GLM 5.2 + OpenCode
Configure GLM 5.2 as your OpenCode backend for cheap, high-quality AI-assisted coding
Why GLM 5.2 for OpenCode?
53× cheaper than Fable
Run thousands of OpenCode sessions for the price of one Fable session
Coding Plan built-in
GLM 5.2 plans multi-file edits before executing — ideal for OpenCode workflows
Fast responses
~85 tokens/sec means less waiting between file edits
Setup via OpenRouter (Recommended)
1. Get an OpenRouter API key
Sign up at openrouter.ai and add credits. GLM 5.2 output costs $0.28/M tokens.
2. Configure OpenCode
# opencode.json
{
"model": {
"provider": "openai",
"name": "zhipuai/glm-4",
"baseURL": "https://openrouter.ai/api/v1",
"apiKey": "sk-or-YOUR_KEY_HERE"
}
}3. Start OpenCode
opencode
Setup via Z.ai (Direct)
# opencode.json (Z.ai direct)
{
"model": {
"provider": "openai",
"name": "glm-4-plus",
"baseURL": "https://open.bigmodel.cn/api/paas/v4",
"apiKey": "YOUR_ZHIPU_API_KEY"
}
}Get your API key at z.ai. Offers slightly lower latency than OpenRouter.
Recommended OpenCode Settings for GLM 5.2
{
"model": { ... },
"autoshare": false,
"keybinds": {
"leader": "ctrl+x"
}
}