← All guides

How to use GLM in Claude Code

Zhipu's GLM models (the GLM-4.7 and newer GLM-5.2 line) have become a strong cheap-but-capable pick for agent coding, and Claude Code can run on them directly. Here's how to connect GLM, what to check, and a cleaner path when you want to switch models freely.

TL;DR: Zhipu exposes an Anthropic-compatible endpoint for GLM, so you can run Claude Code on it: set ANTHROPIC_BASE_URL to https://open.bigmodel.cn/api/anthropic and ANTHROPIC_AUTH_TOKEN to your Zhipu key, then pick a GLM model such as glm-4.7 or glm-5.2. It's a strong value pick for everyday coding, but it's a global endpoint swap — switching back to Claude means editing env vars and restarting. An agent that treats the model as a setting avoids that.

GLM + Claude Code: the short version

GLM is served by Zhipu (BigModel), which publishes an Anthropic-compatible endpoint precisely so Claude Code and similar tools can point at it directly. You supply your own Zhipu key, usage is billed to you, and there's no translating proxy required — Claude Code talks to GLM as if it were an Anthropic endpoint. The newer GLM-5.2 line even offers a very large (1M) context variant for big codebases.

The config

What to set

  1. ANTHROPIC_BASE_URLPoint it at Zhipu's Anthropic-compatible base: https://open.bigmodel.cn/api/anthropic
  2. ANTHROPIC_AUTH_TOKENYour Zhipu (BigModel) API key — usage billed to your Zhipu account.
  3. ModelSelect a GLM model (e.g. glm-4.7 for light work, glm-5.2 or glm-5.2[1m] for the large-context variant). Use the exact name the endpoint exposes.
# Point Claude Code at Zhipu/GLM's Anthropic-compatible endpoint
export ANTHROPIC_BASE_URL="https://open.bigmodel.cn/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-zhipu-key"
# then run claude as usual, selecting a GLM model (e.g. glm-5.2)
Reality check: this is a global switch. There's no in-app 'GLM for this, Claude for that' — you change env vars and restart to move between them. If Claude Code stalls on the onboarding screen the first time, add "hasCompletedOnboarding": true to ~/.claude.json, and set a long API_TIMEOUT_MS for big tasks.

Why route Claude Code to GLM

Value

GLM's 4.7 and 5.2 lines are a strong capability-per-dollar pick for everyday agent coding.

Long context

The GLM-5.2 1M-context variant handles bigger repositories in one session.

Fallback for Claude limits

Somewhere to route when your Claude plan is rate-limited or capped.

The cleaner option: GLM as a one-click setting

The endpoint swap works, but Claude Code is single-provider by design, so mixing GLM and Claude means reconfiguring each time. If you want to run GLM most of the time and jump to Claude (or a local model) on demand, use an agent where the provider, base URL, key and model are settings you pick from a list.

What that looks like with Wuwei

GLM in the model list

Pick it in the UI; Claude, Kimi, DeepSeek, Qwen and OpenAI-compatible endpoints sit alongside.

One-click switch

Move between GLM and Claude mid-task without editing config or restarting.

Free, open source, local

MIT-licensed, runs on your machine, reads your real files; you only pay Zhipu's usage.

FAQ

Can Claude Code use GLM?

Yes. Zhipu exposes an Anthropic-compatible endpoint for GLM. Set ANTHROPIC_BASE_URL to https://open.bigmodel.cn/api/anthropic and ANTHROPIC_AUTH_TOKEN to your Zhipu key, then select a GLM model such as glm-4.7 or glm-5.2 — no proxy needed.

What is GLM-5.2 and is it good for coding?

GLM-5.2 is Zhipu's newer flagship line, a popular value pick for agent coding with strong capability per dollar and a large-context (1M) variant that helps on bigger repos.

How do I switch between GLM and Claude easily?

Use an agent where the model is a setting. Wuwei is free and open source — GLM and Claude are both in the model list, so switching is one click rather than an env-var edit and restart.

If you want agent coding on GLM's cheap, long-context models — with Claude a click away when you need it — Wuwei is a free, open-source agent that puts both in one model list. Bring your Zhipu key, pick GLM, and run locally on your real files.

Learn more

Windows · macOS · Linux — free, no login