explainx.ainewsletter3.5k
TrendingNewsPathwaysSkills
Pricing
explainx.ai

Upskill in AI — 16 free pathways, live workshops & bootcamps, and 50+ courses from practitioners. Plus the skills, tools, and MCP servers to practice on.

follow us

custom AI agents

[email protected]

get started

Find your pathTake Free Evaluation

learn

pathways — start freeworkshopsbootcampscoursescertificationsmock testsexplainx universitycorporate traininglearn skills & mcp

discover

skillsmcp serversexplainx mcptoolsagentsllmsdesignsagi trackerranks

company

aboutvisionmissionteaminstructorscommunityhackathonscareers

content

daily AI newsstate of AI — live resultsblogreleasespromptsgeneratorsresource librarydemofor LLMs

solutions

all solutionsdeveloper upskillingmarketing upskillingproduct manager upskillingleadership upskilling

More from us

InfloqInfluencer marketingBgBlurPrivacy-first blurOlly SocialSocial AI copilotCeptoryVideo intelligenceBgRemoverBackground removal

newsletter · weekly

Get AI news, tools, and insights in your inbox.

supportprivacytermsdata rightssubmission guidelines

© 2026 AISOLO Technologies Pvt Ltd

On this page

  • Quick pick: which harness?
  • How do I get a GLM Coding Plan API key?
  • How to run GLM 5.2 in Claude Code
  • How to run GLM 5.2 in Pi
  • How to run GLM 5.2 in ZCode
  • How to run GLM 5.2 in OpenCode
  • How to run GLM 5.2 in OpenClaw
  • How to run GLM 5.2 in Codex (via Ollama)
  • How to run GLM 5.2 locally (LM Studio / vLLM)
  • How to run GLM 5.2 in Cursor, Cline, and other tools
  • How do I enable 1M context on GLM 5.2?
  • How do I verify GLM 5.2 is actually running?
  • How do I avoid burning through GLM 5.2 quota?
  • Which harness should I pick?
  • Summary
  • Related Reading
← Back to blog

explainx / blog

How to Run GLM 5.2 in Claude Code, Pi, OpenCode & Every Harness (2026)

How do you run GLM 5.2? Step-by-step for Claude Code, Pi, ZCode, OpenCode, OpenClaw, Codex+Ollama, and local inference — API keys, endpoints, model IDs, effort levels, and quota tips.

Jun 19, 2026·10 min read·Yash Thakker
GLM-5.2Zhipu AIAgent HarnessPiClaude CodeCoding Agents
go deep
How to Run GLM 5.2 in Claude Code, Pi, OpenCode & Every Harness (2026)

Matt Pocock (@mattpocockuk) asked: "Folks who are running GLM 5.2, how are you doing it? What harness/provider are you using?"

Update — July 19, 2026: Alibaba's Qwen Token Plan bundles GLM-5.2 + Qwen3.8-Max-Preview + DeepSeek V4 Pro on one subscription — same harness wiring as below, different base URL from qwencloud.com API Keys.

This guide answers in how-to form — one section per harness, step by step. Jump to the tool you use:

  • How to run GLM 5.2 in Claude Code
  • How to run GLM 5.2 in Pi
  • How to run GLM 5.2 in ZCode
  • How to run GLM 5.2 in OpenCode
  • How to run GLM 5.2 in OpenClaw
  • How to run GLM 5.2 in Codex
  • How to run GLM 5.2 locally

Model context (benchmarks, vs Fable 5, export ban): GLM-5.2 explainer. Harness concepts: What Is an Agent Harness?.

Every section below follows the same pattern: what you need, which endpoint to use, how to select glm-5.2, and how to map reasoning effort. If you already have a Coding Plan key, jump straight to your harness. If not, start with How do I get a GLM Coding Plan API key?.

Weekly digest3.5k readers

Catch up on AI

Curated AI updates on agents, skills, and MCP — delivered to your inbox. Unsubscribe anytime.

Quick pick: which harness?

You want…HarnessJump to
Fastest setup, official UXZCodeZCode how-to
Already use Anthropic CLIClaude CodeClaude Code how-to
Open source, any modelOpenCodeOpenCode how-to
Minimal harness you ownPiPi how-to
Codex + open weightsCodex + OllamaCodex how-to
Local inferenceLM Studio / vLLMLocal how-to

How do I get a GLM Coding Plan API key?

Most how-tos below assume a GLM Coding Plan subscription (Lite ~$18/mo, Pro, Max, Team).

  1. Sign up at z.ai
  2. Open z.ai/manage-apikey/apikey-list
  3. Create a Coding Plan API key (Team keys differ from personal keys — use the right one)

