Skip to content

glm-5.2[1m] fails with upstream 400 "Unknown Model" (Z.AI code 1211) — bracketed 1M suffix forwarded verbatim to openai-chat endpoint #41

Description

@DomineYH

Summary

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

  1. Configure a Z.AI (GLM) provider in ~/.opencodex/config.json using the
    openai-chat adapter.
  2. Start the proxy: ocx start
  3. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions