Notice: MAI Image 2.7 launch limited-time 20% off, covering the full text-to-image and image editing lineup, try it now
Notice: MAGI 2 launch limited-time 20% off, covering text-to-video, image-to-video, and reference-to-video across the board. Try it now
Notice: Seed Audio 1.5 launch limited-time 20% off, covering text-to-audio, video dubbing, audio track separation, and video translation across the board. Try it now
Notice: HeyGen Avatar 6 Turbo is 20% off for a limited time, and all three video pipelines are eligible.Try it now
Notice: Midjourney Niji 8 is now available, 20% off · Create now
Notice: Hunyuan Image 3.0 launch limited-time 20% off, for both text-to-image and instruction-based editing · Try it now
Announcement 1 of 6
Blog

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

Dec 2, 2026 4 min read
Flat woven pattern of dark coffee and oat-brown bands with restrained brass-colored strips on a dark background.
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.

Flat woven illustration: three abstract shapes on the left feed through threads into a central woven column, which splits into several bands on the right.
Text goes into the model and comes out as text results for different uses.

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.
Dark brown and oat-colored bands woven into a closed square, surrounded by a broken outline.
The solid weave is the text the model handles directly; the outline is the part where you run code or tools yourself.

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 itemPrice (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.
On a dark brown background, two woven bands merge and form progressively larger woven blocks to the right.
Input and output usage add up to the total cost as calls accumulate.

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 →

Start building with persistent AI artifacts

Get your API key and call image, video and audio models through one task-based API.

Read the API docs