Endpoints you need:

Harness typeBase URL
Claude Codehttps://api.z.ai/api/anthropic
OpenAI-compatible tools (OpenCode, Cline, etc.)https://api.z.ai/api/coding/paas/v4
Pay-as-you-go API (not Coding Plan)https://api.z.ai/api/paas/v4

Model IDs: glm-5.2 (standard) · glm-5.2[1m] (1M context in Claude Code)

Quota: GLM-5.2 costs 3× during peak (14:00–18:00 UTC+8), 2× off-peak — promo 1× off-peak through September 2026. Use GLM-4.7 for cheap routine tasks.


How to run GLM 5.2 in Claude Code

Z.ai lists Claude Code as a first-class Coding Plan client. You keep the same CLI; you swap the provider.

Step 1: Install Claude Code (if needed)

bash
npm install -g @anthropic-ai/claude-code
cd your-project
claude

Step 2: Configure Z.ai credentials

Easiest — automated helper:

bash
npx @z_ai/coding-helper

Manual — edit ~/.claude/settings.json:

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

One-liner script (macOS/Linux):

bash
curl -O "https://cdn.bigmodel.cn/install/claude_code_zai_env.sh" && bash ./claude_code_zai_env.sh

Restart the terminal or open a new Claude Code session after env changes.

Step 3: Select GLM-5.2

  • Default model: GLM-5.2 or glm-5.2
  • 1M context: glm-5.2[1m] and set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000

Step 4: Set reasoning effort

Use /effort in Claude Code:

Claude Code /effortGLM-5.2 maps to
low, medium, highhigh
xhigh, maxmax

Use high for daily coding; max for architecture refactors and hard bugs.

Common Claude Code mistakes: using the general api/paas/v4 URL instead of the Anthropic-compatible path; putting the key in ANTHROPIC_API_KEY when Z.ai docs specify ANTHROPIC_AUTH_TOKEN; forgetting to restart the terminal after editing settings.json. If Claude Code still hits Anthropic's servers, run echo $ANTHROPIC_BASE_URL — it should print https://api.z.ai/api/anthropic.

Step 5: Run your first task

bash
claude
# Example: fix a failing test with file context

More commands: Claude Code reference. Long sessions: loop engineering.


How to run GLM 5.2 in Pi

Tadej Stanic (@tadejstanic) on Matt's thread: "It's Opus 4.8 level for sure. When you use in pi.dev harness…"

Step 1: Install Pi

bash
curl -fsSL https://pi.dev/install.sh | sh
# or: npm install -g --ignore-scripts @earendil-works/pi-coding-agent

Step 2: Start Pi in your project

bash
cd your-project
pi

Step 3: Connect Z.AI Coding Plan

  1. Run /login (OAuth) or export your Coding Plan API key per pi.dev/docs
  2. Select provider Z.AI Coding Plan (not generic Z.AI if you are on the subscription)
  3. /model or Ctrl+L → glm-5.2

Step 4: Configure reasoning effort

