Beta
Discord Download

How to use GLM in Claude Code and Codex

AutoRouter6 min read

AutoRouter, the Mac app for Codex and Claude Code, puts GLM 5.3 and GLM 5.3 Flash in both apps' model pickers with no key or config, next to the ChatGPT and Claude plans you already pay for. The native route takes a Z.ai key and config in each app. To use GLM in Claude Code, add Z.ai's endpoint, https://api.z.ai/api/anthropic, and your Z.ai API key to the env block of ~/.claude/settings.json, and map Claude Code's model variables to glm-5.3 and glm-5.3-flash (Z.ai's Claude Code guide). In Codex, add https://api.z.ai/api/v1 as a provider in ~/.codex/config.toml, with a models.json catalog that describes GLM-5.3 (Z.ai's Codex guide).

AutoRouter wrote this post. The Z.ai routes below bill to your Z.ai plan or balance with nothing in between. Every setting is copied from Z.ai's, Anthropic's or OpenAI's docs as checked on November 17, 2026; check the linked page before you paste.

How do you use GLM in Claude Code?

Point Claude Code at Z.ai's Anthropic-compatible endpoint and map every model tier to a GLM model. Claude Code sends ANTHROPIC_AUTH_TOKEN as a bearer token to the address in ANTHROPIC_BASE_URL (Anthropic docs). Z.ai offers a helper (npx @z_ai/coding-helper) and a setup script for macOS and Linux, or you can write the settings yourself:

  1. Copy your API key from Personal Coding Plan, then Plan Overview, in your Z.ai account.
  2. Add the block below to ~/.claude/settings.json, replacing your_zai_api_key.
  3. Open a new terminal window and start claude in your project.
  4. Run /status to confirm the base URL and model. If Claude Code says a model doesn't exist, update Claude Code.
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash[1m]",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.3[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.3[1m]",
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
    "CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC": 1,
    "DISABLE_TELEMETRY": "1",
    "CLAUDE_CODE_SIMPLE_SYSTEM_PROMPT": "0",
    "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000",
    "API_TIMEOUT_MS": "3000000"
  }
}

The [1m] suffix asks for the 1M-token context window. Z.ai's model page says /effort switches GLM's thinking, which defaults to max, and that GLM-5.3 reads text only while GLM-5.3-Flash also reads images (Z.ai model switching). While the token is set, it replaces your claude.ai login, so your Claude plan's limits don't apply (Anthropic docs).

How do you use GLM in Codex?

Add Z.ai as a custom provider in ~/.codex/config.toml, at the separate address Z.ai runs for Codex. Codex only speaks OpenAI's Responses API (OpenAI config reference), and Z.ai's Codex guide says https://api.z.ai/api/v1 is its dedicated Responses endpoint. The guide also has you create ~/.codex/models.json, a catalog that declares glm-5.3 with its 1,048,576-token context and reasoning levels; copy it from the guide, then add:

model_provider = "ZAI"
model = "glm-5.3"
model_reasoning_effort = "max"
model_catalog_json = "~/.codex/models.json"

[model_providers.ZAI]
name = "ZAI"
base_url = "https://api.z.ai/api/v1"
experimental_bearer_token = "<Your API Key>"
wire_api = "responses"

Restart Codex so it reads the file. OpenAI's reference calls experimental_bearer_token discouraged and suggests env_key, which keeps the key in an environment variable instead of the file. Z.ai notes that Individual Plan, Team Plan and standard API keys have been separate since October 16, 2026, and don't work in each other's place. Codex model providers and config.toml, explained covers the other provider keys.

Should you pay for GLM with the Coding Plan or the API?

Z.ai sells GLM two ways: the GLM Coding Plan, a subscription with usage limits per five hours and per week, and the pay-per-token API. The Coding Plan covers GLM-5.3 and GLM-5.3-Flash in Claude Code, Codex and other agent tools, and comes in Lite, Pro (6× Lite's usage) and Max (14× Lite's usage) tiers. Lite lists at $18 a month, and Z.ai shows a 30% discount for yearly billing, as of November 17, 2026 (Z.ai subscribe, Coding Plan overview).

