Configure OpenClaw to Call Models via CLIProxyAPI (Copy-Paste Ready)
If you already have a CLIProxyAPI endpoint and want OpenClaw to call models through the proxy instead of directly calling the provider, this article gives you a configuration you can copy-paste immediately.
1) Where is CLIProxyAPI connected into OpenClaw?
In OpenClaw, the part that decides model routing lies in 2 layers:
- Provider layer (
models.providers)
Declares the proxy endpoint + the list of models that OpenClaw can see. - Agent routing layer (
agents.defaults.modelandagents.list[].model)
Selects the primary model (primary) and fallback models (fallbacks) in the format:provider/model-id. Example:cliproxy/gpt-5-mini
2) Minimal configuration sample for models.providers.cliproxy
Open the file:
nano ~/.openclaw/openclaw.json
Add (or update) the following block:
{
"models": {
"mode": "replace",
"providers": {
"cliproxy": {
"baseUrl": "https://proxy.naai.studio/v1",
"apiKey": "<YOUR_CLIPROXY_API_KEY>",
"api": "openai-completions",
"models": [
{
"id": "gpt-5-mini",
"name": "GPT 5 Mini",
"reasoning": false,
"input": ["text"],
"cost": { "input": 0, "output": 0 },
"contextWindow": 1000000,
"maxTokens": 8192
},
{
"id": "claude-opus-4-6",
"name": "Claude Opus 4.6",
"reasoning": true,
"input": ["text", "image"],
"cost": { "input": 0, "output": 0 },
"contextWindow": 1000000,
"maxTokens": 8192
}
]
}
}
}
}
Quick explanation of important fields
baseUrl: CLIProxyAPI endpoint (must include/v1if the proxy uses OpenAI-compatible standard).apiKey: key for OpenClaw to authenticate to the proxy.api: in actual configuration this isopenai-completions.models[].id: must exactly match the model ID exposed by the proxy.models.mode: "replace": use the list of models you declare to replace the default list.
3) Set primary + fallback model for the default agent
If you want the ability to switch models directly in the chat interface, you must configure the list of models you want to switch to inside fallbacks.

{
"agents": {
"defaults": {
"model": {
"primary": "cliproxy/gpt-5-mini",
"fallbacks": [
"cliproxy/claude-opus-4-6",
"anthropic/claude-opus-4-6",
"openai-codex/gpt-5.3-codex"
]
}
}
}
}
Principles:
- primary should be a cheap/fast model for most tasks.
- fallbacks should mix multiple providers to increase availability when the proxy or quota encounters errors.
If you configure it via the interface, do it here

4) Override per agent (if needed)
If you have multiple personas/workspaces (for example personal, work), you can override the model per agent in agents.list[]:
{
"agents": {
"list": [
{
"id": "personal",
"model": {
"primary": "openai-codex/gpt-5.1-codex-mini",
"fallbacks": [
"cliproxy/claude-opus-4-6",
"cliproxy/gemini-3-pro-preview"
]
}
}
]
}
}
The nice part: you still keep cliproxy/* in the fallbacks so it automatically “rescues the session” when the primary model fails.
5) Verification checklist after saving the configuration
- Check that the JSON is valid (no extra commas, brackets closed correctly).
- Call the proxy's models endpoint (to ensure key/URL are correct).
- Restart OpenClaw.
- Test a short prompt to confirm the
primarymodel works. - Test fallback scenarios (temporarily disable the primary or use an incorrect model ID to observe fallback switching).
6) Common errors and quick fixes
Error 401 Unauthorized
- Incorrect
apiKeyor the key has been revoked. - Fix: create a new key, update
models.providers.cliproxy.apiKey.
Error 404 / model not found
baseUrlhas an incorrect path or the modeliddoes not exist on the proxy.- Fix: recheck
/v1and sync the model IDs with the list returned by the proxy.
Conclusion
To integrate CLIProxyAPI into OpenClaw reliably, just remember 3 points:
1. Declare models.providers.cliproxy correctly.
2. Route primary/fallback correctly using the format provider/model-id.
3. Verify after every configuration change.
If you follow these 3 steps, you will both leverage your existing account via the proxy and keep the agent system running stably when a provider has issues.