A title card for the GLM-5.4 guide, showing the three effort levels low, high and max with max marked as the default
Guides & Insights

How to Use GLM-5.4: Setup, Effort Levels and the Default Trap

Author

jinhao.song

Date Published

Models in this article · 6View all models →
Back to all posts

GLM-5.4's API opened on 2 December 2026, nine days after the model appeared inside Z.ai's Coding Plan. The rate card is $1.40 per million input tokens, $4.40 per million output tokens and $0.26 per million cached input — 11% above GLM-5.3, which lists at $1.26 / $3.96 on the same platform.

The setup is ordinary. The defaults are not. GLM-5.4 cannot turn thinking off, and its reasoning effort defaults to the maximum setting. A team that ports a GLM-5.3 workload by changing only the model name is silently moving to the most expensive configuration the model offers.

The integration is short: one key, one base URL, one model ID. What takes thought is the effort level, the vision path, and the cost arithmetic that follows from both.

Setup in five steps

About ten minutes, and the only unusual part is the effort setting in step three.

1. Create a key and export it. Make an OrcaRouter key in the console and keep it in an environment variable:

export ORCAROUTER_API_KEY="sk-orca-..."

Add z-ai/glm-5-4 to the key's model allowlist if it has one. A key without the model returns 403 model_access_denied, which is a scope problem rather than a bad credential.

2. Check the route. /v1/models lists the whole catalogue regardless of scope, so send a small real request instead:

curl -s https://api.orcarouter.ai/v1/chat/completions \

-H "Authorization: Bearer $ORCAROUTER_API_KEY" \

-H "Content-Type: application/json" \

-d '{"model":"z-ai/glm-5-4","messages":[{"role":"user","content":"ping"}],"reasoning_effort":"low","max_tokens":4096}'

A 200 means the route works. Set the effort explicitly here: the model's default is max, and an omitted effort on a two-word prompt is the first place people notice the bill.

3. Send a real request. The ceiling matters more than usual, because reasoning cannot be turned off:

curl -s https://api.orcarouter.ai/v1/chat/completions \

-H "Authorization: Bearer $ORCAROUTER_API_KEY" \

-H "Content-Type: application/json" \

-d '{

"model": "z-ai/glm-5-4",

"messages": [{"role": "user", "content": "Refactor this function to use the repository pattern: ..."}],

"reasoning_effort": "high",

"max_tokens": 16000

}'

4. Read the response. Same chat-completions shape as any OpenAI-compatible model:

{

"choices": [{"message": {"role": "assistant", "content": "..."}, "finish_reason": "stop"}],

"usage": {"prompt_tokens": 24, "completion_tokens": 812, "total_tokens": 836}

}

usage.completion_tokens_details.reasoning_tokens reports how much of completion_tokens was thinking. If content is empty and finish_reason is length, the reasoning pass used the whole budget — raise max_tokens rather than retrying.

5. Point your SDK at the same host. The base URL replaces the provider's and the model ID is the only other change.

Z.ai's GLM-5.4 announcement, dated 23 November 2026, describing the first Loop Transformer and native vision

Point your SDK at it

Python, with the official OpenAI SDK:

import os

from openai import OpenAI


client = OpenAI(

base_url="https://api.orcarouter.ai/v1",

api_key=os.environ["ORCAROUTER_API_KEY"],

)


response = client.chat.completions.create(

model="z-ai/glm-5-4",

messages=[{"role": "user", "content": "Refactor this function to use the repository pattern: ..."}],

reasoning_effort="high",

max_tokens=16000,

)

print(response.choices[0].message.content)

print(response.usage)

TypeScript:

import OpenAI from "openai";


const client = new OpenAI({

baseURL: "https://api.orcarouter.ai/v1",

apiKey: process.env.ORCAROUTER_API_KEY,

});


const response = await client.chat.completions.create({

model: "z-ai/glm-5-4",

messages: [{ role: "user", content: "Refactor this function: ..." }],

reasoning_effort: "high",

max_tokens: 16000,

});

console.log(response.choices[0].message.content);

GLM-5.4 exposes one endpoint type here: POST /v1/chat/completions. There is no Anthropic-shaped or Responses-shaped surface for it, so an Anthropic SDK client cannot reach it directly. If you need one of those protocols, route to a model that offers it or put a translation layer in front.

Stream the response

Add "stream": true:

curl -N https://api.orcarouter.ai/v1/chat/completions \

-H "Authorization: Bearer $ORCAROUTER_API_KEY" \

-H "Content-Type: application/json" \

-d '{"model":"z-ai/glm-5-4","messages":[{"role":"user","content":"Hello"}],"reasoning_effort":"high","stream":true}'