On the API, GLM-5.3 costs $1.40 per million input tokens, $0.26 per million cached input tokens and $4.40 per million output tokens; GLM-5.3-Flash costs $0.15, $0.03 and $0.50 (Z.ai pricing). Output on GLM-5.3 costs nearly nine times Flash's.

How do you use GLM with AutoRouter?

Pick it in the model picker. AutoRouter adds 20+ frontier and open-weight models to Codex and Claude Code with no keys or endpoints to set up, including GLM 5.3 and GLM 5.3 Flash on AutoRouter's models page as of November 17, 2026. Choosing a GLM model sends your requests straight to it. Choosing AutoRouter lets it work out how hard each task is and send each one to the model that fits, with your plans first for hard work.

  1. Download AutoRouter for macOS from autorouter.com.
  2. Open it, sign in or create a free account, sign in to your plans, allow Accessibility, and click Enable for each app.
  3. Start a new session and choose a model: in Codex, from the model menu under the message box; in Claude Code, with /model.

AutoRouter pools the plans you already pay for. Connect Claude, ChatGPT, Grok and Gemini plans, use any of them in either app (your Claude plan inside Codex, your ChatGPT plan inside Claude Code), and when one account reaches its limit, AutoRouter moves on to the account with the most room left before it spends any credit. GLM is a pay-per-use model on Pro, at $50 a month with $20 of included usage each month, billed at the provider's price plus 10%. New accounts get Pro free for their first month, or until $20 of usage is spent, whichever comes first.

To be fair to the direct route: if you only want GLM and use it heavily, Z.ai's Coding Plan is built for that. AutoRouter connects Claude, ChatGPT, Grok and Gemini plans, and GLM through AutoRouter bills per use on Pro. AutoRouter runs on macOS 14 or later, and Claude Code needs Node 22.18 or later to use it. Requests pass through AutoRouter's servers; it doesn't store transcripts, but keeps the message that opens each request, up to 4,000 characters, to review routing (AutoRouter privacy).

Which GLM setup should you use?

Use Z.ai's Coding Plan if GLM is your main model, the Z.ai API for occasional use, and AutoRouter for GLM beside your other plans in both apps. As of November 17, 2026:

RouteSetupKeyWhat pays
Claude Code + Z.aienv block in ~/.claude/settings.jsonZ.ai Coding Plan or API keyCoding Plan limits, or per token
Codex + Z.aiconfig.toml provider plus models.jsonZ.ai Coding Plan or API keyCoding Plan limits, or per token
AutoRouter (Mac)Install, sign in, click EnableNonePro usage at the provider's price plus 10%

For how GLM fits beside other models by task, see Which model for which coding task. Try a new model in Codex or Claude Code without another API key covers other providers.

Questions

Does a Z.ai API key work with the Coding Plan endpoint?

No. Z.ai says Individual Plan, Team Plan and standard API keys have been separate since October 16, 2026 and aren't interchangeable. Use the key from Plan Overview for the Coding Plan, and an API key for pay-per-token use.

Can GLM-5.3 read screenshots in Claude Code?

No. Z.ai lists GLM-5.3 as text-only and GLM-5.3-Flash as multimodal. The Coding Plan also includes a vision MCP server for image understanding (Coding Plan overview).

How do I turn GLM's thinking down in Claude Code?

Use /effort. Z.ai's guide says thinking defaults to max, and turning it off maps to low; it changes the effort level, not the model (Z.ai model switching).

How do I switch Claude Code back to Claude?

Delete the keys you added to the env block in ~/.claude/settings.json and open a new terminal. With no gateway credential set, Claude Code goes back to your claude.ai login (Anthropic docs).

Sources