Setup guide - From GLM and OpenCode docs
Use GLM in OpenCode
Z.ai documents logging OpenCode in to the Z.AI or Z.AI Coding Plan provider with opencode auth login, pasting the API key, and picking a GLM model with /models; OpenCode's docs document the same auth login command and the /connect then /models flow for catalog providers.
Last verified 4 steps4 official sources
Steps
- Step 1.
Install OpenCode (either method).
Terminalcurl -fsSL https://opencode.ai/install | bash npm install -g opencode-ai - Step 2.
Get your API key from Personal Coding Plan > Plan Overview (Individual) or Team Coding Plan > My Plan (Team).
- Step 3.
Add the credential. Z.ai documents the CLI login (select Z.AI Coding Plan if you subscribe to the GLM Coding Plan, otherwise Z.AI); OpenCode's docs document the same command and the /connect command inside the TUI.
Terminalopencode auth login # or, inside OpenCode /connect - Step 4.
Enter your Z.AI API key when prompted, launch OpenCode, and select a GLM model.
Terminalopencode /models
Caveats
- Z.ai's OpenCode page names the Z.AI and Z.AI Coding Plan providers; OpenCode's live provider docs describe connecting catalog providers generically (catalog from models.dev) and do not name Z.AI.
- Model ids come from Z.ai's How to Switch Models page; OpenCode's docs do not list GLM model ids.
- Base URL is not entered by the user in Z.ai's OpenCode steps; the value shown is Z.ai's documented OpenAI Chat Completions Coding Plan endpoint.
- Pick Z.AI Coding Plan for subscription quota; Z.AI (standard) bills pay-as-you-go. Coding Plan and Standard keys are separate since 2026-10-16.
More setup guides
Same tool, other providers
Related reading
- Prime Agent: A Self-Improving Coding Harness Where Everything Is PythonPrime Agent is Prime Intellect's open-source coding harness with one tool, a persistent IPython kernel. How it works, its benchmarks, and Claude Code compared.
- GLM 5.2 in 9 Minutes: The Open-Weight Rival to GPT-5.5GLM 5.2 in 9 minutes: a companion guide to the video on the open-weight GPT-5.5 rival, covering benchmarks, pricing and a live OpenCode demo.
- GLM-5.3 on Workers AI Leaked Other Users' Prompts: SGLang Fix ListCloudflare's GLM-5.3 Workers AI endpoint returned other customers' data in 155 long-prompt responses. What broke in SGLang, the upgrade and config checklist, and what API users should ask.
- Anthropic's GLM-5.3 Cyber Report: The Numbers, the Backlash, and What Developers Should Take From ItAnthropic's GLM-5.3 cyber report: exploit numbers against Claude Mythos Preview, how its safeguards were stripped, the backlash, and the read for developers.
- GLM-5.3 Free and Cheap: Every Route and Price (October 2026)GLM-5.3 has no free hosted tier. Cheapest on October 9: Wafer via OpenRouter at $0.049/$3.39, Flash from $0.075/$0.25. Z.ai's promos ended October 7.
- Cloudflare Runs Kimi and GLM at Scale: FP8 KV Caches, INT4 Weights, and a Cache Safety NetCloudflare runs Kimi K2.6 and GLM 5.2 on Workers AI with FP8 KV caches, INT4 weights and a KV cache integrity check. What each technique buys on GPU fleets.
FAQ
How do I use GLM in OpenCode?
Z.ai documents logging OpenCode in to the Z.AI or Z.AI Coding Plan provider with opencode auth login, pasting the API key, and picking a GLM model with /models; OpenCode's docs document the same auth login command and the /connect then /models flow for catalog providers.
Which GLM model ids work in OpenCode?
The official docs read for this guide list glm-5.3 and glm-5.3-flash. Requests go to https://api.z.ai/api/coding/paas/v4.
Is this an official GLM and OpenCode setup?
The steps draw on both GLM's and OpenCode's docs. It was last checked against 4 official pages on November 8, 2026.
Sources
Last verified against 4 official pages.
- docs.z.aihttps://docs.z.ai/devpack/tool/opencode
- opencode.aihttps://opencode.ai/docs/providers/
- opencode.aihttps://opencode.ai/docs/cli/providers
- docs.z.aihttps://docs.z.ai/devpack/latest-model
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.