Files
adolf/docs/providers/zai.md
alvis bedb527145
Some checks failed
ClawSweeper Dispatch / dispatch (push) Has been cancelled
CodeQL / Security High (actions) (push) Has been cancelled
CodeQL / Security High (channel-runtime-boundary) (push) Has been cancelled
CodeQL / Security High (core-auth-secrets) (push) Has been cancelled
CodeQL / Security High (mcp-process-tool-boundary) (push) Has been cancelled
CodeQL / Security High (network-ssrf-boundary) (push) Has been cancelled
CodeQL / Security High (plugin-trust-boundary) (push) Has been cancelled
CodeQL / Security High (process-exec-boundary) (push) Has been cancelled
Docs Sync Publish Repo / sync-publish-repo (push) Has been cancelled
Docs / docs (push) Has been cancelled
OpenClaw Stable Main Closeout / Resolve stable release closeout inputs (push) Has been cancelled
OpenClaw Stable Main Closeout / Verify stable main closeout (push) Has been cancelled
Workflow Sanity / no-tabs (push) Has been cancelled
Workflow Sanity / actionlint (push) Has been cancelled
Workflow Sanity / generated-doc-baselines (push) Has been cancelled
CI / runner-admission (push) Has been cancelled
CI / preflight (push) Has been cancelled
CI / security-fast (push) Has been cancelled
CI / pnpm-store-warmup (push) Has been cancelled
CI / build-artifacts (push) Has been cancelled
CI / native-i18n (push) Has been cancelled
CI / ${{ matrix.check_name }} (push) Has been cancelled
CI / ${{ matrix.checkName }} (push) Has been cancelled
CI / checks-node-compat-node22 (push) Has been cancelled
CI / check-bundled-channel-config-metadata (push) Has been cancelled
CI / check-dependencies (push) Has been cancelled
CI / check-guards (push) Has been cancelled
CI / check-lint (push) Has been cancelled
CI / check-prod-types (push) Has been cancelled
CI / check-shrinkwrap (push) Has been cancelled
CI / check-test-types (push) Has been cancelled
CI / check-additional-boundaries-a (push) Has been cancelled
CI / check-additional-boundaries-bcd (push) Has been cancelled
CI / check-additional-extension-bundled (push) Has been cancelled
CI / check-additional-extension-channels (push) Has been cancelled
CI / check-additional-extension-package-boundary (push) Has been cancelled
CI / check-additional-runtime-topology-architecture (push) Has been cancelled
CI / check-session-accessor-boundary (push) Has been cancelled
CI / check-session-transcript-reader-boundary (push) Has been cancelled
CI / check-docs (push) Has been cancelled
CI / skills-python (push) Has been cancelled
CI / macos-swift (push) Has been cancelled
CI / ios-build (push) Has been cancelled
CI / ci-timings-summary (push) Has been cancelled
Native App Locale Refresh / Refresh native fa (push) Has been cancelled
Native App Locale Refresh / Refresh native fr (push) Has been cancelled
Native App Locale Refresh / Refresh native hi (push) Has been cancelled
Native App Locale Refresh / Refresh native id (push) Has been cancelled
Native App Locale Refresh / Refresh native it (push) Has been cancelled
Native App Locale Refresh / Refresh native ja-JP (push) Has been cancelled
Control UI Locale Refresh / plan (push) Has been cancelled
Control UI Locale Refresh / Refresh ${{ matrix.locale }} (push) Has been cancelled
Control UI Locale Refresh / Commit control UI locale refresh (push) Has been cancelled
Live Media Runner Image / Build live media runner image (push) Has been cancelled
Native App Locale Refresh / Refresh native ar (push) Has been cancelled
Native App Locale Refresh / Refresh native de (push) Has been cancelled
Native App Locale Refresh / Refresh native es (push) Has been cancelled
Native App Locale Refresh / Refresh native ko (push) Has been cancelled
Native App Locale Refresh / Refresh native nl (push) Has been cancelled
Native App Locale Refresh / Refresh native pl (push) Has been cancelled
Native App Locale Refresh / Refresh native pt-BR (push) Has been cancelled
Native App Locale Refresh / Refresh native ru (push) Has been cancelled
Native App Locale Refresh / Refresh native sv (push) Has been cancelled
Native App Locale Refresh / Refresh native th (push) Has been cancelled
Native App Locale Refresh / Refresh native tr (push) Has been cancelled
Native App Locale Refresh / Refresh native uk (push) Has been cancelled
Native App Locale Refresh / Refresh native vi (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-CN (push) Has been cancelled
Native App Locale Refresh / Refresh native zh-TW (push) Has been cancelled
Native App Locale Refresh / Commit native locale refresh (push) Has been cancelled
Plugin Init Scaffold Validation / Validate provider scaffold (push) Has been cancelled
Plugin NPM Release / preview_plugins_npm (push) Has been cancelled
Plugin NPM Release / Validate release publish approval (push) Has been cancelled
Plugin NPM Release / preview_plugin_pack (push) Has been cancelled
Plugin NPM Release / publish_plugins_npm (push) Has been cancelled
Sandbox Common Smoke / sandbox-common-smoke (push) Has been cancelled
Website Installer Sync / static (push) Has been cancelled
Website Installer Sync / linux-docker (push) Has been cancelled
Website Installer Sync / macos-installer (push) Has been cancelled
Website Installer Sync / windows-installer (push) Has been cancelled
Website Installer Sync / sync-website (push) Has been cancelled
Vendor OpenClaw source as Adolf fork baseline
Adolf is a fork/vendored clone of github.com/openclaw/openclaw (v2026.6.11),
free to diverge. Tree copied sans upstream .git; upstream remote added for
future syncs. Node pinned to 24 (.nvmrc); engines already require >=22.19.
Preserves docs/ARCHITECTURE.md.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LeqyaxJF2nbRXJtae2kNB2
2026-07-05 09:36:54 +00:00

8.7 KiB

summary, read_when, title
summary read_when title
Use Z.AI (GLM models) with OpenClaw
You want Z.AI / GLM models in OpenClaw
You need a simple ZAI_API_KEY setup
Z.AI

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 models

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.

Getting started

Install the provider plugin first:

openclaw plugins install @openclaw/zai-provider
**Best for:** most users. OpenClaw probes supported Z.AI endpoints with your API key and applies the correct base URL automatically.
<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>
**Best for:** users who want to force a specific Coding Plan or general API surface.
<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>

Endpoints

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.

Config example

`zai-api-key` lets OpenClaw detect the matching Z.AI endpoint from the key and apply the correct base URL automatically. Use the explicit regional choices when you want to force a specific Coding Plan or general API surface.
{
  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" } } },
}

Built-in catalog

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
GLM models are available as `zai/` (example: `zai/glm-5`). Coding Plan setup defaults to `zai/glm-5.2`; general API setup keeps `zai/glm-5.1`. On the Coding Plan endpoints, auto-detection falls back to `glm-5.1` and then `glm-4.7` when the key/plan does not expose GLM-5.2. GLM versions and availability can change; run `openclaw models list --all --provider zai` to see the catalog known to your installed version.

Thinking levels

Full range: `off`, `low`, `high`, `max` (default `off`). OpenClaw maps `low` and `high` to Z.AI's `high` reasoning effort, and `max` to Z.AI's `max` effort, via `reasoning_effort` on the request payload. Binary toggle only: `off` and `low` (shown as `on` in pickers), default `off`. Setting thinking to `off` sends `thinking: { type: "disabled" }`; any other level leaves the request payload untouched (Z.AI's own default reasoning behavior applies).

Setting thinking to off avoids responses that spend the output budget on reasoning_content before visible text.

Advanced configuration

Unknown `glm-5*` ids still forward-resolve on the provider path by synthesizing provider-owned metadata from the `glm-4.7` template when the id matches the current GLM-5 family shape. `tool_stream` is enabled by default for Z.AI tool-call streaming. To disable it:
```json5
{
  agents: {
    defaults: {
      models: {
        "zai/<model>": {
          params: { tool_stream: false },
        },
      },
    },
  },
}
```
Preserved thinking is opt-in because Z.AI requires the full historical `reasoning_content` to be replayed, which increases prompt tokens. Enable it per model:
```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`.
The Z.AI plugin registers image understanding.
| Property      | Value       |
| ------------- | ----------- |
| Model         | `glm-4.6v`  |

Image understanding is auto-resolved from the configured Z.AI auth — no
additional config is needed.
- Z.AI uses Bearer auth with your API key. - The `zai-api-key` onboarding choice auto-detects the matching Z.AI endpoint by probing supported endpoints with your key. - Use the explicit regional choices (`zai-coding-global`, `zai-coding-cn`, `zai-global`, `zai-cn`) when you want to force a specific API surface. - The legacy env var `Z_AI_API_KEY` is still accepted; OpenClaw copies it to `ZAI_API_KEY` at startup if `ZAI_API_KEY` is unset. Choosing providers, model refs, and failover behavior. Full OpenClaw config schema, including provider and model settings.