📝 Tutorials
· 5 min read

Run Claude Code with GLM-5.2 for $18/Month — Complete Setup Guide


GLM-5.2 is one of the most capable coding models available today, and you can run it inside Claude Code for a flat $18/month. No per-token billing, no surprise invoices — just a subscription to the GLM Coding Plan and a few minutes of configuration.

This guide walks you through the complete setup: from subscribing to the plan, to configuring Claude Code, to verifying everything works. We’ll also cover effort modes, troubleshooting common issues, and setting up Cline as an alternative.

If you’re coming from GLM-5.1, check out what changed in GLM-5.2 and our deep dive into the 1M context window.

Prerequisites

Before you start, make sure you have:

  • Claude Code installed and updated to the latest version (run claude update to check)
  • A terminal with access to your home directory
  • A payment method for the GLM Coding Plan subscription

That’s it. No API keys to manage separately — the GLM Coding Plan handles authentication through its Anthropic-compatible endpoint.

Step 1: Subscribe to the GLM Coding Plan

GLM-5.2 is available through the GLM Coding Plan, which exposes an Anthropic-compatible endpoint. This means Claude Code talks to GLM’s servers using the same protocol it uses for Anthropic’s own models — no adapter or proxy needed.

  1. Go to z.ai/subscribe
  2. Select the Coding Plan (starts at ~$18/month)
  3. Complete payment and note your account credentials

The Coding Plan gives you access to both GLM-5.2 (the flagship model) and GLM-4.5-air (a faster, lighter model used for background tasks). Both are included in the subscription.

Step 2: Configure Claude Code Settings

Open your Claude Code settings file:

code ~/.claude/settings.json

If the file doesn’t exist yet, create it. Add or merge the following configuration:

{
  "env": {
    "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.5-air",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2[1m]",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.2[1m]"
  }
}

Here’s what each variable does:

VariableValuePurpose
CLAUDE_CODE_AUTO_COMPACT_WINDOW"1000000"Sets the auto-compact threshold to 1M tokens, matching GLM-5.2’s context window
ANTHROPIC_DEFAULT_HAIKU_MODEL"glm-4.5-air"Routes lightweight/background tasks to the faster GLM-4.5-air model
ANTHROPIC_DEFAULT_SONNET_MODEL"glm-5.2[1m]"Routes standard requests to GLM-5.2 with 1M context
ANTHROPIC_DEFAULT_OPUS_MODEL"glm-5.2[1m]"Routes high-effort requests to GLM-5.2 with 1M context

The [1m] suffix is important — it enables the full 1 million token context window. Without it, you’d get the default (smaller) context. For a full explanation of how this works, see GLM-5.2 1M Context Explained.

Step 3: Verify the Setup

Launch Claude Code and run the /status command:

/status

You should see GLM-5.2 listed as the active model. If you see the standard Anthropic models instead, double-check your settings.json file for typos.

Step 4: Set the Right Effort Mode

Claude Code supports different effort levels that map to GLM’s thinking modes. For coding tasks, Max is recommended — it gives GLM-5.2 more thinking budget, which translates directly to better code generation and reasoning.

Use the /effort command to switch:

/effort max

Here’s how Claude Code’s effort levels map to GLM thinking modes:

Claude Code EffortGLM Thinking Mode
lowGLM High
mediumGLM High
highGLM High
xhighGLM Max
maxGLM Max
ultracodeGLM Max

For most coding work — refactoring, debugging, architecture decisions, writing tests — you want GLM Max. The difference in output quality is significant, especially for complex multi-file changes.

For quick questions or simple edits, the default effort (GLM High) works fine and responds faster.

Troubleshooting

”Model not found” error

This is the most common issue. It almost always means your Claude Code installation is outdated.

claude update

Update to the latest version and try again. Older versions don’t recognize the GLM model identifiers.

Settings not taking effect

Make sure your settings.json is valid JSON. A missing comma or bracket will cause Claude Code to silently ignore the file. You can validate it:

cat ~/.claude/settings.json | python3 -m json.tool

If you get a parse error, fix the JSON syntax.

Connection issues

Verify you can reach the GLM endpoint:

curl -s https://api.z.ai/api/coding/paas/v4/models | head -20

If this times out, check your network/firewall settings.

Bonus: Setting Up Cline with GLM-5.2

If you use Cline (the VS Code coding agent), you can connect it to GLM-5.2 as well:

  1. Open Cline settings in VS Code
  2. Set the provider to OpenAI Compatible
  3. Set the base URL to:
https://api.z.ai/api/coding/paas/v4
  1. Enter your GLM Coding Plan credentials
  2. Select glm-5.2[1m] as the model

That’s all it takes. Cline will now use GLM-5.2 for all its coding operations.

Other Compatible Tools

The GLM Coding Plan’s Anthropic-compatible endpoint works with a growing list of AI coding tools beyond Claude Code and Cline:

  • OpenCode — terminal-based coding assistant
  • Roo Code — VS Code extension
  • OpenClaw — open-source coding agent
  • Kilo Code — lightweight coding tool
  • Crush — AI pair programmer
  • Goose — autonomous coding agent

Each tool connects to the same https://api.z.ai/api/coding/paas/v4 endpoint. Check each tool’s documentation for provider configuration specifics.

FAQs

How does GLM-5.2 compare to Claude Opus 4?

For a detailed benchmark comparison, see our GLM-5.2 vs Claude Opus 4 analysis. The short version: GLM-5.2 is competitive on coding benchmarks and significantly cheaper at flat-rate pricing.

Can I switch between GLM and Anthropic models?

Yes. Remove or comment out the env vars in settings.json to revert to Anthropic’s default models. You can keep both configurations and swap as needed.

Is the 1M context window actually usable?

Yes — and it’s one of GLM-5.2’s biggest advantages for large codebases. The CLAUDE_CODE_AUTO_COMPACT_WINDOW setting ensures Claude Code won’t compact your context prematurely. Read more in GLM-5.2 1M Context Explained.

What’s the difference from the GLM-5.1 setup?

The configuration is nearly identical. If you previously set up GLM-5.1 with Claude Code, just update the model names from glm-5.1[1m] to glm-5.2[1m] in your settings.json.

Do I still need an Anthropic API key?

No. The GLM Coding Plan provides its own Anthropic-compatible endpoint, so Claude Code authenticates through GLM directly. You don’t need a separate Anthropic subscription.

Is $18/month really unlimited?

The GLM Coding Plan is a flat-rate subscription. Check z.ai/subscribe for current plan details and any fair-use policies.

Next Steps

Once you’re set up, try throwing a complex refactoring task at GLM-5.2 in Max mode. The combination of 1M context and extended thinking makes it particularly strong at understanding large codebases and making coordinated changes across multiple files.