Z.ai

GLM 5.4

Z.ai's new flagship for coding and agent work runs part of its network twice per token, buying deeper reasoning without adding parameters.

Z.ai's first Loop Transformertext inputtext output

Replaces GLM 5.3: same input and output price, context 1M → 1M, max output 1M → 262K.

Launch coverage: GLM-5.4 release notes

Run this model

zai/glm-5.4

Use an endpoint supported by this model.

Get a key for this setup →
Thinking guide →
const response = await fetch('https://api.minirouter.sh/v1/chat/completions', {  method: 'POST',  headers: {    Authorization: `Bearer ${process.env.MINIROUTER_KEY}`,    'Content-Type': 'application/json',  },  body: JSON.stringify({    model: 'zai/glm-5.4',    messages: [{ role: 'user', content: 'Why is the sky blue?' }],    max_tokens: 1024,  }),}) const data = await response.json()console.log(data.choices[0].message.content)
Read docs →

Set max_tokens on every request and cap agent turns.

Model overview

Input / 1M
$1.47
All-in MiniRouter rate
Output / 1M
$4.62
All-in MiniRouter rate
Context
1M
1,048,576 tokens
Max output
262K
tokens
Architecture
Loop Transformer
Layers 27–54 run twice per token
Reasoning
low · high · max
Always on
Announced
23 Nov 2026
publisher release

Compare text-model alternatives or estimate token costs for your workload.

How it works

Same weights, a second pass

Z.ai aims GLM-5.4 at long-chain reasoning work such as large-scale software engineering, and at code that produces video, games, 3D scenes and CAD models.

Z.ai turned its 750B-scale GLM-5 base into a Loop Transformer through continued training rather than pre-training from scratch. A 28-layer middle block runs twice per token with shared weights, so the model gets deeper without getting bigger. Z.ai says the result reaches intelligence comparable to 2T–3T-parameter models.

In a controlled test on a 30B model with the same architecture, Z.ai reports that looping cut average output length by 10–14% on most benchmarks: part of the reasoning moves from visible tokens into the loop.

Layer layout

Looped block
28 layers × 2Layers 27–54, shared weights
Layer passes per token
106From 78 stored layers, counted from Z.ai's diagram
Second-pass KV cache
128-token windowReuses the first pass's sparse KV for the rest
Architecture diagram and text in the Z.ai announcement ↗, November 23, 2026.
View chart data
GLM-5.4 layer blocks
BlockLayersCountPasses per token
Prelude1–26261
Loop27–54282
Coda55–78241
Total1–7878 stored106 layer passes
Making the loop practical

Three changes keep a second pass affordable.

Looping layers of a pre-trained model naively makes activations blow up and multiplies KV-cache memory by the loop count. Z.ai made three changes at 750B scale.
  1. [ 01 ]

    Gated updates

    Per-token gates control how much each pass writes back. The first pass writes conservatively to build context; the second opens the gates to refine. Harder tokens get larger first-pass updates.

  2. [ 02 ]

    Hybrid KV cache

    The second pass reuses the sparse KV selected in the first and keeps only a local sliding window of its own. An extra loop costs one window of cache, not a full-context copy, which Z.ai says keeps the added 1M-context serving cost over GLM-5.3 well under control.

  3. [ 03 ]

    Sparse index reuse

    The second pass reuses the first pass's sparse-attention indices instead of recomputing them. Z.ai reports nearly identical results with no extra indexing cost.

Z.ai head-to-head

A clear edge over GLM-5.3, close against the field

Z.ai published no standard benchmark scores for GLM-5.4. Its pairwise comparisons put GLM-5.4 ahead of GLM-5.3 in 51.1% of cases and behind in 23.1%. The margin narrows against Kimi K3.1 Pro and is roughly even against DeepSeek V4.1 Flash 1017.

Three comparisons

Win, tie and loss rates

  • GLM-5.4 wins
  • Ties and opponent wins

GLM-5.4 vs

GLM-5.3

  • GLM-5.4 wins51.1%
  • Tie25.7%
  • GLM-5.3 wins23.1%

0 to 100% of comparisons

GLM-5.4 vs

Kimi K3.1 Pro

  • GLM-5.4 wins41.8%
  • Tie26.9%
  • Kimi K3.1 Pro wins31.3%

0 to 100% of comparisons

GLM-5.4 vs

DeepSeek V4.1 Flash 1017

  • GLM-5.4 wins36.6%
  • Tie30.2%
  • DeepSeek V4.1 Flash 1017 wins33.2%

0 to 100% of comparisons

Win-rate chart in the Z.ai model documentation ↗, November 23, 2026. Z.ai does not disclose the task set or how comparisons were judged.
View chart data
GLM-5.4 head-to-head results
OpponentGLM-5.4 winsTieOpponent wins
GLM-5.351.1%25.7%23.1%
Kimi K3.1 Pro41.8%26.9%31.3%
DeepSeek V4.1 Flash 101736.6%30.2%33.2%
Before you switch

Budget for long thinking.

Z.ai says GLM-5.4 tends to get caught in overly long "marathon thinking" loops. The extra reflection usually improves accuracy, but it costs output tokens and time.
  1. [ 01 ]

    Set hard limits

    Reasoning cannot be turned off. Give every request a max_tokens value and every agent loop a turn limit.

  2. [ 02 ]

    Choose the effort

    Effort can be low, high or max. Z.ai recommends max with temperature 1; compare lower efforts on routine steps by accepted results and billed usage.

  3. [ 03 ]

    Text in, text out

    MiniRouter accepts text input only for this model and does not enforce response schemas. Extract document text first, and validate any JSON in your application.

  4. [ 04 ]

    Retest against GLM-5.3

    On MiniRouter, GLM-5.3 supports response schemas and up to 1M output tokens; GLM-5.4 caps a response at 262,144 tokens and has no schemas. GLM-5.3 still wins 23.1% of Z.ai's comparisons; check both on your own tasks.

Route

One route, standard clients.

Authenticate with a MiniRouter bearer key. Caller-provided upstream credentials are not used on this route.
Base URLhttps://api.minirouter.sh/v1
Model IDzai/glm-5.4
Endpoints/v1/chat/completions/v1/messages/v1/responses
Parametersmax_tokens, temperature, stop, tools, tool_choice, reasoning, include_reasoning
Structured outputNot enforced; a requested format is dropped and the answer is plain text.
ModalitiesInput: text · Output: text

Configured providers. Priority follows the live catalog order.

ProviderPriorityInput / 1MOutput / 1MParametersAccess
vercel
1$1.47$4.62max_tokens, temperature, stop, tools, tool_choice, reasoning, include_reasoningMiniRouter balance

Every model, one key.