Each line is data: {...} with a choices[0].delta, ending in data: [DONE]. Reasoning may arrive as delta.reasoning_content before the answer, which is the difference between a spinner and a progress bar on a model tuned for long thinking.

stream = client.chat.completions.create(

model="z-ai/glm-5-4",

messages=[{"role": "user", "content": "Hello"}],

reasoning_effort="high",

stream=True,

)

for chunk in stream:

delta = chunk.choices[0].delta

if getattr(delta, "reasoning_content", None):

continue # hide the thinking, or render it as progress

if delta.content:

print(delta.content, end="", flush=True)

Effort is not optional here

Three levels: low, high and max. There is no medium, and there is no off switch.

That is a change from the earlier GLM-5 line, where thinking could be disabled. On GLM-5.4, passing a disabled thinking configuration fails the request rather than quietly downgrading. The only control you have is how long the reasoning pass runs. OrcaRouter's reasoning guide shows the three request shapes that set it.

• low — the cheapest floor. Still reasons, just briefly. Right for extraction, classification and short rewrites. • high — the setting to use by default in production. Enough depth for most coding and analysis, without the marathon. • max — the default if you specify nothing. Right for the hardest problems and wrong for almost everything else.

Z.ai's own documentation for the Coding Plan maps a "medium" request to high. If you are porting configuration from another vendor, that mapping is worth knowing.

Three effort levels for GLM-5.4: low for extraction, high for production, and max as the silent default

The default is the expensive one

This is the part that costs people money.

A model that defaults to max looks like it has no configuration at all until you read the migration guide. Every request that omits reasoning_effort runs at maximum depth. In an agent loop that fires twenty calls per task, the difference between max and high is not a rounding error.

Two settings make it worse. Sampling defaults are temperature 1.0 and top_p 0.95, which is a creative setting for a coding model; Z.ai recommends adjusting them for deterministic work. And GLM-5.4 exposes a wider parameter set than most: top_k, min_p, frequency_penalty, presence_penalty, repetition_penalty, seed, logprobs and logit_bias all work. That is useful for reproducibility and easy to leave at defaults that fight the task.

The practical rule: set reasoning_effort explicitly on every request, and set it to high unless you have a measured reason to go higher.

Put it to work on one task

Setup is not the test. A single refactor is. Pick one with a checkable outcome, because that is what tells you whether the model is worth its output bill.

A good first task for GLM-5.4: "move this module's database access behind a repository interface, keep the public functions unchanged, and make the existing tests pass." It uses the long context, it has a verifiable answer — the tests — and it fails loudly when the model gets it wrong.

prompt = """Refactor the attached module so that all database access goes through a

repository interface. Keep every public function signature unchanged.

Do not change the tests. If a function cannot be moved without a signature

change, stop and list it instead of guessing."""


response = client.chat.completions.create(

model="z-ai/glm-5-4",

messages=[{"role": "user", "content": prompt}],

reasoning_effort="high",

max_tokens=16000,

)

print(response.choices[0].message.content)

Two things to look at in the result, beyond whether the tests pass. finish_reason should be stop; length means the reasoning pass or the diff hit the ceiling, and a truncated diff is worse than no diff. And compare the diff against the original before running anything: GLM-5.4's long thinking makes it thorough, and thorough sometimes means "also renamed three things you did not ask it to rename."

Check the answer before you ship it

Three checks, in this order.

• The tests, unchanged. If the model edited the test file, the run is void. Diff the test directory first. • The public surface. git diff --stat on exported functions should be empty. A refactor that changes call sites is a different, larger change. • The stopping reason. A model that stopped mid-file still returns 200. Check finish_reason before the tests, so a truncated answer is not mistaken for a failing one.

Run the same task twice and compare usage. A stable token count means the prompt is doing the work; a swing of thousands means the model is exploring, and max effort is making it worse.

Make it repeatable

One refactor is a demo. A backlog is the job. The loop is small, and the only discipline it needs is a cost line per task:

import json


for task in backlog:

r = client.chat.completions.create(

model="z-ai/glm-5-4",

messages=[{"role": "user", "content": task.prompt}],

reasoning_effort="high",

max_tokens=16000,

)

usage = r.usage

cost = usage.prompt_tokens / 1e6 * 1.4 + usage.completion_tokens / 1e6 * 4.4

print(json.dumps({

"task": task.name,

"diff": r.choices[0].message.content,

"prompt_tokens": usage.prompt_tokens,

"completion_tokens": usage.completion_tokens,

"cost_usd": round(cost, 4),

"finish_reason": r.choices[0].finish_reason,

}))

