How do I use Claude Code with GLM
On this page
  1. What do I need before I start?
  2. How do I point Claude Code at GLM?
  3. How do I keep my normal Claude sign-in as well?
  4. How do I use Claude and GLM together on one project?
  5. Where does Joxo help?
  6. Frequently asked questions
  7. Does Claude Code officially support GLM?
  8. Will using GLM count against my Claude plan?
  9. Can I switch between Claude and GLM without editing settings every time?
  10. Which GLM model should I use?
  11. Can a teammate on GLM work on the same project as a teammate on Claude?
  12. Try it with your team

Guides

How do I use Claude Code with GLM?

Point Claude Code at Z.ai's Anthropic-compatible endpoint to run GLM models, keep your Claude sign-in for other sessions, and use both on one project.

To use Claude Code with GLM, create an API key on the Z.ai Open Platform and start Claude Code with ANTHROPIC_BASE_URL set to https://api.z.ai/api/anthropic and ANTHROPIC_AUTH_TOKEN set to that key. Claude Code then sends its requests to Z.ai, and the GLM model answers. To use Claude and GLM together, run one session on your Claude sign-in and another on the GLM settings, so the two never share a configuration by accident.

What do I need before I start?#

  • Claude Code installed. Z.ai's guide uses npm install -g @anthropic-ai/claude-code, and Anthropic's own installer works too.
  • A Z.ai account with an API key from the API Keys page of the Z.ai Open Platform, or a GLM Coding Plan.
  • About ten minutes.

GLM bills you through Z.ai. While Claude Code points at Z.ai, the work counts against your Z.ai plan or key and not against your Claude plan. Some Claude Code features may work differently, because the other end is not Anthropic.

How do I point Claude Code at GLM?#

Z.ai documents three ways: a helper tool, a setup script and manual settings. The quickest is the helper:

bash
npx @z_ai/coding-helper

The manual way is to add an env block to ~/.claude/settings.json:

json
{
  "env": {
    "ANTHROPIC_AUTH_TOKEN": "your_zai_api_key",
    "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
    "API_TIMEOUT_MS": "3000000"
  }
}

Open a new terminal, cd into your project and run claude. The long timeout comes straight from Z.ai's guide.

Claude Code picks a model by tier: Opus, Sonnet and Haiku. To choose which GLM model answers each tier, set the three model variables. Z.ai's guide maps all three to its current GLM-5.3 family. Model names change between releases, so copy the exact ids from Z.ai's Claude Code page on the day you set it up:

json
{
  "env": {
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "<model id from Z.ai's guide>",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "<model id from Z.ai's guide>",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "<model id from Z.ai's guide>"
  }
}

If you have set Claude Code variables before, for this or another provider, Z.ai's guide says to edit them by hand.

How do I keep my normal Claude sign-in as well?#

Writing the variables into ~/.claude/settings.json changes every Claude Code session on that computer. If you also use Claude on a Pro or Max plan, that is rarely what you want. Claude Code reads ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN from the environment of the process that starts it (Claude Code's environment variables), so you can scope GLM to one command instead.

A shell alias, in ~/.zshrc or ~/.bashrc:

bash
export ZAI_API_KEY="your_zai_api_key"
alias claude-glm='ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic \
  ANTHROPIC_AUTH_TOKEN=$ZAI_API_KEY API_TIMEOUT_MS=3000000 claude'

Now claude starts on your Claude sign-in and claude-glm starts on GLM. Nothing in your global settings changes.

Another option is per project: put the env block in that project's .claude/settings.local.json, which Claude Code reads only in that folder and which is meant to stay out of Git. Never commit a key into .claude/settings.json in a shared repository.

To check which one you are on, ask the session what model it is running, or watch the bill: requests to GLM show up in your Z.ai console.

How do I use Claude and GLM together on one project?#

Treat them as two teammates with different strengths. Some patterns that work:

PatternClaude sessionGLM session
Split by task sizeDesign, tricky bugs, reviewBulk edits, test writing, migrations
Plan, build, reviewWrites the planBuilds it on a branch, then Claude reviews the diff
Second opinionProposes a fixReviews it cold, with no memory of the reasoning

Run them in separate Git worktrees so they never edit the same checkout:

bash
git worktree add ../app-glm -b glm/bulk-rename
cd ../app-glm && claude-glm

Keep the shared rules in one AGENTS.md, imported from CLAUDE.md with a line that reads @AGENTS.md, so both sessions follow the same conventions. When work moves from one to the other, commit first and write a short handoff note with the branch, the commit and the next step. Handing work between two agents shows the note format.

Where does Joxo help?#

The steps above are enough for one person at one desk. A team adds a problem: the teammate on GLM and the teammate on Claude cannot see each other's tasks or decisions unless someone copies them across.

Joxo gives the team one shared project. Each person pastes one line into their own agent:

Read https://joxo.ai/skill.md and follow it to set up Joxo in this project.

Then both agents share a task board, where only one agent can hold a task, decisions that reach every teammate's agent, and handoffs that carry the branch, the commit and a note into the next agent's turn. Claude Code joins the same way whichever model it is pointed at, and OpenCode with GLM models joins too. Each person keeps their own plan or key, and Joxo never asks for it. The privacy page says what Joxo receives.

For Kimi, DeepSeek, MiniMax and Qwen, using Chinese AI models with Claude Code has the endpoints side by side.

Frequently asked questions#

Does Claude Code officially support GLM?#

Claude Code lets you set a custom API endpoint with ANTHROPIC_BASE_URL, and Z.ai publishes an endpoint that speaks the same format. The setup guide comes from Z.ai, not Anthropic. If something breaks, check Z.ai's documentation first.

Will using GLM count against my Claude plan?#

No. While Claude Code points at Z.ai, requests go to Z.ai and are billed to your Z.ai plan or API key. Your Claude plan is used only by sessions that run on your Claude sign-in.

Can I switch between Claude and GLM without editing settings every time?#

Yes. Keep your global settings on Claude and start GLM sessions through a shell alias that sets the two variables for that one command, or through a project's local settings file. The alias in this guide does exactly that.

Which GLM model should I use?#

Use the model ids Z.ai's Claude Code guide lists on the day you set up. Its default maps all three Claude Code tiers to the GLM-5.3 family, and the names change between releases.

Can a teammate on GLM work on the same project as a teammate on Claude?#

Yes. Each runs their own agent on their own computer and plan. With a shared project such as Joxo, both agents see one task board and the same decisions, so the model behind each one does not matter to the rest of the team.