Once you have subscribed to the GLM Coding Plan, wiring it into your favourite coding tool takes a couple of minutes. Here is how to do it in the most popular agents as of June 2026.

New to the plan? Subscribe with 5% off using code RIMBTGLNJI first, then come back here.

Step 1: Get your GLM Coding Plan API key

  1. Log in to your Z.ai account.
  2. Open the API Keys page on the Z.ai Open Platform.
  3. Create a new key and copy it somewhere safe.

There are two base URLs depending on the tool:

  • Claude Code (Anthropic-compatible): https://api.z.ai/api/anthropic
  • Other tools (OpenAI-compatible): https://api.z.ai/api/coding/paas/v4

Current model names you can use: glm-5.2, glm-5.2[1m] (the 1M-context variant), glm-5-turbo, and glm-4.7.

Step 2: Claude Code

Claude Code reads its config from ~/.claude/settings.json. Add an env block:

{
    "env": {
        "ANTHROPIC_BASE_URL": "https://api.z.ai/api/anthropic",
        "ANTHROPIC_AUTH_TOKEN": "your-glm-coding-plan-key",
        "API_TIMEOUT_MS": "3000000",
        "ANTHROPIC_DEFAULT_SONNET_MODEL": "glm-5.2[1m]",
        "ANTHROPIC_DEFAULT_OPUS_MODEL": "glm-5.2[1m]",
        "ANTHROPIC_DEFAULT_HAIKU_MODEL": "glm-4.7",
        "CLAUDE_CODE_AUTO_COMPACT_WINDOW": "1000000"
    }
}

The model mappings tell Claude Code to use GLM-5.2 (with its 1M context) wherever it would normally call Claude, and the lighter GLM-4.7 for quick tasks. The CLAUDE_CODE_AUTO_COMPACT_WINDOW line lets Claude Code take advantage of the full 1M-token window. Launch Claude Code as usual and it will route to GLM.

Step 3: Cline (VS Code)

Cline uses the OpenAI-compatible endpoint:

  1. Open Cline's settings and set the API Provider to an OpenAI-compatible / custom option.
  2. Base URL: https://api.z.ai/api/coding/paas/v4
  3. API key: your GLM Coding Plan key.
  4. Model: glm-5.2 (or glm-5.2[1m] for the long-context variant).

Save, and Cline will use GLM for its agentic edits.

Step 4: Roo Code

Roo Code works the same way as Cline:

  1. Settings, then Provider, then a compatible / custom endpoint.
  2. Base URL: https://api.z.ai/api/coding/paas/v4
  3. Paste your API key and pick the GLM model.

Step 5: Cursor, OpenCode, Kilo Code and others

The GLM Coding Plan officially supports 13+ agents. For Cursor, OpenCode, Kilo Code and the rest, add a custom OpenAI-compatible provider:

  1. Base URL: https://api.z.ai/api/coding/paas/v4
  2. API key: your GLM Coding Plan key.
  3. Reference a GLM model (glm-5.2) in the model picker or config.

Verifying it works

Run a small prompt like "list the files in this project and summarise the README." If the agent responds and starts reading files, you are connected. If you get an auth error, double-check the key and base URL; if you get a model-not-found error, confirm the exact model name from Z.ai's docs.

Tips

  • Mind the 5-hour window. Usage resets on a rolling basis, so if you hit a limit, wait a bit and quota frees up.
  • Save GLM-5.2 for the hard tasks. Advanced models consume quota faster; use GLM-4.7 for routine edits to stretch your plan.
  • Pick the right tier. If you constantly hit limits on Lite, move up to Pro. See the pricing guide.
  • Keep your key secret. Do not commit it to a repo; use environment variables or your tool's secret storage.

That is it: same tools, same workflow, GLM-5.2 under the hood. If you have not subscribed yet, do it with 5% off.