Configure Z.AI GLM in DeepSeek Harness
Choose the correct Z.AI general or Coding Plan endpoint, then save the matching key and model route.
On this page
The endpoint, protocol and environment variable below come from the provider's official documentation or the current upstream provider source. Model catalogs change, so use the ID shown by your installed DSH version.
Before you start
Make sure DSH is already running from npx @deepseek-ai/dsh web; the default Web UI address is http://127.0.0.1:3080. If DSH itself does not start, use the startup checks first.
Do not put a real key in a repository, screenshot, prompt or public error report.
Get a Z.AI / GLM API key
Open Z.AI API keys, sign in, create a key and copy it before leaving the page.
If you use YAML, the variable name must exactly match the apiKeyEnv value below; the variable name is not the key itself.
Add the provider to DSH
Open Settings → Models. If Z.AI / GLM appears in the installed catalog, choose Add provider, paste the API key and save it.
The Z.AI Coding Plan has a dedicated endpoint. Use the built-in Z.AI route for that plan. The general Z.AI API uses a different base URL, so configure it as a separate custom provider when that is the product you purchased.
The official provider guide says model and provider changes take effect on the next request. Save, then start a fresh session for the test.
Check the route values
| Route | Provider ID | apiKeyEnv | Base URL | API |
|---|---|---|---|---|
| GLM Coding Plan international · built-in | zai | ZAI_API_KEY | https://api.z.ai/api/coding/paas/v4 | openai-completions |
| GLM Coding Plan China · built-in | zai-coding-cn | ZAI_CODING_CN_API_KEY | https://open.bigmodel.cn/api/coding/paas/v4 | openai-completions |
| Z.AI general API · custom | zai-general-custom | ZAI_API_KEY | https://api.z.ai/api/paas/v4 | openai-completions |
Do not mix a key from one region or plan with another route or protocol. Use a built-in row only when that catalog is actually present in your DSH version.
Select a model
Select a GLM model from the route matching your key. Do not use a Coding Plan key with the general endpoint or a general API key with the Coding endpoint.
If a model is missing from the picker, do not keep guessing names. For an OpenAI-compatible custom route, use Fetch available models; if discovery fails, add the exact ID returned by the provider manually.
If the built-in catalog is missing: create a custom provider
Open Settings → Models → Add a custom provider. Use a lowercase Provider ID and choose it carefully, for example zai-glm-custom.
Base URL
https://api.z.ai/api/paas/v4
API protocol
openai-completions
Credential
ZAI_API_KEY holds the key
Models
Click Fetch available models, search and choose Add selected.
If the endpoint does not return a model list, confirm the key, base URL and model ID, then add it manually. Failed discovery does not by itself prove that chat requests fail.
If you need YAML
The Web UI is enough for a normal setup. Edit <code>$DSH_HOME/settings.yaml</code> only when you need a fixed custom route or a setting the form cannot express. Replace the model ID below with the exact value returned by the provider.
llm-pi-ai:
providers:
zai-glm-custom:
apiKeyEnv: ZAI_API_KEY
api: openai-completions
baseURL: https://api.z.ai/api/paas/v4
models:
- id: <copy the exact model id from the provider>Reference the key through <code>apiKeyEnv</code>; do not put the secret itself in the config file. A custom route's <code>models</code> list replaces that route's model catalog.
Test one safe request
Choose a disposable test workspace, start a fresh session, select the configured model and send:
Once the reply is successful, move on to file-reading or tool tasks. This keeps credential and routing failures separate from workspace and permission issues.
Common errors
MISSING_CREDENTIAL
Return to Settings → Models and save the key. With YAML, make sure the variable named by apiKeyEnv existed before DSH started.
UNKNOWN_MODEL
Use a Model ID that actually exists under the current provider. Do not substitute a display name, alias or an old tutorial's model name.
401 / authentication failed
Z.AI's own documentation distinguishes the general API from the Coding Plan endpoint. A correct-looking URL is not enough; the key and product permission must match it.
Fetch available models is empty or fails
Check the base URL, protocol and key currently shown in the form. If the provider does not expose a compatible model-list endpoint, confirm the model ID and add it manually.
The old model still appears to be used
A session that has already sent a request keeps its own recorded model. Start a new session when verifying the switch.