Pi maps effort for GLM-5.2 (earendil-works/pi#5770):

Pi settingSends to GLM
low, medium, highreasoning_effort: high
xhighreasoning_effort: max
thinking offthinking disabled

Step 5: Add verification (recommended)

Pi does not ship test loops by default. Paste a kickoff from explainx.ai loops — e.g. ci-until-green.

Deeper Pi context: Pi harness guide. Heavier fork: oh-my-pi with Z.AI/GLM in its provider matrix.


How to run GLM 5.2 in ZCode

Sheeki (@sheeki03): "zcode.z.ai — the app is a copy of Codex, and it's good as well."

Zero manual endpoint config — Z.ai's official desktop agent.

Step 1: Subscribe to GLM Coding Plan

z.ai/subscribe — GLM-5.2 included on all tiers.

Step 2: Download ZCode

Get the app from zcode.z.ai (macOS, Windows, Linux).

Step 3: Sign in and select GLM-5.2

  1. Log in with your Z.ai account
  2. Choose GLM-5.2 as the active model
  3. Use /goal for long-horizon tasks (matches GLM-5.2's long-context positioning)

Check z.ai for in-app quota promos (community reported 50% extra usage and 1.5× effective quota offers — verify live before relying on them).


How to run GLM 5.2 in OpenCode

treysync (@0xtreysync): "OpenCode is my preference. Honestly been having comparable results to Opus."

Step 1: Install OpenCode

bash
curl -fsSL https://opencode.ai/install | bash
# or: npm install -g opencode-ai

Full harness overview: OpenCode guide. Local open weights (no API): Run OSS models locally in OpenCode.

Step 2: Connect Z.AI Coding Plan

bash
cd your-project
opencode

Inside the TUI:

  1. /connect
  2. Search Z.AI → select Z.AI Coding Plan
  3. Paste your Coding Plan API key

Step 3: Select GLM-5.2

  1. /models
  2. Choose GLM-5.2 (use GLM-4.7 for routine work to save quota)

Step 4: Initialize project memory

text
/init

Creates AGENTS.md — same filename as Codex.

Slash commands: OpenCode commands reference.

Custom config (if needed in opencode.json):

json
{
  "provider": {
    "zai": {
      "options": {
        "baseURL": "https://api.z.ai/api/coding/paas/v4"
      }
    }
  }
}

How to run GLM 5.2 in OpenClaw

OpenClaw is on Z.ai's supported tool list. It embeds Pi via SDK — configure GLM like any custom Anthropic provider.

Steps

  1. Subscribe to GLM Coding Plan and get API key
  2. In OpenClaw provider settings, set:
    • Base URL: https://api.z.ai/api/anthropic (Anthropic-compatible path)
    • API key: your Coding Plan key
    • Model: glm-5.2
  3. Read Is OpenClaw Safe? before routing subscription OAuth through third-party harnesses

Underlying harness: Pi guide.


How to run GLM 5.2 in Codex (via Ollama)

For OpenAI Codex users who want GLM weights without Z.ai Coding Plan routing in Claude Code:

Step 1: Pull GLM-5.2 in Ollama

bash
ollama pull glm-5.2

Step 2: Launch Codex in OSS mode

bash
ollama launch codex
# or manually:
codex --oss -m glm-5.2

Full setup: Codex + Ollama OSS guide.

This uses Ollama as model host + Codex as harness — separate from Coding Plan quota rules.


How to run GLM 5.2 locally (LM Studio / vLLM)

Szymon (@Szymon_Lorenz) uses LM Studio. Henry Mascot noted ~256GB RAM for full local GLM-5.2 — plan for cluster/quantized serving, not a laptop default.

Step 1: Download weights

huggingface.co/zai-org/GLM-5.2 (MIT)

Step 2: Serve with your stack

  • LM Studio — load model, enable OpenAI-compatible local server
  • vLLM 0.23+ / SGLang 0.5.13+ — see GLM-5.1 local patterns (same workflow, model id glm-5.2)

Step 3: Point your harness at localhost

HarnessHow
PiCustom provider in models.json → http://localhost:PORT/v1
OpenCode/connect → Ollama or LM Studio local provider
Claude CodeNot typical for local — use Pi or OpenCode instead

How to run GLM 5.2 in Cursor, Cline, and other tools

Z.ai documents these in quick start:

ToolHow to run GLM 5.2
Cline/connect or settings → OpenAI Compatible → https://api.z.ai/api/coding/paas/v4 → key → GLM-5.2
CursorCustom OpenAI-compatible provider → same base URL + model
Factory + vibeproxyCoding Plan key through proxy (community pattern)
Crush / Goose / Roo Code / Kilo CodeSame OpenAI-compatible pattern per Z.ai tool list

HCC (@HCColenbrander) warns Z.ai uptime can be spotty — keep GLM-4.7 or a fallback harness for deadline days.

How to run GLM 5.2 in Cursor specifically: open Settings → Models → Add custom provider. Set base URL to https://api.z.ai/api/coding/paas/v4, paste your Coding Plan key, and enter GLM-5.2 as the model name. Cursor treats this like any OpenAI-compatible endpoint — no Anthropic URL needed. Same pattern works in Windsurf, Continue, and other editors that accept a custom OpenAI base URL.

How to use Coding Plan MCP servers

Included on all tiers: Vision, Web Search, Web Reader, Zread (Z.ai docs). Enable in Claude Code or ZCode for mockup-to-code and live doc lookup.


How do I enable 1M context on GLM 5.2?

In Claude Code only (documented pattern):

  1. Set model to glm-5.2[1m]
  2. Export or set CLAUDE_CODE_AUTO_COMPACT_WINDOW=1000000
  3. Use /effort max only when the task truly needs full-repo context

Other harnesses: check provider docs — OpenCode and ZCode may expose 1M natively depending on build.


How do I verify GLM 5.2 is actually running?

Before burning quota on a long agent session, confirm the model and endpoint are wired correctly:

  1. Check the model name — the harness should show glm-5.2 or GLM-5.2, not a fallback like glm-4.7 or claude-sonnet.
  2. Ask a identity probe — "What model are you?" GLM-5.2 should self-identify correctly; if it says Claude or GPT, your provider routing is wrong.
  3. Watch the first API call — in Claude Code, enable verbose logging or check that requests go to api.z.ai, not api.anthropic.com.
  4. Run a small coding task — fix one failing test or add a typed function. GLM-5.2 should produce coherent multi-file edits on the first turn.

If verification fails, re-check the base URL table in How do I get a GLM Coding Plan API key? — Anthropic-compatible harnesses and OpenAI-compatible harnesses use different paths.


How do I avoid burning through GLM 5.2 quota?

  1. GLM-4.7 — lint fixes, small edits, doc Q&A
  2. GLM-5.2 + high effort — features, multi-file refactors
  3. GLM-5.2 + max effort — architecture, heisenbugs, /goal marathons
  4. Schedule heavy runs outside 14:00–18:00 UTC+8 when off-peak promo applies
  5. Add deterministic verification — agent loops so GLM is not the judge of "done"

Which harness should I pick?

If you…Start here
Want zero configZCode
Already live in Claude CodeClaude Code (how-to above)
Want open source + 75 providersOpenCode
Want to own the harnessPi
Want Codex UX + OSS weightsCodex + Ollama
Have a GPU clusterLocal vLLM + Pi/OpenCode

None replace tests or CI as exit criteria — GLM-5.2 reasons well; your harness still needs a verification loop.


Summary

How to run GLM 5.2 is a harness question, not a model question. Pick your tool, follow the matching section above, and verify the endpoint before long sessions:

QuestionShort answer
How to run GLM 5.2 in Claude Code?ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic + Coding Plan key + glm-5.2
How to run GLM 5.2 in Pi?/login → Z.AI Coding Plan → /model → glm-5.2
How to run GLM 5.2 in ZCode?Sign in at zcode.z.ai, select GLM-5.2
How to run GLM 5.2 in OpenCode?/connect → Z.AI Coding Plan → /models → GLM-5.2
How to run GLM 5.2 locally?HF weights + LM Studio/vLLM + localhost provider in Pi or OpenCode

Model benchmarks and ban context: GLM-5.2 explainer.


Update — July 20, 2026: Hugging Face CEO said hosted US frontier models blocked exploit-payload analysis; HF switched to local GLM 5.2 for defensive security work. See cyber guardrails debate for IR routing patterns.

Related Reading

  • AI cyber guardrails debate — self-hosted GLM 5.2 for IR (July 2026)
  • Colibrì — GLM-5.2 on 25 GB RAM via disk streaming (July 2026)
  • Perplexity Computer GLM 5.2 orchestrator — 0.344× Opus cost (July 9)
  • Ollama $88M funding — what is Ollama? (July 2026)
  • How to run open-source models locally in OpenCode — Ollama, llama.cpp, opencode.jsonc pillar guide
  • Qwen 3.8-Max-Preview Token Plan — cloud frontier while waiting for 3.8 GGUF
  • Qwen 3.6 27B local dev — llama.cpp + OpenCode on Apple Silicon
  • GLM-5.2 Beats Fable 5 on Reasoning — China AI Response
  • GPT-5.6 Sol in Claude Code — proxy setup like GLM harness swap
  • What Is an Agent Harness?
  • Top 10 AI Agent Loops for Coding Workflows
  • Pi: Minimal Agent Harness by Mario Zechner
  • GLM-5.1: Hugging Face and Ollama Run Guide
  • Codex Open-Source Models via Ollama
  • oh-my-pi: Pi Fork with Z.AI/GLM Support
  • Z.ai GLM Coding Plan docs

Endpoints, quota multipliers, and supported tools are accurate as of June 19, 2026 per docs.z.ai. Verify current promos on z.ai before subscribing.

Yash Thakker

Written by

Yash Thakker

Yash is an AI expert with over 300K learners. Join his workshops →

Related posts

Jun 19, 2026

Pi Agent Harness: Mario Zechner's Minimal Coding Agent You Can Own (2026)

Pi's tagline is blunt: there are many agent harnesses, but this one is yours. Built by Mario Zechner (badlogic), Pi ships a small core — no baked-in MCP, sub-agents, or plan mode — and lets you extend everything via skills, extensions, and npm packages. Here is how Pi fits the harness layer we define in our agent harness guide, and why OpenClaw embeds it.

Jul 26, 2026

AI Coding Agent Evals: How They Score on Real Repositories

Feature comparisons tell you what coding agents can click; repository evals test whether they can ship a correct change. This guide compares public signals and gives teams a reproducible private benchmark.

Jul 22, 2026

Top 10 Closed-Source and Open-Source Agent Harnesses (2026)

The model gets the headline; the harness decides whether the agent actually finishes the task. Here are the top 10 closed-source and top 10 open-source agent harnesses builders are running in 2026 — what each one does differently, what it costs, and who should pick it.