docs/providers/zai.md
Z.AI is the API platform for GLM models. It provides REST APIs for GLM and
uses API keys for authentication. Create your API key in the Z.AI console.
OpenClaw uses the zai provider with a Z.AI API key.
| Property | Value |
|---|---|
| Provider | zai |
| Package | @openclaw/zai-provider |
| Auth | ZAI_API_KEY (legacy alias: Z_AI_API_KEY) |
| API | Z.AI Chat Completions (Bearer auth) |
GLM is a model family, not a separate provider. In OpenClaw, GLM models use
refs such as zai/glm-5.2: provider zai, model id glm-5.2.
Install the provider plugin first:
openclaw plugins install @openclaw/zai-provider
<Steps>
<Step title="Run onboarding">
```bash
openclaw onboard --auth-choice zai-api-key
```
</Step>
<Step title="Verify the model is listed">
```bash
openclaw models list --all --provider zai
```
</Step>
</Steps>
<Steps>
<Step title="Pick the right onboarding choice">
```bash
# Coding Plan Global (recommended for Coding Plan users)
openclaw onboard --auth-choice zai-coding-global
# Coding Plan CN (China region)
openclaw onboard --auth-choice zai-coding-cn
# General API
openclaw onboard --auth-choice zai-global
# General API CN (China region)
openclaw onboard --auth-choice zai-cn
```
</Step>
<Step title="Verify the model is listed">
```bash
openclaw models list --all --provider zai
```
</Step>
</Steps>
| Onboarding choice | Base URL | Default model |
|---|---|---|
zai-global | https://api.z.ai/api/paas/v4 | glm-5.1 |
zai-cn | https://open.bigmodel.cn/api/paas/v4 | glm-5.1 |
zai-coding-global | https://api.z.ai/api/coding/paas/v4 | glm-5.2 |
zai-coding-cn | https://open.bigmodel.cn/api/coding/paas/v4 | glm-5.2 |
zai-api-key auto-detects one of these four by probing your key against each
endpoint's chat-completions API, checking general endpoints (zai-global,
then zai-cn) before Coding Plan endpoints (zai-coding-global, then
zai-coding-cn), and stopping at the first endpoint that accepts a request.
Use an explicit --auth-choice to force a Coding Plan endpoint if your key
works on both.
{
env: { ZAI_API_KEY: "sk-..." },
models: {
providers: {
zai: {
// GLM-5.2 uses the Coding Plan endpoint.
baseUrl: "https://api.z.ai/api/coding/paas/v4",
},
},
},
agents: { defaults: { model: { primary: "zai/glm-5.2" } } },
}
The zai provider plugin ships its catalog in the plugin manifest, so read-only
listing can show known GLM rows without loading provider runtime:
openclaw models list --all --provider zai
The manifest-backed catalog currently includes:
| Model ref | Notes |
|---|---|
zai/glm-5.2 | Coding Plan default; 1M context |
zai/glm-5.1 | General API default |
zai/glm-5 | |
zai/glm-5-turbo | |
zai/glm-5v-turbo | |
zai/glm-4.7 | |
zai/glm-4.7-flash | |
zai/glm-4.7-flashx | |
zai/glm-4.6 | |
zai/glm-4.6v | |
zai/glm-4.5 | |
zai/glm-4.5-air | |
zai/glm-4.5-flash | |
zai/glm-4.5v |
Setting thinking to off avoids responses that spend the output budget on
reasoning_content before visible text.
```json5
{
agents: {
defaults: {
models: {
"zai/<model>": {
params: { tool_stream: false },
},
},
},
},
}
```
```json5
{
agents: {
defaults: {
models: {
"zai/glm-5.2": {
params: { preserveThinking: true },
},
},
},
},
}
```
When enabled and thinking is on, OpenClaw sends
`thinking: { type: "enabled", clear_thinking: false }` and replays prior
`reasoning_content` for the same OpenAI-compatible transcript. The snake_case
`preserve_thinking` param key works as an alias.
Advanced users can still override the exact provider payload with
`params.extra_body.thinking`.
| Property | Value |
| ------------- | ----------- |
| Model | `glm-4.6v` |
Image understanding is auto-resolved from the configured Z.AI auth — no
additional config is needed.