Skip to main content
Watch: I Built an AI App Without Leaving Databricks

Setup guide - Documented by GLM

Use GLM in Claude Code

Z.ai documents pointing Claude Code at its Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) by setting env vars in ~/.claude/settings.json, and mapping Claude Code's Opus/Sonnet/Haiku slots to GLM-5.3 and GLM-5.3-Flash with a [1m] suffix for 1M context.

Last verified 6 steps4 official sources

Steps

  1. Step 1.

    Install Claude Code (Z.ai's documented install command).

    Terminal
    # Install Claude Code
    npm install -g @anthropic-ai/claude-code
    
    # Navigate to your project
    cd your-awesome-project
    
    # Complete
    claude
  2. Step 2.

    Get a GLM Coding Plan API key. Individual Plan users create it under Personal Coding Plan > Plan Overview (https://z.ai/manage-apikey/apikey-list). Team Plan members create it under Team Coding Plan > My Plan (https://z.ai/manage-apikey/coding-plan/team/my-plan).

  3. Step 3.

    Option A (automated): run Z.ai's Coding Tool Helper and follow the on-screen guidance.

    Terminal
    npx @z_ai/coding-helper
  4. Step 4.

    Option B (manual): edit ~/.claude/settings.json and add or modify these env fields, replacing your_zai_api_key. A new window is required for changes to take effect.

    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,
            "API_TIMEOUT_MS": "3000000"
        }
    }
  5. Step 5.

    Start Claude Code in your project. If prompted with "Do you want to use this API key," select "Yes."

    Terminal
    cd your-project-directory
    claude
  6. Step 6.

    Confirm the switch: run claude, type /status, and check that Settings source shows ~/.claude/settings.json and Model shows the GLM model. Use /effort to change thinking intensity (default max).

    Snippet
    /status

Caveats

  • Z.ai's Claude Code page lists the default mapping as GLM-5.3-Flash for all three slots, while its manual config snippet maps Sonnet/Opus to glm-5.3[1m] and Haiku to glm-5.3-flash[1m]; both are on official pages.
  • The [1m] suffix plus CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000 enables 1M context; Z.ai says to upgrade Claude Code (claude update) if the [1m] model is reported as not existing.
  • The GLM Coding Plan is limited to Z.ai's officially supported tools. Since 2026-10-16, Coding Plan keys and Standard API keys are separate and not interchangeable; a Standard key in Claude Code bills pay-as-you-go, not plan quota.
  • Z.ai also offers a macOS/Linux shell script (claude_code_zai_env.sh) that writes ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL and API_TIMEOUT_MS; it is omitted here because it downloads and runs a remote script.
  • Z.ai states compatibility was verified with Claude Code 2.0.14 and other versions and recommends the latest version.

FAQ

How do I use GLM in Claude Code?

Z.ai documents pointing Claude Code at its Anthropic-compatible endpoint (https://api.z.ai/api/anthropic) by setting env vars in ~/.claude/settings.json, and mapping Claude Code's Opus/Sonnet/Haiku slots to GLM-5.3 and GLM-5.3-Flash with a [1m] suffix for 1M context.

Which GLM model ids work in Claude Code?

The official docs read for this guide list glm-5.3, glm-5.3[1m], glm-5.3-flash and glm-5.3-flash[1m]. Requests go to https://api.z.ai/api/anthropic.

Is this an official GLM and Claude Code setup?

GLM documents this setup in its own docs. It was last checked against 4 official pages on October 17, 2026.

Sources

Last verified against 4 official pages.

Newsletter

New models, set up the day they ship

One email per week. New model releases, the coding tools that support them and how to wire them up.