Use GLM in Claude Code

Run Claude Code on Z.ai's GLM 5.3, with GLM 5.3 Flash for small jobs, using four settings and a /model key. No router needed.

Checked November 28, 2026

GLM models answer in Anthropic's Messages format, the one Claude Code speaks, so Claude Code runs them straight from /model, with no program in between. We ran these steps with Claude Code 2.1.332 against /model, on 28 Nov 2026.

Before you start

Set it up

For one terminal session, set four variables and start Claude Code:

bash
export ANTHROPIC_BASE_URL="https://api.slashmodel.com"
export ANTHROPIC_AUTH_TOKEN="$SLASHMODEL_API_KEY"
export ANTHROPIC_MODEL="glm-5.3"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="glm-5.3-flash"
claude
  • ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN point Claude Code at /model, as in the Claude Code guide. The base URL has no /v1.
  • ANTHROPIC_MODEL is the model Claude Code runs on.
  • ANTHROPIC_DEFAULT_HAIKU_MODEL is the model behind Claude Code's haiku name, which Claude Code also uses for small jobs in the background. Here it is GLM 5.3 Flash, which costs less.

To keep them, put them in Claude Code's settings file, ~/.claude/settings.json, with your key:

settings.json
{
  "env": {
    "ANTHROPIC_BASE_URL": "https://api.slashmodel.com",
    "ANTHROPIC_AUTH_TOKEN": "sk-sm-…",
    "ANTHROPIC_MODEL": "glm-5.3",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-5.3-flash"
  }
}

Every session then starts on that model. Keep the key out of a project's .claude/settings.json if the project is shared: that file is usually committed.

Pick a model

  • GLM 5.3, glm-5.3: the main model in the settings above. It takes text only.
  • GLM 5.3 Flash, glm-5.3-flash: the haiku model above. It costs less than GLM 5.3, and reads images as well as text.
  • GLM 5.3 FlashX, glm-5.3-flashx: costs more than Flash and less than GLM 5.3, and reads images too. To make it the haiku model, set ANTHROPIC_DEFAULT_HAIKU_MODEL to glm-5.3-flashx.

Each model's price is on the pricing page. To start a session on the haiku model:

bash
claude --model haiku

Good to know

  • GLM 5.3 is a preview here: at busy times it can be slow or briefly unavailable.
  • Little of the prompt was read from the cache. Claude Code sends its long instructions again with every request, and in our runs only about 5 to 10% of the prompt tokens came from the cache. Most of each request is billed at the input price.
  • Claude Code warns that it doesn't recognise the model's name, then goes on: in our runs it wrote a file and ran it, as it does on Claude.
  • Claude Code's other names, such as sonnet, still mean Claude models. claude --model sonnet starts a session on Claude Sonnet 5.5: see the /model command.
  • A key can cap what a session costs. Give Claude Code a key of its own with a daily or monthly limit: see key settings.
  • Every request shows under Usage with its model, its tokens and its cost.

One key for every model here.

Top up from $10, change one URL, and pay only for the tokens you use.