Bỏ qua đến nội dung
Configuring CLIProxyAPI for OpenClaw

Configuring CLIProxyAPI for OpenClaw

If you already have a CLIProxyAPI endpoint and want OpenClaw to call the model via a proxy instead of calling the provider directly, this article provides a ready-to-use copy-paste configuration.

1) Where is CLIProxyAPI connected in OpenClaw?

In OpenClaw, the model routing decision 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 backup models (fallbacks) in the format:
  3. provider/model-id
    Example: cliproxy/gpt-5-mini

2) Minimum configuration template 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](https://proxy.naai.studio/v1)",
        "apiKey": "",
        "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 the OpenAI-compatible standard).
  • apiKey: key for OpenClaw to authenticate with the proxy.
  • api: in the actual configuration, it is openai-completions.
  • models[].id: must exactly match the model ID exposed by the proxy.
  • models.mode: "replace": uses the model list you declared to replace the default list.

3) Set primary + fallback model for the default agent

If you want the feature to switch models right on the chat interface, you must configure the list of models you want to switch to in the fallback.

{
  "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: set a cheap/fast model for most tasks.
- fallbacks: mix multiple providers to increase availability when the proxy or quota encounters errors.

To declare using the interface, do it here:

4) Override per agent (if needed)

If you have multiple personas/workspaces (e.g., personal, work), you can override the specific model 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 great thing is: you still keep cliproxy/* in the fallback to automatically "save the session" when the main model fails.

5) Verification checklist after saving configuration

  1. Check for valid JSON (no extra commas, correct bracket closures).
  2. Test call the proxy's models endpoint (ensure the key/URL is correct).
  3. Restart OpenClaw.
  4. Test a short prompt to confirm the primary model is working.
  5. Test a fallback situation (temporarily disable the primary or use a wrong model ID to observe the fallback switch).

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 again.

Error 404 / model not found

  • baseUrl has a wrong path or the model id does not exist on the proxy.
  • Fix: double-check /v1 and synchronize the model ID with the list returned by the proxy.

Conclusion

To stably integrate CLIProxyAPI into OpenClaw, just remember 3 points:
1. Correctly declare models.providers.cliproxy.
2. Correctly route primary/fallback in the format provider/model-id.
3. Verify after every configuration change.

By following these 3 steps correctly, you will be able to utilize your existing account via proxy while keeping the agent system running stably during provider errors.

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.