Coding agent integration
Nothing matches that. Try a protocol, a capability or an endpoint path.
Coding agents reach the gateway over the protocol they already speak: /v1/messages for Claude-style agents, /v1/responses for Codex, and /v1/chat/completions for everything else. Point the tool at ChinaAPI and its requests keep the same key, quota, logs, and billing as your own API traffic.
/v1/messages to whatever you give it, so it takes the bare host https://api.chinaapi.ai. Every other tool on this page expects the /v1 suffix spelled out. A doubled or missing /v1 is the most common cause of 404s here.
Hermes Agent
POST /v1/chat/completions
Point the model block of ~/.hermes/config.yaml at the gateway, or run hermes model and pick Custom endpoint interactively. base_url carries the /v1 suffix; Hermes appends /chat/completions itself.
model:
default: kimi-k2.7-code
provider: custom
base_url: https://api.chinaapi.ai/v1
api_key: <your ChinaAPI key>
Claude Code
POST /v1/messages
Export the three environment variables and start claude as usual. The ANTHROPIC_DEFAULT_*_MODEL variables map Claude Code's internal model tiers onto ChinaAPI models, which is what lets you run Chinese models inside an unmodified Claude Code.
export ANTHROPIC_BASE_URL=https://api.chinaapi.ai
export ANTHROPIC_AUTH_TOKEN=$CHINAAPI_KEY
export ANTHROPIC_DEFAULT_OPUS_MODEL=kimi-k3
export ANTHROPIC_DEFAULT_SONNET_MODEL=kimi-k2.7-code
export ANTHROPIC_DEFAULT_HAIKU_MODEL=glm-5-turbo
claude
Codex
POST /v1/responses
Codex talks the Responses protocol, so wire_api must be responses; leaving it on the chat wire format breaks tool calls. Put your key in the environment variable named by env_key. deepseek-v4-pro speaks the same wire format, so swapping the model name is all it takes to trade cost for capability.
model = "deepseek-v4-flash"
model_provider = "chinaapi"
[model_providers.chinaapi]
name = "ChinaAPI"
base_url = "https://api.chinaapi.ai/v1"
wire_api = "responses"
env_key = "CHINAAPI_KEY"
Cline, Roo Code, Kilo Code
POST /v1/chat/completions
All three use the same OpenAI Compatible provider form, field for field. Enter the model ID exactly as it appears in Console → Models; these tools do not fetch a model list for custom providers.
Base URL https://api.chinaapi.ai/v1
API Key <your ChinaAPI key>
Model ID glm-5.2
Cursor
POST /v1/chat/completions
Override the base URL under Settings → Models → OpenAI API Key. Add the ChinaAPI model name with Add model first, then leave only ChinaAPI models enabled, because Cursor otherwise sends its built-in model names to your override URL.
Base URL https://api.chinaapi.ai/v1
API Key <your ChinaAPI key>
Model deepseek-v4-pro
OpenClaw
POST /v1/messages
Declare ChinaAPI as a provider with "api": "anthropic-messages" and list the models you want selectable in the session picker.
{
"models": {
"providers": {
"chinaapi": {
"baseUrl": "https://api.chinaapi.ai",
"apiKey": "<your ChinaAPI key>",
"api": "anthropic-messages",
"models": ["kimi-k3", "glm-5.2"]
}
}
}
}
Aider
POST /v1/chat/completions
Aider routes by model prefix, so keep the openai/ prefix on the model name even though the model itself is a Chinese one.
export OPENAI_API_BASE=https://api.chinaapi.ai/v1
export OPENAI_API_KEY=$CHINAAPI_KEY
aider --model openai/deepseek-v4-pro
Choosing models: the model names above are working examples, not a fixed list. Open Console → Models for the aliases enabled on your account. For agent work, prefer a coding-tuned model on the tier the agent uses most and a cheap fast model on its lightweight tier — Claude Code, for instance, sends background summarisation to its Haiku tier, so mapping that tier to a small model saves the most quota.