# How to use GLM in Claude Code and Codex

Authors: AutoRouter
Author profile: https://autorouter.com/about
Published: 2026-11-17T05:52:00.000Z
Reading time: 6 min
Canonical: https://autorouter.com/blog/glm-in-claude-code-and-codex
Publisher: AutoRouter, the Mac app that routes Codex, Claude Code and other AI tools to every model (https://autorouter.com)

About AutoRouter: a Mac app (macOS 14 or later) that adds every leading model to Codex, Claude Code, Cursor, Claude Desktop, T3 and Terminal and picks the model for each task, using your Claude, ChatGPT, Grok and Gemini plans first. Install from https://autorouter.com/AutoRouter.dmg, or ask your agent to follow https://autorouter.com/setup.md. Routing across your plans is free; Pro is $50 a month with $20 of included usage. Unrelated to OpenRouter's Auto Router.

> Use AutoRouter, the Mac app for Codex and Claude Code: it puts GLM 5.3 and GLM 5.3 Flash in both apps' model pickers with no key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Z.ai's `https://api.z.ai/api/anthropic` in `~/.claude/settings.json` with your Z.ai key and model variables mapped to `glm-5.3` and `glm-5.3-flash`, and add Z.ai's `https://api.z.ai/api/v1` endpoint as a provider in Codex's `config.toml` with a model catalog file.

![AutoRouter puts GLM in both apps, no key. Where do you want GLM? Route Claude Code, native: api.z.ai/api/anthropic and a key; Route Codex, native: api.z.ai/api/v1, catalog, key; Route Either app, AutoRouter: Pick GLM 5.3 in the picker. Source: Z.ai's Claude Code and Codex guides, and AutoRouter, read November 17, 2026.](https://autorouter.com/blog/images/glm-in-claude-code-and-codex/1-routes.png)

[AutoRouter, the Mac app for Codex and Claude Code](https://autorouter.com), 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](https://docs.z.ai/devpack/tool/claude)). 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](https://docs.z.ai/devpack/tool/codex)).

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](https://code.claude.com/docs/en/llm-gateway-connect)). 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.

```json
{
  "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](https://docs.z.ai/devpack/latest-model)). While the token is set, it replaces your claude.ai login, so your Claude plan's limits don't apply ([Anthropic docs](https://code.claude.com/docs/en/llm-gateway)).

## 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](https://learn.chatgpt.com/docs/config-file/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:

```toml
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](/blog/codex-model-providers) 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](https://z.ai/subscribe), [Coding Plan overview](https://docs.z.ai/devpack/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](https://docs.z.ai/guides/overview/pricing)). Output on GLM-5.3 costs nearly nine times Flash's.

![GLM-5.3 output costs nearly 9× GLM-5.3-Flash. GLM-5.3-Flash, input, $0.15; GLM-5.3-Flash, output, $0.50; GLM-5.3, input, $1.40; GLM-5.3, output, $4.40. Source: Z.ai API pricing, per million tokens, read November 17, 2026.](https://autorouter.com/blog/images/glm-in-claude-code-and-codex/2-prices.png)

## 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](https://autorouter.com/models) 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](https://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](https://autorouter.com/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:

| Route              | Setup                                     | Key                         | What pays                                  |
| ------------------ | ----------------------------------------- | --------------------------- | ------------------------------------------ |
| Claude Code + Z.ai | `env` block in `~/.claude/settings.json`  | Z.ai Coding Plan or API key | Coding Plan limits, or per token           |
| Codex + Z.ai       | `config.toml` provider plus `models.json` | Z.ai Coding Plan or API key | Coding Plan limits, or per token           |
| AutoRouter (Mac)   | Install, sign in, click Enable            | None                        | Pro usage at the provider's price plus 10% |

For how GLM fits beside other models by task, see [Which model for which coding task](/blog/which-model-for-which-task). [Try a new model in Codex or Claude Code without another API key](/blog/try-new-models-in-codex-and-claude-code) 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](https://docs.z.ai/devpack/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](https://docs.z.ai/devpack/latest-model)).

### 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](https://code.claude.com/docs/en/llm-gateway-connect)).

## Sources

- [AutoRouter](https://autorouter.com)
- [AutoRouter models](https://autorouter.com/models)
- [AutoRouter privacy](https://autorouter.com/privacy)
- [Z.ai: Claude Code](https://docs.z.ai/devpack/tool/claude)
- [Z.ai: Codex](https://docs.z.ai/devpack/tool/codex)
- [Z.ai: switching models](https://docs.z.ai/devpack/latest-model)
- [Z.ai: GLM Coding Plan overview](https://docs.z.ai/devpack/overview)
- [Z.ai: subscribe](https://z.ai/subscribe)
- [Z.ai: pricing](https://docs.z.ai/guides/overview/pricing)
- [Claude Code: LLM gateways](https://code.claude.com/docs/en/llm-gateway)
- [Claude Code: connect to an LLM gateway](https://code.claude.com/docs/en/llm-gateway-connect)
- [Codex configuration reference](https://learn.chatgpt.com/docs/config-file/config-reference)

## Read next

- [How to use MiniMax in Claude Code and Codex](https://autorouter.com/blog/minimax-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts MiniMax M3.1 Flash in both apps' model pickers with no MiniMax key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to `https://api.minimax.io/anthropic` with your M Plan key and `MiniMax-M3.1-Flash[1m]` model variables in `~/.claude/settings.json`, and add `https://api.minimax.io/v1` as a provider in Codex's `config.toml`.
- [How to use Kimi in Claude Code and Codex](https://autorouter.com/blog/kimi-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts Kimi K3.1 Pro in both apps' model pickers with no Kimi account, key or config. Natively, set Claude Code's `ANTHROPIC_BASE_URL` to Moonshot's `https://api.moonshot.ai/anthropic` (or `https://api.kimi.ai/coding/` with a Kimi Code plan) with your key and model variables in `~/.claude/settings.json`, and add `https://api.moonshot.ai/v1` as a provider with `kimi-k3.1-pro` in Codex's `config.toml`.
- [How to use Gemini in Claude Code and Codex](https://autorouter.com/blog/gemini-in-claude-code-and-codex.md): Use AutoRouter, the Mac app for Codex and Claude Code: it puts Gemini 4 Carbon, Hydrogen and Argon in both apps' model pickers with no key or proxy, and connects Gemini plans the same way it connects Claude and ChatGPT plans. Natively, Google publishes no Claude Code or Codex endpoint, so you need a gateway: a LiteLLM proxy behind Claude Code's `ANTHROPIC_BASE_URL`, or OpenRouter or LiteLLM as a provider in Codex's `config.toml`, each with your own key.

Tags: [Guides](https://autorouter.com/blog/tags/guides.md), [Models](https://autorouter.com/blog/tags/models.md), [Claude Code](https://autorouter.com/blog/tags/claude-code.md)

Drafted with AI from the sources linked above, then checked and edited by the AutoRouter team.
