Guide
GLM 5.4 API Guide: Capabilities, First Request and Pricing
1M context and always-on thinking, from your first request to a cost estimate
- Model
- glm-5.4
On this page
What is GLM 5.4?
GLM 5.4 is the flagship model from Z.ai (Zhipu), built for complex coding and long-horizon reasoning, and it is now available on HiAPI. It has a 1M-token context window, returns up to 128K output tokens per response, and always runs in thinking mode. On HiAPI it currently accepts text input and returns text.
Under the hood it uses a Loop Transformer design: it reuses the 28 layers of the GLM-5 base model and runs them twice, without adding parameters.

What GLM 5.4 is good at
- Complex coding: large software engineering tasks that need consistent logic across many steps.
- Long-horizon reasoning: problems with long causal chains and multi-step deduction.
- Very long text analysis: reading a code repository or long documents within the 1M context and reporting on them.
- Doing more through code: writing code that generates or edits video, builds games or creates 3D models. The model delivers code and text; you get the finished video, game or model by running that code.

Your first GLM 5.4 API request
Send requests to /v1/chat/completions with the model name glm-5.4. Replace YOUR_API_KEY with your own key:
curl https://api.hiapi.ai/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "glm-5.4",
"messages": [
{"role": "user", "content": "Review the following function, find the bug, and return a fixed version with a short explanation: def average(xs): return sum(xs) / (len(xs) - 1)"}
]
}'The reply text is in choices[0].message.content. If your project already uses the Chat Completions format, add glm-5.4 as another model in your existing client.
Always-on thinking: what to plan for
Thinking mode cannot be disabled on GLM 5.4. Two things follow. First, leave enough output length for the reasoning: if your code sets a maximum output length, do not reuse a small value tuned for short answers. Second, allow more response time and loosen client timeouts for harder tasks; for long tasks, use streaming. If time to first token is critical for you, test with your own samples before deciding.
Prompting tips
- State the goal and the acceptance criteria: what to fix, which behavior must not change, and what counts as done.
- Split material into labeled sections: when you include several files, label each with its path so the model can cite it.
- Specify the deliverable: only the changed function, a patch, or a plan first and code second.
- Make code runnable: name the language version, runtime and available libraries.
GLM 5.4 pricing and cost estimates
GLM 5.4 is billed per token:
| Billing item | Price (USD / 1M tokens) |
|---|---|
| Input | $1.177 |
| Output | $4.118 |
| Cached input read | $0.26 |
Two examples:
- 100K input tokens and 10K output tokens: 0.1 × $1.177 + 0.01 × $4.118 ≈ $0.159.
- The same request where 80K of the 100K input tokens are billed as cached reads and 20K at the input price: 0.08 × $0.26 + 0.02 × $1.177 + 0.01 × $4.118 ≈ $0.086.

To budget, run a batch of your own samples, record the usage the API returns, and track input and output separately. Output costs more per token than input, so estimate long-output tasks on their own.
Troubleshooting
- Authentication fails: check that the key is complete and the header is
Authorization: Bearer YOUR_API_KEY. - Model not found: make sure the model name is exactly
glm-5.4. - The answer stops early or is empty: check whether the maximum output length is too small; the reasoning needs room too.
- The request times out: use streaming, loosen the client timeout, or split a large task into steps.
See the GLM 5.4 model page for all parameters and current pricing.
Related articles
View all articles →-
Guide
Midjourney Niji 8 Getting Started Guide: Text-to-Image, Eight Parameters, and Task Polling
Developer-oriented integration notes for midjourney/niji: image selection, input parameters, POST /v1/tasks, and per-call billing
-
Guide
HeyGen Avatar 6 Turbo image-to-video: Capabilities, Pricing and Integration
From a portrait to a talking clip: input shapes, parameters and per-second cost
8 min read -
Guide
HeyGen Avatar 6 Turbo identity-to-video: Capabilities, Pricing and Integration
From scripts and recordings to talking-head video: capability boundaries, API details and cost estimation
7 min read