Coding Tools (GLM Coding Plan)
go-z-ai coding configures third-party coding assistants to use your GLM
Coding Plan instead of their default provider. It's a Go port of Z.AI's
official @z_ai/coding-helper ("chelper") CLI, sharing the same credential
file so the two tools can be used interchangeably.
Supported tools
| Tool | Config file it writes |
|---|---|
| Claude Code | ~/.claude/settings.json (+ ~/.claude.json onboarding flag) |
| OpenCode | ~/.config/opencode/opencode.json |
| Crush | ~/.config/crush/crush.json |
| Factory Droid | ~/.factory/settings.json |
| Cursor | OS-specific — ~/Library/Application Support/Cursor/User/settings.json on macOS, ~/.cursor/settings.json (or ~/.config/Cursor/User/settings.json) elsewhere |
Run go-z-ai coding tools to see install status and exact resolved paths
on your machine.
Plans
| Plan identifier | Endpoint |
|---|---|
glm_coding_plan_global |
https://api.z.ai |
glm_coding_plan_china |
https://open.bigmodel.cn |
Pick whichever matches where your GLM Coding Plan subscription lives.
Quickstart
# 1. Store and validate your GLM Coding Plan key (one-time)
go-z-ai coding auth glm_coding_plan_global YOUR_KEY
# 2. Load it into a tool
go-z-ai coding load claude-code
# tool IDs: claude-code, opencode, crush, factory-droid, cursor
# aliases also work: claude, droid, factory
# 3. Check everything's wired up
go-z-ai coding status
go-z-ai coding doctor
Credentials live at ~/.chelper/config.yaml (byte-compatible with the
official Node helper) — coding auth writes there once, and coding load
reads from it for every tool unless you pass --key/--plan overrides.
To stop using Z.AI for a tool without losing your stored credential:
go-z-ai coding unload claude-code
This removes only the Z.AI-specific fields it added; it does not touch the rest of your existing config file.
Claude Code: model mapping
The official helper only sets ANTHROPIC_AUTH_TOKEN, ANTHROPIC_BASE_URL,
API_TIMEOUT_MS, and CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC. This client
goes further by default and also maps Claude Code's model tiers to specific
GLM models via ANTHROPIC_DEFAULT_*_MODEL, matching
Z.AI's documented recommendation:
| Claude tier | Default GLM model |
|---|---|
| haiku | glm-4.5-air |
| sonnet | glm-4.7 |
| opus | glm-4.7 |
Override any tier, or opt out entirely:
go-z-ai coding auth glm_coding_plan_global YOUR_KEY \
--sonnet glm-5.2 --opus glm-5.2
go-z-ai coding auth glm_coding_plan_global YOUR_KEY --no-model-mapping
Also configurable, all optional (0/omitted = don't set the env var):
| Flag | Env var it sets | Why you'd use it |
|---|---|---|
--auto-compact-window int |
CLAUDE_CODE_AUTO_COMPACT_WINDOW |
Defaults to 1,000,000 (GLM-5.2's context size); lower it (e.g. 128000) if you're pinned to a 128K-context model |
--max-thinking-tokens int |
MAX_THINKING_TOKENS |
Extended-thinking budget |
--max-output-tokens int |
CLAUDE_CODE_MAX_OUTPUT_TOKENS |
Output cap |
These flags are persistent on the coding command, so they apply the same
way to auth, load, and reload.
Key management
go-z-ai coding auth revoke # clear the stored key, keep the plan choice
go-z-ai coding auth reload <tool> # re-push stored creds into a tool
go-z-ai coding load <tool> --key OTHER_KEY --plan glm_coding_plan_china # one-off override
By default, coding auth validates a new key against the API before storing
it (a real /models call). Skip that with --no-validate if you want to
store a key offline (e.g. scripting a machine you haven't network-tested yet).
Vision MCP server
The official @z_ai/coding-helper wizard has a "manage MCP services" step
that this client didn't replicate until now: Z.AI ships its own
Vision MCP Server
(@z_ai/mcp-server) — screenshot OCR, error-screenshot diagnosis,
diagram/chart understanding, and general image/video analysis via GLM-4.6V,
launched on demand via npx. coding mcp registers it in whichever tool
you're using:
go-z-ai coding mcp add claude-code # uses the stored API key
go-z-ai coding mcp add crush --key OTHER_KEY
go-z-ai coding mcp status # which tools have it configured
go-z-ai coding mcp remove claude-code
Requires Node.js. The server itself runs via npx -y @z_ai/mcp-server —
Z.AI's own docs currently recommend Node.js 22+, though the npm package only
declares an 18+ requirement. coding mcp add/doctor warn (don't block) if
npx isn't found on PATH, since the config is valid the moment Node.js
becomes available.
The MCP config file often isn't the same file as your GLM credential. Two of the five tools keep MCP servers in a separate file from provider/API settings:
| Tool | Credential config | MCP config |
|---|---|---|
| Claude Code | ~/.claude/settings.json |
~/.claude.json |
| OpenCode | opencode.json |
same file, mcp key |
| Crush | crush.json |
same file, mcp key |
| Factory Droid | ~/.factory/settings.json |
~/.factory/mcp.json |
| Cursor | OS-specific settings.json |
sibling mcp.json, same directory |
Cursor isn't explicitly listed as a supported Vision MCP client in Z.AI's own docs — this uses the generic MCP shape Cursor documents for any server, which should work but hasn't been Z.AI-confirmed for this specific server.
Doctor
go-z-ai coding doctor
Checks: is a credential stored, does it look well-formed, which supported
tools are installed on PATH, and which of those already have a Z.AI
configuration (including the Vision MCP server, if registered). Good first
step when something isn't working.
Compliance & usage policy ⚠️
Z.AI's coding endpoint (/api/coding/paas/v4) is restricted by the
usage policy to "officially
supported tools," and "SDK-based access" is explicitly prohibited. Three
violations result in an account ban. Unidentified third-party clients are
indistinguishable from prohibited access at the server
(pi#4187).
go-z-ai mitigates this in two ways:
- The
codingsubcommand wires officially-supported tools (Claude Code, OpenCode, Crush, Factory Droid, Cursor) into their native config formats — exactly what Z.AI's own@z_ai/coding-helperdoes. The wiring itself is the supported path;go-z-aijust automates it from a Go binary. - Every request carries an identifying
User-Agent: go-z-ai/<version>header (overridable viaConfig.UserAgentfor downstream apps, proxies, and MCP servers that need their own identifier). This is the minimum hygiene that distinguishes go-z-ai from anonymous/prohibited access.
What this does not do:
- It does not make go-z-ai an "officially supported tool" — only Z.AI can
confer that status. Until then, using the
codingsubcommand to wire a supported tool is the compliant path; usingpkg/clientdirectly against/api/coding/paas/v4from a custom integration is at the user's own risk. - It does not spoof or evade detection. The header honestly identifies the client; the goal is to be a good citizen, not to hide.
If you are building a downstream tool, proxy, or MCP server on top of
pkg/client, set a distinct Config.UserAgent (e.g.
"my-tool/1.0 (go-z-ai)") so Z.AI can identify your traffic separately and
so you inherit go-z-ai's good-citizen default rather than weakening it.