Bỏ qua đến nội dung
Configure OpenClaw to Call Models via CLIProxyAPI (Copy-Paste Ready)

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:

  1. Provider layer (models.providers)
    Declares the proxy endpoint + the list of models that OpenClaw can see.
  2. Agent routing layer (agents.defaults.model and agents.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 /v1 if the proxy uses OpenAI-compatible standard).
  • apiKey: key for OpenClaw to authenticate to the proxy.
  • api: in actual configuration this is openai-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

  1. Check that the JSON is valid (no extra commas, brackets closed correctly).
  2. Call the proxy's models endpoint (to ensure key/URL are correct).
  3. Restart OpenClaw.
  4. Test a short prompt to confirm the primary model works.
  5. 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 apiKey or the key has been revoked.
  • Fix: create a new key, update models.providers.cliproxy.apiKey.

Error 404 / model not found

  • baseUrl has an incorrect path or the model id does not exist on the proxy.
  • Fix: recheck /v1 and 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.

Bạn thấy bài viết hữu ích?

Đăng ký để nhận thông báo khi có bài viết mới.

Kiểm tra hộp thư để xác nhận email!
Bạn đã đăng ký thành công vào Geek Playground
Tuyệt vời! Tiếp theo, hoàn tất thanh toán để có quyền truy cập đầy đủ vào Geek Playground
Chào mừng trở lại! Bạn đã đăng nhập thành công.
Thành công! Tài khoản của bạn đã được kích hoạt đầy đủ, bạn hiện có quyền truy cập vào tất cả nội dung.
Thành công! Thông tin thanh toán của bạn đã được cập nhật.
Cập nhật thông tin thanh toán không thành công.