Developer guide
The GLM-5 API, from first request to production

§ 01Two routes
Where you can call GLM-5
Z.ai's platform
Z.ai, the developer of GLM, runs its own API. The general endpoint is https://api.z.ai/api/paas/v4/chat/completions and follows the OpenAI chat completions protocol, so the official OpenAI SDKs work by changing the base URL. Z.ai's documentation also lists a coding endpoint (https://api.z.ai/api/coding/paas/v4), a Responses-style endpoint (https://api.z.ai/api/v1) and an Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) for tools that expect those formats.
On Z.ai the model codes are short: glm-5.3, glm-5.3-flash and glm-5.3-flashx. Thinking is switched on with "thinking": {"type": "enabled"}, and the depth is set with reasoning_effort. You need a Z.ai account and API key; check Z.ai's own pricing page for its current rates.
OpenRouter
OpenRouter is an aggregator: one key and one endpoint (https://openrouter.ai/api/v1/chat/completions) give you every GLM-5 model alongside models from other labs. Model IDs carry a vendor prefix — z-ai/glm-5.3, z-ai/glm-5.3-flash and so on — and reasoning is controlled with a single reasoning object such as {"effort": "low"}.
The prices in the table below are OpenRouter's. OpenRouter is also how this site runs its free chat, so the behaviour you see in our chat is what you will get from the API.
- Pick Z.ai if you want the developer's own platform, its coding endpoint or Anthropic-compatible access.
- Pick OpenRouter if you want one bill for many model families and easy switching between them.
- Either way, your code is the same OpenAI-style request with a different base URL and model name.
§ 02Prices
GLM-5 API prices on OpenRouter
USD per 1 million tokens, plus an estimate for 1,000 typical chat turns. Click a model for its full guide.
| Model | Model ID | Context | Input / 1M | Output / 1M | 1,000 chats* |
|---|---|---|---|---|---|
| GLM-5 | z-ai/glm-5 | 205K | $1 | $3.20 | $3.74 |
| GLM-5-Turbo | z-ai/glm-5-turbo | 203K | $1.20 | $4 | $4.60 |
| GLM-5V-Turbo | z-ai/glm-5v-turbo | 203K | $1.20 | $4 | $4.60 |
| GLM-5.1 | z-ai/glm-5.1 | 205K | $1.40 | $4.40 | $5.18 |
| GLM-5.2 | z-ai/glm-5.2 | 1.05M | $0.0341 | $7 | $4.95 |
| GLM-5.3 | z-ai/glm-5.3 | 1.05M | $0.079 | $1.40 | $1.10 |
| GLM-5.3 Flash | z-ai/glm-5.3-flash | 1.05M | $0.0052 | $0.1985 | $0.15 |
| GLM-5.3 FlashX | z-ai/glm-5.3-flashx | 1.05M | $0.37 | $1.25 | $1.43 |
| GLM-5.3 Prime | z-ai/glm-5.3-prime | 1M | $2.80 | $8.80 | $10 |
*1,000 chat turns of 1,500 input and 700 output tokens each. Prices from the OpenRouter model list at the time of writing; reasoning tokens are billed as output.
§ 03Code
Copy-ready requests
Set your key in an environment variable — never put it in client-side code or a public repository.
OpenRouter
curl https://openrouter.ai/api/v1/chat/completions \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "z-ai/glm-5.3",
"messages": [
{"role": "system", "content": "You are a concise senior engineer."},
{"role": "user", "content": "Explain idempotency keys in two paragraphs."}
],
"reasoning": {"effort": "low"},
"max_tokens": 1024,
"stream": false
}'Z.ai platform
curl -X POST "https://api.z.ai/api/paas/v4/chat/completions" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ZAI_API_KEY" \
-d '{
"model": "glm-5.3",
"messages": [{"role": "user", "content": "Summarise the CAP theorem."}],
"thinking": {"type": "enabled"},
"reasoning_effort": "low"
}'Z.ai uses short model codes (glm-5.3, glm-5.3-flash) and a separate thinking switch. Check Z.ai's documentation for the latest parameters and limits.
§ 04Details
Parameters that matter
Reasoning is part of the answer
GLM-5.3 always reasons before it answers; you choose how much. Its model card lists three reasoning_effort levels — low, high and max — and says the default is max if you pass nothing. For chat and simple tools, set a low effort explicitly: answers arrive faster and cost less, because reasoning tokens are billed as output.
When streaming through OpenRouter, the reasoning arrives in delta.reasoning and the final text in delta.content. Show the first as a collapsible "thinking" panel or hide it, but do not paste it back into the conversation history.
Sending images to GLM-5.3 Flash
GLM-5.3 Flash, GLM-5.3 FlashX and GLM-5V-Turbo accept images. Send the user message as an array of parts: a text part and an image_url part whose url is either a public HTTPS address or a base64 data URL such as data:image/jpeg;base64,…. GLM-5.3 and GLM-5.3 Prime are text-only, so route image requests to Flash.
Resize large photos before sending them. A long side of about 1,024 pixels keeps the request small and is enough for most questions about documents, charts and screenshots.
Context and output limits
GLM-5.2, GLM-5.3 and GLM-5.3 Flash list a context of 1,048,576 tokens on OpenRouter, and up to 943,718 output tokens. That does not mean you should use it all on every call: input tokens are cheap on these models, but long outputs are not, so cap max_tokens to what your interface can show.
For agents, keep the system prompt stable and append to the conversation rather than rewriting it; providers that cache prompts can then reuse earlier work.
- Use stream: true for anything a person is waiting on.
- Retry 429, 502 and 503 responses with a short backoff.
- Log usage from the final chunk to track your spend.
§ 05FAQ
GLM-5 API questions
Q01Is the GLM-5 API compatible with the OpenAI SDK?
Yes. Both Z.ai's endpoint and OpenRouter accept OpenAI-style chat completions requests. Point the SDK's base URL at the provider and use a GLM model name.
Q02What is the cheapest GLM-5 model to call?
GLM-5.3 Flash. On OpenRouter it costs $0.0052 per million input tokens and $0.1985 per million output tokens, and it also reads images and video.
Q03What are the GLM-5.3 model IDs?
On OpenRouter: z-ai/glm-5.3, z-ai/glm-5.3-flash, z-ai/glm-5.3-flashx and z-ai/glm-5.3-prime. On Z.ai's platform: glm-5.3, glm-5.3-flash and glm-5.3-flashx.
Q04Can I turn reasoning off?
GLM-5.3 always reasons on Z.ai's platform. You can keep it short by asking for a low reasoning effort, which is what our free chat does by default.
Q05Is there a free GLM-5 API?
This site does not offer a public API. You can test GLM-5.3 and GLM-5.3 Flash for free in our web chat, then move to Z.ai or OpenRouter for programmatic access.
Try it now
Ask GLM-5.3 something real.
No account, no card, no install. Type a question and watch GLM-5.3 Flash answer in seconds — switch to GLM-5.3 for the hardest problems.