API compatibility - 2 documented limits
Z.ai (GLM) API compatibility
Z.ai documents an OpenAI-compatible API at https://api.z.ai/api/paas/v4/ (chat/completions and responses). Its Anthropic-compatible base URL, the value for ANTHROPIC_BASE_URL, is https://api.z.ai/api/anthropic. The docs list 2 limitations: 2 for the OpenAI-compatible layer.
Verified against Z.ai's own documentation. Not documented means the docs read that day do not say; it never means No.
Compare every provider in the API compatibility matrix.
OpenAI-compatible API
Supportedhttps://api.z.ai/api/paas/v4/- Endpoints
- chat/completions
- responses
- Auth
- Authorization: Bearer ZAI_API_KEY
- Notes
- General (pay-as-you-go) endpoint is https://api.z.ai/api/paas/v4. GLM Coding Plan subscribers must use dedicated endpoints instead: OpenAI Chat Completions at https://api.z.ai/api/coding/paas/v4 and OpenAI Responses at https://api.z.ai/api/v1 (the Responses endpoint is documented only on the Coding Plan page). Thinking is toggled via extra_body {"thinking": {"type": "enabled"}}.
From the docs
Z.AI provides interfaces compatible with OpenAI API, which means you can use existing OpenAI SDK code and seamlessly switch to Z.AI's model services by simply modifying the API key and base URL.
Anthropic-compatible API
Supportedhttps://api.z.ai/api/anthropic- Auth
- ANTHROPIC_AUTH_TOKEN
- Notes
- Documented in the GLM Coding Plan context (Claude Code guide and the Coding Endpoint table). The docs read today do not describe a separate pay-as-you-go Anthropic endpoint.
From the docs
GLM Coding Plan supports both the Anthropic and OpenAI protocols. Make sure to configure the correctBase URL: | Anthropic Messages |https://api.z.ai/api/anthropic| OpenAI Chat Completions |https://api.z.ai/api/coding/paas/v4| OpenAI Responses |https://api.z.ai/api/v1|
Documented limitations
Parameters, content types and features Z.ai (GLM)'s docs say its compatibility layers ignore, reject or change, each with the line it comes from. A layer with nothing listed may still differ in ways the docs do not spell out.
OpenAI-compatible layer2
temperature range (0,1); temperature = 0 (do_sample = False) not applicable via OpenAI calls
Note: The temperature parameter range is (0,1), do_sample = False (temperature = 0) is not applicable in OpenAI calls.
docs.z.ai/guides/develop/openai/python general statement of differences
In some scenarios, there are still differences between Z.AI and OpenAI interfaces, but this does not affect overall compatibility.
docs.z.ai/guides/develop/openai/python
Anthropic-compatible layer0
No limitations listed in the docs read.
Example from Z.ai (GLM)'s docs
Copied verbatim from the provider's documentation, placeholders included.
from openai import OpenAI
client = OpenAI(
api_key="your-Z.AI-api-key",
base_url="https://api.z.ai/api/paas/v4/"
)
completion = client.chat.completions.create(
model="glm-5.3",
messages=[
{"role": "system", "content": "You are a smart and creative novelist"},
{"role": "user", "content": "Please write a short fairy tale story as a fairy tale master"}
]
)More on Z.ai (GLM)
Newsletter
Know when a provider changes its API
One email per week. New models, new endpoints and the compatibility changes that break a base URL, and what they mean for your stack.