At 80,000 input and 8,000 output tokens, one refactor costs about $0.15. Half of that input on a warm cache takes it to roughly $0.09, because cache reads bill at $0.26 instead of $1.40. Keep the instructions and the repository conventions in a stable prefix, and the difference compounds across a backlog.

Write the output as JSONL, run the tests in CI, and review only the diffs that pass. The human step is the merge, not the extraction.

Vision input without the guesswork

GLM-5.4 is the first Z.ai flagship with native vision. Text, image and video input all work; output is text.

Images go in as an image_url content part, with a public URL or a base64 data URI:

response = client.chat.completions.create(

model="z-ai/glm-5-4",

messages=[{

"role": "user",

"content": [

{"type": "text", "text": "Why does this layout overflow on mobile?"},

{"type": "image_url", "image_url": {"url": "https://example.com/screenshot.png"}},

],

}],

reasoning_effort="high",

)

The vision capability is not new to the family — GLM-5.3-Flash shipped with visual input in August. What changed is that vision now sits on the flagship. For coding work, that means a screenshot of a broken UI can go into the same request as the component source, which is the workflow the previous flagship could not do at all.

Video input follows the same content-part pattern on the compatible surface. Very large files run into the upstream size cap; for anything long, host it and pass a URL rather than base64.

Long context, and the 512K advice

The window is 1,048,576 tokens and the maximum output is 128,000 tokens. Both are large enough that the context is not the constraint for repository-scale work.

Z.ai's docs add a detail worth taking seriously: for coding, they recommend setting the client window to 512,000 tokens rather than the full million. A model that is told it has a million tokens of room will use them, and the second half of a very long context is where retrieval quality and cost both get worse. Halving the window is a cheap way to keep the model focused.

On the router, the advertised maximum output is 128,000. Long outputs at that size are slow and expensive; if you are generating a file rather than a diff, expect a multi-minute call and set the client timeout accordingly.

Tool calls and structured output

The parameters are the standard ones: tools, tool_choice, response_format, structured_outputs.

Two behaviours are worth planning for, both from independent testing rather than vendor documentation. Tool-call failures happen — one harness measured 1.56% of calls failing, 11th of 17 models in that test — but recovery is strong, with about two-thirds of failed calls recovered on retry. If your agent gives up on the first failed tool call, you will see a worse failure rate than the model actually has.

The other is latency. max effort can keep reasoning long enough to hit default agent timeouts. A 60-second timeout that worked for GLM-5.3 may be too short here. Set timeouts generously and log completion_tokens_details.reasoning_tokens so a timeout can be diagnosed as thinking rather than a hung connection.

What a GLM-5.4 call actually costs

Three worked examples at the list rate:

• 1,000 input tokens and 500 output tokens — $0.0014 plus $0.0022, or $0.0036. • 100,000 input tokens and 10,000 output tokens — $0.14 plus $0.044, or $0.184. • The same 100,000-token prompt with a warm cache — input falls to $0.026, and the call costs $0.070. That is a 62% cut.

The cache line deserves more attention than the headline rate. Output costs 3.1 times input per token, so the balance of a prompt matters more than its length: a summarisation job and a code-generation job with the same input count can differ by five times in cost.

The OrcaRouter model page for GLM-5.4, showing a 1M context window, 128K maximum output and $1.40 input / $4.40 output per million tokens

Z.ai is also offering free cache storage for a limited period, with no end date published. Any figure that assumes cached input should be treated as a current price rather than a permanent one.

Five errors and what they mean

• 400 on a request that disables thinking — GLM-5.4 rejects it. Remove the disabled-thinking configuration and set reasoning_effort instead. • A timeout with no output — usually max effort still reasoning. Raise the timeout or lower the effort. • 404 model_not_found — the prefix is missing. It is z-ai/glm-5-4, not glm-5.4. • Empty or truncated content with finish_reason: "length" — the 128K output ceiling is shared with reasoning. Raise max_tokens. • 403 model_access_denied — the key's model scope. Fix it in the console.

Who this setup is for

GLM-5.4 is the right call if you are already on GLM-5.3 and want vision without changing providers, if your work is repo-scale coding that benefits from a long context, or if you want to test a looped architecture against your own harness before the vendor publishes numbers.

The review covers what the model does with those tokens, and the API launch post covers what changed on 2 December, and the Loop Transformer write-up explains why the model reasons this long. Set the effort level first. Everything else about the integration is routine.

Sourcing note: model specifications and prices from OrcaRouter's live model record on 2 December 2026; architecture and effort behaviour from Z.ai's 23 November announcement and OrcaRouter's migration notes. Throughput and token-efficiency claims are vendor-reported. No part of this guide was validated by a production run of our own.

Compared in this article2

Detected from this article · Benchmarks: Artificial Analysis · updated daily