How to Use GLM-5.4: 2 Base URLs, 1M Context, Max Thinking
OpenLux TeamPublished
GLM-5.4's model API opened on 2 December 2026, nine days after the model first appeared inside Z.ai's Coding Plan, according to Zhipu's changelog. The model code is glm-5.4, the context window is 1M tokens and a single response can run to 128K tokens, per Z.ai's model page. Two details decide most first-day problems. Thinking cannot be switched off: thinking.type accepts only enabled, and Z.ai recommends reasoning_effort: max. And on OpenLux the model currently sits in exactly one group, glm-1, at $1.54 per million input tokens and $4.84 per million output when we read the price API at 02:00 Beijing time on 4 December. Get the key's group and the Base URL right and the rest is a model name.
Current group prices are on the glm-5.4 model page. For the launch price and how it compares with GLM-5.3, see GLM-5.4 API Pricing and GLM-5.4 vs GLM-5.3; this guide covers only the setup. Compiled by the OpenLux Team from documentation read on 4 December 2026.
What you are connecting to
Zhipu's changelog lists three request formats for GLM-5.4: OpenAI Chat Completions, OpenAI Responses and Anthropic Messages. On OpenLux, the glm-5.4 page lists two of them, Anthropic Messages and OpenAI Chat Completions, so those are the two this guide uses. Both use the same key.
| Setting | OpenAI Chat Completions | Anthropic Messages |
|---|---|---|
| Base URL to enter in the client | https://api.openlux.ai/v1 |
https://api.openlux.ai (no /v1) |
| Request path | /v1/chat/completions |
/v1/messages |
| Key header | Authorization: Bearer <key> |
x-api-key: <key> or Bearer |
| Model name | glm-5.4 |
glm-5.4 |
| Group on OpenLux (4 Dec) | glm-1, ratio 1.1 | glm-1, ratio 1.1 |
| Price per million tokens | $1.54 input / $0.286 cached / $4.84 output | same |
The glm-1 prices are Z.ai's list rates of $1.40, $0.26 and $4.40 on its pricing page, multiplied by the group ratio of 1.1. The group's description on OpenLux reads: smooth semantic understanding, suited to copywriting and summarization. The difference between the two Base URLs, with and without /v1, is the most common setup mistake; the full rules for every format are in the interface guide.
It also helps to know what kind of model is on the other end. Z.ai describes GLM-5.4 as a 750-billion-parameter "Loop Transformer" that runs the 28 layers of the GLM-5 base model twice, and says it performs like a model in the 2 to 3 trillion parameter class. Z.ai quotes output speeds of up to 200 tokens per second off-peak and 70 to 80 at peak. With thinking always on, those speeds matter: a reply with 4,000 tokens of reasoning takes roughly 20 seconds off-peak and closer to a minute at peak, before any network overhead.
Step 1: create a key in the right group and test it
Create a key on the token page of the OpenLux console (https://www.openlux.ai/console/token). Each model only answers keys in a group that model supports, and glm-5.4 is in one group today, so the key must include glm-1. A key created for a Claude or Gemini group will return a "model unavailable" error for glm-5.4 even though the key itself is valid.
Then check the address and the key before touching any client:
export OPENLUX_API_KEY=sk-...
curl -sS https://api.openlux.ai/v1/models \
-H "Authorization: Bearer $OPENLUX_API_KEY"
A model list means both are correct. A 401 means the key is wrong or missing. Anything else after this point is about the Base URL or the model name, not authentication.
Step 2: send the first request with curl
The smallest working call in the OpenAI format sends one user message to glm-5.4. The temperature and top_p values are the ones Z.ai recommends for this model, 1 and 0.95:
curl -sS https://api.openlux.ai/v1/chat/completions \
-H "Authorization: Bearer $OPENLUX_API_KEY" \
-H "content-type: application/json" \
-d '{
"model": "glm-5.4",
"temperature": 1,
"top_p": 0.95,
"messages": [{"role": "user", "content": "List three risks in this SQL migration: ..."}]
}'
Read the usage object in the reply before anything else. GLM-5.4 always reasons before it answers, so the output token count includes thinking, and even a short answer can carry several thousand output tokens. At $4.84 per million output tokens, 4,000 tokens of thinking and answer cost about $0.019.
Step 3: call it from Python with the recommended settings
With the OpenAI Python SDK, only base_url and model change from a standard OpenAI setup. Z.ai's thinking options are not part of the OpenAI schema, so they go in extra_body:
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.openlux.ai/v1", api_key=os.environ["OPENLUX_API_KEY"])
resp = client.chat.completions.create(
model="glm-5.4",
temperature=1,
top_p=0.95,
reasoning_effort="max", # Z.ai's recommendation; try "high" for faster replies
extra_body={"thinking": {"type": "enabled", "clear_thinking": False}},
messages=[
{"role": "system", "content": "You are a senior backend reviewer."},
{"role": "user", "content": "Review this diff for concurrency bugs: ..."},
],
)
print(resp.choices[0].message.content)
print(resp.usage)
thinking.type only accepts enabled, so leaving it out does not turn thinking off. clear_thinking: False keeps earlier reasoning in multi-turn conversations, which Zhipu's changelog says is already the default on the standard endpoint. These are Z.ai's documented parameters; if a request with them returns an error through OpenLux, drop the extra_body line first and test again, since the defaults already match Z.ai's recommendation.
Step 4: use the Anthropic format and Claude Code
Because glm-5.4 also accepts Anthropic Messages on OpenLux, tools written for Claude can call it by changing two settings. With the Anthropic Python SDK, the Base URL has no /v1, because the SDK adds /v1/messages itself:
import anthropic
client = anthropic.Anthropic(base_url="https://api.openlux.ai", api_key="sk-...")
msg = client.messages.create(
model="glm-5.4",
max_tokens=8192,
messages=[{"role": "user", "content": "Write a pytest for this function: ..."}],
)
print(msg.content[-1].text, msg.usage)
For Claude Code, set the Base URL, the key and the model in the environment before starting it:
export ANTHROPIC_BASE_URL=https://api.openlux.ai
export ANTHROPIC_AUTH_TOKEN=sk-...
export ANTHROPIC_MODEL=glm-5.4
claude
If Claude Code reports a 404 on /v1/v1/messages, the Base URL was entered with /v1; remove it. Set max_tokens with the 128K output cap in mind, and leave enough room for thinking: a low cap can cut off the answer after the reasoning has used most of it.
Step 5: send images and stream tool calls
GLM-5.4 reads video, images, text and files, according to Z.ai's model page. For images, Z.ai's format is a content block of type image_url, with either a public URL (recommended) or a Base64 data URL; several blocks send several images:
resp = client.chat.completions.create(
model="glm-5.4",
messages=[{"role": "user", "content": [
{"type": "image_url", "image_url": {"url": "https://example.com/dashboard.png"}},
{"type": "text", "text": "Which metric on this dashboard changed most, and by how much?"},
]}],
)
For agents that call tools, Z.ai recommends streaming with both stream: true and tool_stream: true, so tool-call arguments arrive as they are generated instead of after the whole reasoning step. In the OpenAI SDK that is stream=True plus extra_body={"tool_stream": True}. Function calling, context caching and JSON-structured output are all listed as supported on the model page. The model page documents the image block in detail; for video and file input, check the block types in Z.ai's API reference and test one small request through OpenLux before building a pipeline around them.
Keep long contexts cheap with caching
The 1M context is useful for whole repositories or long document sets, and it is also where cost adds up. One request with 200,000 input tokens and 8,000 output tokens costs $0.347 in the glm-1 group (0.2 × $1.54 + 0.008 × $4.84). If 90% of that input is a cached prefix, the same request costs $0.121 (0.18 × $0.286 + 0.02 × $1.54 + $0.039), or 35% of the uncached price.
Caching works on repeated prefixes, so put the stable part first: system prompt, tool definitions, the repository or documents. Put the changing question last. In a multi-turn agent, preserved thinking also adds earlier reasoning to every later request, which makes the cached share of each request more important as the conversation grows. How cached tokens appear in OpenLux usage logs is covered in OpenLux billing.
Fixes for the first errors you are likely to see
Most failures in the first hour fall into four cases. A 401 means the key or its header is wrong; re-run the /v1/models check. A "model unavailable" error with a valid key means the key's group does not include glm-1. A 404 with /v1/v1/ in the path means an Anthropic-style client was given the /v1 Base URL; a 404 with no /v1 at all means an OpenAI-style client was given the bare domain. And a reply that stops mid-answer usually means max_tokens was too small for thinking plus answer.
Slow first tokens are expected rather than an error. With reasoning_effort at max, GLM-5.4 thinks before writing, and Z.ai itself lists over-long "marathon thinking" as a known weakness. For chat-style uses where speed matters more than depth, test high against max on the same 20 prompts and compare quality, output tokens and time.
What to set before you go to production
Fix three settings first. Create a key that includes the glm-1 group, since that is the only group serving glm-5.4 today; check the model page before launch in case groups change. Choose the reasoning level per job rather than globally: max for code review and multi-step agents, high or lower for summaries and classification. And log usage on every call for the first week, because with thinking always on, output tokens, not input, decide most of the bill.
If you are moving from GLM-5.3, the switch is smaller than it looks. Zhipu's changelog says GLM-5.4's other protocol parameters match GLM-5.3, so existing code needs a new model name and a check of how it handles preserved reasoning across turns. GLM-5.4 adds video, image and file input, which GLM-5.3 does not take, so multimodal requests are new code rather than a migration. Run the same 30 to 50 real tasks on both before moving traffic, and compare output tokens per task as well as answers.
OpenLux Team