You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
glm-5.2[1m] fails with upstream 400 "Unknown Model" (Z.AI code 1211) — bracketed 1M suffix forwarded verbatim to openai-chat endpoint #41
Routing Codex to Z.AI's GLM-5.2 1M-context variant with the model ID glm-5.2[1m] fails on every request with an upstream 400 error
(Z.AI code 1211, "Unknown Model"). The bare glm-5.2 code is accepted by
the provider; only the bracketed [1m] variant is rejected.
glm-5.2[1m] is Z.AI's documented, official model ID for the 1M-context
variant, so this looks like a model-string passthrough issue in opencodex
rather than an invalid model on my side.
Environment
opencodex version: [e.g. output of ocx --version]
Codex CLI version: [e.g. codex --version]
OS: [macOS / Linux / Windows + arch]
Provider / adapter: Z.AI GLM Coding Plan via openai-chat adapter
baseUrl: [the Z.AI endpoint configured in config.json]
Auth mode: key
Steps to reproduce
Configure a Z.AI (GLM) provider in ~/.opencodex/config.json using the openai-chat adapter.
Start the proxy: ocx start
Run Codex against the 1M variant: codex -m "<provider>/glm-5.2[1m]" "hello"
Expected
Request routes to GLM-5.2 with the 1M context window. Z.AI documents glm-5.2[1m] as the model name that enables the 1M-context variant.
Actual
The request fails with:
{"error":{"message":"Provider error 400: {"error":{"code":"1211","message":"Unknown Model, please check the model code.\n"}}","type":"upstream_error","code":null}}
For comparison, glm-5.2 (without the [1m] suffix) routes successfully
through the same provider config.
Likely cause
1211 / "Unknown Model, please check the model code." is Z.AI's response
when the model field does not match a known model code. It appears opencodex
forwards the model string glm-5.2[1m] verbatim as the model value to the
upstream OpenAI-compatible chat-completions endpoint, which does not accept
the bracketed [1m] suffix — Z.AI only recognizes the bare code (glm-5.2) on
that path.
The [1m] suffix is a Z.AI convention documented specifically for the Anthropic-compatible (Claude Code) endpoint, where it is set via ANTHROPIC_DEFAULT_SONNET_MODEL=glm-5.2[1m]. It does not seem to be valid as a
chat-completions model value, so passing it straight through the openai-chat
adapter breaks.
Questions / suggestions
Should opencodex strip or translate the [1m] (and similar bracketed)
suffix before forwarding to the openai-chat adapter, while still enabling
the 1M context another way (e.g. an explicit context/param)?
Or should the GLM-5.2 1M variant be documented as only reachable through the anthropic adapter pointed at Z.AI's Anthropic-compatible endpoint?
What is the currently recommended opencodex config to use the GLM-5.2 1M
variant?
Happy to provide a redacted config.json or proxy request log if useful.
Root cause: opencodex forwards the model id verbatim as the chat-completions model value. glm-5.2[1m] was sent unchanged to Z.AI's OpenAI-compatible endpoint, which rejects the bracketed id (400, code 1211). The [1m] suffix is a Claude-Code / Anthropic-endpoint-only convention, not a valid OpenAI-compatible model value.
Fix (Option A): the openai-chat adapter now strips a trailing [...] suffix from the wire model value (stripBracketedModelSuffix), so glm-5.2[1m] resolves to glm-5.2. The strip is confined to the openai-chat path — the anthropic adapter keeps the suffix verbatim, since [1m] is valid there (Z.AI Anthropic coding endpoint). The 1M context window comes from the model catalog (modelContextWindows), not the model name.
Added unit tests (openai-chat strip + anthropic no-op) and a README note documenting both paths.
This will be closed once the change is merged to main.
Fixed by 0b8d95c (fix(openai-chat): strip bracketed [1m] suffix from wire model id), now in dev/main/preview (released). The openai-chat adapter strips a trailing bracketed group (e.g. [1m]) from the wire model id via stripBracketedModelSuffix (src/adapters/openai-chat.ts:13,175), so glm-5.2[1m] is sent to Z.AI as bare glm-5.2 while the anthropic adapter keeps the suffix verbatim. Regression test: tests/openai-chat-model-suffix.test.ts. Closing as resolved.
Activity
lidge-jun commentedon Jun 29, 2026
Fixed on the
feat/kiro-on-devbranch.Root cause: opencodex forwards the model id verbatim as the chat-completions
modelvalue.glm-5.2[1m]was sent unchanged to Z.AI's OpenAI-compatible endpoint, which rejects the bracketed id (400, code 1211). The[1m]suffix is a Claude-Code / Anthropic-endpoint-only convention, not a valid OpenAI-compatiblemodelvalue.Fix (Option A): the
openai-chatadapter now strips a trailing[...]suffix from the wiremodelvalue (stripBracketedModelSuffix), soglm-5.2[1m]resolves toglm-5.2. The strip is confined to theopenai-chatpath — theanthropicadapter keeps the suffix verbatim, since[1m]is valid there (Z.AI Anthropic coding endpoint). The 1M context window comes from the model catalog (modelContextWindows), not the model name.Added unit tests (openai-chat strip + anthropic no-op) and a README note documenting both paths.
This will be closed once the change is merged to
main.docs(devlog): review open PRs and issues (#17,#41-45)
fix(openai-chat): strip bracketed [1m] suffix from wire model id
docs(openai-chat): note GLM-5.2 1M [1m] suffix handling for issue #41
lidge-jun commentedon Jun 29, 2026
Fixed by 0b8d95c (fix(openai-chat): strip bracketed [1m] suffix from wire model id), now in dev/main/preview (released). The openai-chat adapter strips a trailing bracketed group (e.g.
[1m]) from the wire model id via stripBracketedModelSuffix (src/adapters/openai-chat.ts:13,175), soglm-5.2[1m]is sent to Z.AI as bareglm-5.2while the anthropic adapter keeps the suffix verbatim. Regression test: tests/openai-chat-model-suffix.test.ts. Closing as resolved.docs(devlog): review open PRs and issues (lidge-jun#17,lidge-jun#41-45)
fix(openai-chat): strip bracketed [1m] suffix from wire model id
docs(openai-chat): note GLM-5.2 1M [1m] suffix handling for issue lid…