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:
| Scenario | OpenAI Compatible Mode | Anthropic 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.Recommended Configuration
Edit~/.openclaw/openclaw.json and add the following provider configuration:
Critical Configuration Notes
About reasoning: false
Model Allowlist Configuration
Add models toagents.defaults.models, otherwise OpenClaw may report the model as “unregistered” and silently fall back to another model:
Comparison with OpenAI Compatible Mode
| Feature | OpenAI Compatible Mode | Anthropic Native Mode |
|---|---|---|
| API Type | openai-completions | anthropic-messages |
| baseUrl | https://api.apiyi.com/v1 | https://api.apiyi.com |
| Supported Models | All 200+ models | Claude series only |
| Tool Calling | Unstable (multi-turn may 400) | Stable |
| Prompt Caching | Not supported | Supported |
| Extended Context | Depends on model | Up to 200K tokens |
| Best For | Multi-model switching, basic chat | Deep Claude usage, Agent tool calling |
Claude Model ID List
| Model ID | Name | Description |
|---|---|---|
claude-sonnet-4-6 | Claude Sonnet 4 | Balanced performance, recommended for daily use |
claude-opus-4-6 | Claude Opus 4 | Strongest reasoning capability |
claude-haiku-4-5-20251001 | Claude Haiku 4.5 | Fast response, cost-effective |
Mixed Configuration (Recommended)
Configure both OpenAI compatible and Anthropic native providers, switching as needed:/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:meta.agentMeta.provider and meta.agentMeta.model match your configuration.
Troubleshooting
400 ValidationException: Operation not allowed
400 ValidationException: Operation not allowed
This is usually caused by thinking-related fields in the request. Ensure:
- Model entries have
"reasoning": falseset - Headers include
"anthropic-beta": ""correctly configured
Configuration changed but not taking effect
Configuration changed but not taking effect
Existing chat sessions may have cached the old model configuration. Two solutions:Patch the session model:Or reset the session:
Model silently falls back to another model
Model silently falls back to another model
Check if the model has been added to the
agents.defaults.models allowlist. Unregistered models will be automatically fallen back by OpenClaw.baseUrl path duplication error
baseUrl path duplication error
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.