Use with Coding Tools
Any coding tool or client that accepts a custom OpenAI-compatible endpoint can use the ZAI API. Every tool needs the same three settings:
| Setting | Value |
|---|---|
| Base URL | https://api.ourzai.com/v1 |
| API Key | A key created on the API keys page of the developer console |
| Model | A model ID from the model catalog, entered exactly |
Tool interfaces change between versions. The steps below name each tool's settings; if you cannot find one, fill in the three settings above wherever the tool asks for them. A coding tool can send many requests to finish one task, and each request is charged to your balance by usage, so consider setting a spending limit on the key. See Get a key.
Every chat model supports chat.completions; only some models also offer responses or the Anthropic messages endpoint. Codex needs responses and Claude Code needs messages. Before choosing a model, check its endpoints in Model catalog and integration.
Cline
- Open Cline's settings and set "API Provider" to OpenAI Compatible.
- Set "Base URL" to
https://api.ourzai.com/v1. - Enter your key in "API Key".
- In "Model ID", enter the ID of a chat model that supports
chat.completions.
Cursor
- Open Cursor Settings → Models.
- Under API Keys, enter your key as the OpenAI API Key, turn on Override OpenAI Base URL, and enter
https://api.ourzai.com/v1. - Add the model IDs you want to use to the model list and enable them.
Your own key is used only for the models you pick in chat and Agent. Cursor's built-in features, such as Tab completion, still run on Cursor's own service.
Codex CLI
Codex calls models through the Responses endpoint, so choose a model that offers responses. Add the following to ~/.codex/config.toml:
model = "<model ID that offers responses>"
model_provider = "zai"
[model_providers.zai]
name = "ZAI"
base_url = "https://api.ourzai.com/v1"
env_key = "ZAI_API_KEY"
wire_api = "responses"
Then set the key in the terminal where you start Codex:
export ZAI_API_KEY="<your API key>"
In Windows PowerShell, use $env:ZAI_API_KEY = "<your API key>".
Claude Code
Claude Code calls models through the Anthropic Messages endpoint, so only models that offer messages work. Set these environment variables before starting it:
export ANTHROPIC_BASE_URL="https://api.ourzai.com"
export ANTHROPIC_AUTH_TOKEN="<your API key>"
export ANTHROPIC_MODEL="<model ID that offers messages>"
export ANTHROPIC_DEFAULT_OPUS_MODEL="<the same model ID>"
export ANTHROPIC_DEFAULT_SONNET_MODEL="<the same model ID>"
export ANTHROPIC_DEFAULT_HAIKU_MODEL="<the same model ID>"
claude
- Leave
/v1out ofANTHROPIC_BASE_URL: Claude Code appends/v1/messagesitself. - Claude Code uses other model tiers by default for background tasks and subagents. Point all three
ANTHROPIC_DEFAULT_*_MODELvariables at a model the platform offers withmessages, so that it never requests a model the platform does not have and gets a 404. - In Windows PowerShell, set the same variables with
$env:NAME = "value".
Other OpenAI-compatible clients
In apps such as Chatbox, Cherry Studio, LobeChat, Open WebUI, Dify, and n8n, add a provider of the "OpenAI compatible" or "custom OpenAI" type and fill in the three settings at the top of this page. For tools that read OpenAI's standard environment variables, see Use environment variables.
If requests fail after setup, look up the status code in Errors, Limits, and Usage: a 401 usually means a wrong key, and a 404 usually means a misspelled model ID or a model that does not support that endpoint.