Skip to main content

Why Choose Anthropic Native Mode

OpenClaw supports two ways to call Claude models. If you need tool calling (tool_use) and other advanced features, Anthropic native mode (anthropic-messages) is strongly recommended:
ScenarioOpenAI Compatible ModeAnthropic Native Mode
Basic Chat✅ Works✅ Works
Tool Calling (tool loop)❌ May return 400✅ Stable
Prompt Caching❌ Not supported✅ Supported
Multi-model Switching✅ 200+ models⚠️ Claude series only
With openai-completions, basic chat works fine, but multi-turn tool calling (tool_calls → tool_result → tool loop) may be rejected with a 400 error. Switching to anthropic-messages allows tool_use + tool_result format to work properly.
Edit ~/.openclaw/openclaw.json and add the following provider configuration:
{
  "models": {
    "providers": {
      "apiyi": {
        "baseUrl": "https://api.apiyi.com",
        "apiKey": "sk-your-apiyi-key",
        "api": "anthropic-messages",
        "headers": {
          "anthropic-version": "2023-06-01",
          "anthropic-beta": ""
        },
        "models": [
          {
            "id": "claude-sonnet-4-6",
            "name": "Claude Sonnet 4",
            "reasoning": false,
            "contextWindow": 200000,
            "maxTokens": 16384
          },
          {
            "id": "claude-opus-4-6",
            "name": "Claude Opus 4",
            "reasoning": false,
            "contextWindow": 200000,
            "maxTokens": 16384
          }
        ]
      }
    }
  }
}

Critical Configuration Notes

The following three points must be set correctly, or you will encounter 400 errors:
  1. baseUrl without /v1: Must be https://api.apiyi.com — adding /v1 would result in .../v1/v1/messages causing request failure
  2. headers must include anthropic-version: Set to 2023-06-01
  3. anthropic-beta set to empty string: Disables beta feature headers to avoid triggering unsupported features

About reasoning: false

Claude models on APIYI will return a 400 error if the request contains thinking-related fields (thinking / output_config).Setting "reasoning": false in the model entry prevents OpenClaw from sending thinking fields, avoiding this issue.

Model Allowlist Configuration

Add models to agents.defaults.models, otherwise OpenClaw may report the model as “unregistered” and silently fall back to another model:
{
  "agents": {
    "defaults": {
      "model": { "primary": "apiyi/claude-sonnet-4-6" },
      "models": {
        "apiyi/claude-sonnet-4-6": { "streaming": false },
        "apiyi/claude-opus-4-6": { "streaming": false }
      }
    }
  }
}

Comparison with OpenAI Compatible Mode

FeatureOpenAI Compatible ModeAnthropic Native Mode
API Typeopenai-completionsanthropic-messages
baseUrlhttps://api.apiyi.com/v1https://api.apiyi.com
Supported ModelsAll 200+ modelsClaude series only
Tool CallingUnstable (multi-turn may 400)Stable
Prompt CachingNot supportedSupported
Extended ContextDepends on modelUp to 200K tokens
Best ForMulti-model switching, basic chatDeep Claude usage, Agent tool calling

Claude Model ID List

Model IDNameDescription
claude-sonnet-4-6Claude Sonnet 4Balanced performance, recommended for daily use
claude-opus-4-6Claude Opus 4Strongest reasoning capability
claude-haiku-4-5-20251001Claude Haiku 4.5Fast response, cost-effective
Configure both OpenAI compatible and Anthropic native providers, switching as needed:
{
  "agents": {
    "defaults": {
      "model": { "primary": "apiyi-claude/claude-sonnet-4-6" },
      "models": {
        "apiyi-claude/claude-sonnet-4-6": { "streaming": false },
        "apiyi-claude/claude-opus-4-6": { "streaming": false }
      }
    }
  },
  "models": {
    "providers": {
      "apiyi": {
        "baseUrl": "https://api.apiyi.com/v1",
        "apiKey": "sk-your-apiyi-key",
        "api": "openai-completions",
        "models": [
          { "id": "gpt-5.4", "name": "GPT-5.4" },
          { "id": "deepseek-v3.2", "name": "DeepSeek V3.2" }
        ]
      },
      "apiyi-claude": {
        "baseUrl": "https://api.apiyi.com",
        "apiKey": "sk-your-apiyi-key",
        "api": "anthropic-messages",
        "headers": {
          "anthropic-version": "2023-06-01",
          "anthropic-beta": ""
        },
        "models": [
          {
            "id": "claude-sonnet-4-6",
            "name": "Claude Sonnet 4",
            "reasoning": false,
            "contextWindow": 200000,
            "maxTokens": 16384
          },
          {
            "id": "claude-opus-4-6",
            "name": "Claude Opus 4",
            "reasoning": false,
            "contextWindow": 200000,
            "maxTokens": 16384
          }
        ]
      }
    }
  }
}
Use /model apiyi/gpt-5.4 or /model apiyi-claude/claude-sonnet-4-6 in chat to switch models.

Verify Configuration

After setup, verify that the configuration is working:
{/* Check model status */}
openclaw models status

{/* Send a test message and check the returned provider/model */}
openclaw agent --message "just reply pong" --json
In the returned JSON, check that meta.agentMeta.provider and meta.agentMeta.model match your configuration.

Troubleshooting

This is usually caused by thinking-related fields in the request. Ensure:
  • Model entries have "reasoning": false set
  • Headers include "anthropic-beta": "" correctly configured
Existing chat sessions may have cached the old model configuration. Two solutions:Patch the session model:
openclaw gateway call sessions.patch \
  --params '{"key":"your-session-key","model":"apiyi-claude/claude-sonnet-4-6"}'
Or reset the session:
openclaw gateway call sessions.reset \
  --params '{"key":"your-session-key","reason":"reset"}'
Check if the model has been added to the agents.defaults.models allowlist. Unregistered models will be automatically fallen back by OpenClaw.
The Anthropic native mode baseUrl must not include /v1. Using https://api.apiyi.com/v1 will result in .../v1/v1/messages, causing a 404 error.