# How to use GLM and the GLM Coding Plan in Claude Code and Codex

> Use Auto, the Mac app for all your coding agents: it puts GLM 5.3 and GLM 5.3 Flash in the model picker of each one (Claude Code, Codex, Cursor, etc.) beside your Claude plan, with no Z.ai key or base URL to swap. Natively, Z.ai's GLM Coding Plan (Lite $18, Pro $80 or Max $168 a month, as of November 18, 2026) runs in Claude Code once you set `ANTHROPIC_BASE_URL` to `https://api.z.ai/api/anthropic` and `ANTHROPIC_AUTH_TOKEN` to your plan key in `~/.claude/settings.json`, and in Codex through Z.ai's `https://api.z.ai/api/v1` provider in `config.toml`.

Author: Tyler J. Cagle (https://x.com/tjcages)
Published: 2026-11-17T05:52:00.000Z
Updated: 2026-11-18T22:30:00.000Z
Reading time: 9 min
Canonical: https://auto.sh/blog/glm-in-claude-code-and-codex
Part of: How to choose and change models in Codex and Claude Code (https://auto.sh/blog/models-in-codex-and-claude-code.md)
Publisher: Auto (https://auto.sh)

![Auto 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, Auto: Pick GLM 5.3 in the picker. Source: Z.ai's Claude Code and Codex guides, and Auto, read November 17, 2026.](https://auto.sh/blog/images/glm-in-claude-code-and-codex/1-routes.png)

[Auto, the Mac app for all your coding agents](https://autorouter.com/), puts GLM 5.3 and GLM 5.3 Flash in each one's model picker (Claude Code, Codex, Cursor, etc.) with no key or config, next to the AI subscriptions you already pay for. You keep Claude for hard work and pick GLM with `/model` when you want it, or choose Auto and let it send each task to the model that fits; every request shows its model and what it cost. The native route is Z.ai's GLM Coding Plan, a subscription from $18 a month as of November 18, 2026 ([Z.ai subscribe](https://z.ai/subscribe)). To use it in Claude Code, add Z.ai's endpoint, `https://api.z.ai/api/anthropic`, and your plan's 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)).

Auto wrote this post. The Z.ai routes below bill to your Z.ai plan or balance with nothing in between. Every setting and price is copied from Z.ai's, Anthropic's or OpenAI's docs as checked on November 17 and 18, 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)). With all three model variables mapped to GLM and the token set, every Claude Code request goes to Z.ai: the token replaces your claude.ai login, so your Claude plan isn't used until you delete those keys and open a new terminal ([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.

## What is the GLM Coding Plan, and what does it cost?

The GLM Coding Plan is Z.ai's subscription for using GLM in coding agents such as Claude Code and Codex, sold in three tiers: Lite at $18 a month, Pro at $80 and Max at $168, as of November 18, 2026 ([Z.ai subscribe](https://z.ai/subscribe)). Quarterly billing takes 20% off ($14.40, $64 and $134.40 a month) and yearly billing 30% off ($12.60, $56 and $117.60 a month). Every tier covers GLM-5.3 and GLM-5.3-Flash, plus Z.ai's vision, web search, web reader and Zread MCP servers, and Z.ai routes requests for GLM-5.2, GLM-5.1 and GLM-4.7 to the current models ([Coding Plan overview](https://docs.z.ai/devpack/overview)).

| Tier | Monthly | Yearly, per month | Credits per 5 hours | Credits per week |
| ---- | ------- | ----------------- | ------------------- | ---------------- |
| Lite | $18     | $12.60            | 2,000               | 10,000           |
| Pro  | $80     | $56               | 12,000              | 60,000           |
| Max  | $168    | $117.60           | 28,000              | 140,000          |

Usage is counted in credits, with a five-hour limit and a weekly one. Five-hour credits come back five hours after you spend them, and weekly credits reset every seven days from the day you subscribe. A GLM-5.3 request costs its input tokens × 6.9, cached input × 1.7 and output × 24, divided by 10,000; GLM-5.3-Flash uses 2.3, 0.56 and 8. Outside peak hours (Monday to Friday, 14:00 to 18:00 Singapore time, which is 1:00 to 5:00 AM Eastern Standard Time) requests cost half the credits ([Coding Plan overview](https://docs.z.ai/devpack/overview)).

The plan renews on its own, and Z.ai doesn't refund a plan once bought, even unused; cancel at least three days before the renewal date to stop the next charge ([Z.ai usage policy](https://docs.z.ai/devpack/usage-policy)). Z.ai also sells a Team plan with its own limits.

## Is the GLM Coding Plan worth it over the Z.ai API?

Yes, if you use GLM heavily: a used-up Lite plan covers GLM-5.3 work that would cost about $72 to $145 a month on Z.ai's API. Take an example agent request with 60,000 input tokens, 95% of them cached, and 1,500 output tokens. On the plan it costs 15.36 credits at peak and 7.68 off-peak, so Lite's 10,000 weekly credits cover about 651 such requests at peak, or 1,302 off-peak. On the API, the same request costs $0.0256 (3,000 fresh input tokens at $1.40 per million, 57,000 cached at $0.26 and 1,500 output at $4.40), so 651 requests a week come to $16.68, about $72 a month, and 1,302 to about $145.

![Lite's credits would cost $72 to $145 on the API. Lite plan, a month, $18; API cost, peak use, $72; API cost, off-peak use, $145. Source: Z.ai Coding Plan credits and API prices, checked November 18, 2026; example request of 60,000 input tokens, 95% cached, and 1,500 output on GLM-5.3, Lite's weekly credits used up.](https://auto.sh/blog/images/glm-in-claude-code-and-codex/3-coding-plan.png)

The API wins when you use GLM now and then: it bills only what you use, and 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://auto.sh/blog/images/glm-in-claude-code-and-codex/2-prices.png)

## How do you use GLM in Claude Code and keep Claude?

Use Auto: it puts GLM in Claude Code's `/model` picker beside the Claude models on your Claude plan, so you don't swap a base URL or token to move between them. Z.ai's setup sends every Claude Code request to GLM until you edit `settings.json` again. With Auto, Claude models run on your Claude plan, GLM 5.3 and GLM 5.3 Flash sit beside them ([Auto's models page](https://autorouter.com/models), November 18, 2026), and choosing a GLM model sends your requests straight to it. Choosing Auto instead lets it work out how hard each task is: hard work goes to the strongest model your plans cover, and quick work goes to the model that costs you least, which is often a low-cost open model. Each request shows its model, what it cost and why.

If Z.ai is already set in your Claude Code `env` block or shell profile, [the switch page](/switch/claude-code-env) reads what you paste and shows what Auto replaces, or gives your coding agent one prompt that moves you over.

1. Download Auto 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`.

Auto pools the AI subscriptions you already pay for. Connect your plans, use any of them in any of your coding agents (your Claude plan inside Codex, say), and when one account reaches its limit, Auto moves on to the account with the most room left before it spends any credit. GLM is a pay-per-use model on [Pro](/pricing), which includes usage each month, billed at the provider's price plus 10%. New accounts get a week of Pro, or until its included usage is spent, whichever comes first.

To be fair to the direct route: GLM is a capable, low-cost model, and if it is your main model and you use it all day, Z.ai's Coding Plan is built for that and the math above favors it. Auto doesn't connect a GLM Coding Plan; GLM through Auto bills per use on Pro. Auto runs on macOS 14 or later, and Claude Code needs Node 22.18 or later to use it. Requests pass through Auto's servers; it doesn't store transcripts, but keeps the message that opens each request, up to 4,000 characters, to review routing ([Auto privacy](https://autorouter.com/privacy)).

## Which GLM setup should you use?

Use Auto to run GLM beside the AI subscriptions you already pay for in all your coding agents, Z.ai's Coding Plan if GLM is your main model, and the Z.ai API for occasional use. As of November 18, 2026:

| Route                     | Setup                                     | Key             | What pays                                      |
| ------------------------- | ----------------------------------------- | --------------- | ---------------------------------------------- |
| Auto (Mac)                | Install, sign in, click Enable            | None            | Pro usage at the provider's price plus 10%     |
| Claude Code + Coding Plan | `env` block in `~/.claude/settings.json`  | Coding Plan key | $18, $80 or $168 a month, within credit limits |
| Codex + Coding Plan       | `config.toml` provider plus `models.json` | Coding Plan key | $18, $80 or $168 a month, within credit limits |
| Either app + Z.ai API     | Same settings as the plan                 | Z.ai API key    | Per token                                      |

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

### Can Auto use my GLM Coding Plan?

Not as a plan: Auto connects Claude, ChatGPT, Grok and Gemini plans, and GLM through Auto bills per use on Pro at the provider's price plus 10%. To use a GLM Coding Plan, set it up with Z.ai's own settings in each app.

### 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 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)). With Auto there is nothing to delete: pick a Claude model with `/model`.

### Which GLM Coding Plan tier should I pick?

Z.ai recommends Lite for one project at a time, Pro for one or two at once and Max for two or more, and Pro and Max get 6× and 14× Lite's usage ([Z.ai usage policy](https://docs.z.ai/devpack/usage-policy), [Z.ai subscribe](https://z.ai/subscribe)). Since Z.ai doesn't refund a plan once bought, try a month before you pay for a year.

## Sources

- [Auto](https://autorouter.com/)
- [Auto models](https://autorouter.com/models)
- [Auto 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: GLM Coding Plan usage policy](https://docs.z.ai/devpack/usage-policy)
- [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 choose and change models in Codex and Claude Code](https://auto.sh/blog/models-in-codex-and-claude-code.md): To give each task the right model, use Auto, the Mac app for all your coding agents: it adds models from every leading provider to the picker you already use (Claude Code, Codex, Cursor, etc.) and can pick one for each turn. To choose yourself, give hard, multi-file work a frontier model such as Claude Opus 5.5 or GPT-6.2 Astra and quick edits a fast one such as Claude Haiku 5.5 or GPT-6 Luna. Switch with /model in either app, a launch flag for one session, or a settings file for every session.
- [How to use MiniMax in Claude Code and Codex](https://auto.sh/blog/minimax-in-claude-code-and-codex.md): Use Auto, the Mac app for all your coding agents: it puts MiniMax M3.1 Flash in each one's model picker (Claude Code, Codex, Cursor, etc.) 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://auto.sh/blog/kimi-in-claude-code-and-codex.md): Use Auto, the Mac app for all your coding agents: it puts Kimi K3.1 Pro in each one's model picker (Claude Code, Codex, Cursor, etc.) 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`.

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

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

Auto is a Mac app for AI model routing in Codex, Claude Code, Cursor and other supported coding agents. It uses eligible connected subscriptions first. See [setup](https://auto.sh/setup.md) and [pricing](https://auto.sh/pricing).
