For OpenClaw v2026.2 | This article assumes you have completed basic configuration and need to optimize model selection or cost control.
TL;DR: OpenClaw supports multiple models: Claude Opus/Sonnet/Haiku, GPT-4o, Gemini, local models (Ollama). Configure "agent": {"model": "anthropic/claude-opus-4-6"} to switch. Failover automatically switches to fallback: "fallback": [{"model": "claude-sonnet-4", "condition": "rate_limit"}]. Recommended: Claude Opus for complex tasks, Haiku for high-frequency simple tasks.
Supported Model Providers
Provider Overview
| Provider | Recommended Models | Characteristics | Price Reference |
|---|---|---|---|
| Anthropic | Claude Opus 4.6 / Sonnet 4 | Long context, strong reasoning, injection-resistant | $15-75/1M tokens |
| OpenAI | GPT-4o / GPT-4-turbo | Mature ecosystem, strong tool calling | $5-30/1M tokens |
| Gemini Pro / Ultra | Multimodal, long context | $1-7/1M tokens | |
| Groq | Llama 3 / Mixtral | Ultra-fast inference | Free/low-cost |
| Local | Ollama / LM Studio | Privacy, unlimited | Free (hardware required) |
Model Capability Comparison
| Model | Context Length | Tool Calling | Multimodal | Reasoning | Cost |
|---|---|---|---|---|---|
| Claude Opus 4.6 | 200K | ✅ | ✅ | ⭐⭐⭐⭐⭐ | High |
| Claude Sonnet 4 | 200K | ✅ | ✅ | ⭐⭐⭐⭐ | Medium |
| GPT-4o | 128K | ✅ | ✅ | ⭐⭐⭐⭐ | Medium |
| GPT-4-turbo | 128K | ✅ | ⚠️ | ⭐⭐⭐⭐ | Medium-High |
| Gemini Pro | 1M | ✅ | ✅ | ⭐⭐⭐ | Low |
| Llama 3.1 70B | 128K | ⚠️ | ⚠️ | ⭐⭐⭐ | Free |
Basic Model Configuration
Anthropic Claude
{
"agent": {
"model": "anthropic/claude-opus-4-6",
"thinkingLevel": "high"
},
"models": {
"anthropic": {
"apiKey": "${ANTHROPIC_API_KEY}",
"baseUrl": "https://api.anthropic.com"
}
}
}
Claude Model Selection Guide:
| Scenario | Recommended Model | Reason |
|---|---|---|
| Complex reasoning, code generation | Opus 4.6 | Strongest reasoning |
| Daily chat, simple tasks | Sonnet 4 | Best value |
| High-frequency calls, cost-sensitive | Haiku 3.5 | Fast, low cost |
OpenAI GPT
{
"agent": {
"model": "openai/gpt-4o"
},
"models": {
"openai": {
"apiKey": "${OPENAI_API_KEY}",
"baseUrl": "https://api.openai.com/v1",
"organization": "org-xxx"
}
}
}
GPT Model Selection Guide:
| Scenario | Recommended Model | Reason |
|---|---|---|
| General tasks, tool calling | GPT-4o | Balanced performance and cost |
| Complex reasoning | GPT-4-turbo | Strong reasoning |
| Fast response, simple tasks | GPT-4o-mini | Fast, cheap |
Google Gemini
{
"agent": {
"model": "google/gemini-2.0-flash"
},
"models": {
"google": {
"apiKey": "${GOOGLE_API_KEY}",
"baseUrl": "https://generativelanguage.googleapis.com/v1beta"
}
}
}
Local Models (Ollama)
{
"agent": {
"model": "ollama/llama3.1:70b"
},
"models": {
"ollama": {
"baseUrl": "http://localhost:11434"
}
}
}
Ollama Installation and Startup:
# Install Ollama
curl -fsSL https://ollama.com/install.sh | sh
# Download models
ollama pull llama3.1:70b
ollama pull codellama:34b
# Start service
ollama serve
Third-Party API Proxy
{
"agent": {
"model": "anthropic/claude-opus-4-6"
},
"models": {
"anthropic": {
"apiKey": "${PROVIDER_API_KEY}",
"baseUrl": "https://api.your-provider.com/v1"
}
}
}
Model Format Reference
Model Identifier Format
{provider}/{model-name}
| Example | Description |
|---|---|
anthropic/claude-opus-4-6 |
Anthropic Claude Opus 4.6 |
openai/gpt-4o |
OpenAI GPT-4o |
google/gemini-2.0-flash |
Google Gemini 2.0 Flash |
ollama/llama3.1:70b |
Ollama Llama 3.1 70B |
Custom Model Aliases
{
"models": {
"aliases": {
"smart": "anthropic/claude-opus-4-6",
"fast": "anthropic/claude-sonnet-4",
"cheap": "anthropic/claude-haiku-3.5",
"local": "ollama/llama3.1:70b"
}
},
"agent": {
"model": "smart"
}
}
Using aliases:
# Switch in chat
/model fast
# Or use full name
/model anthropic/claude-sonnet-4
Failover Strategy
What is Failover?
When the primary model is unavailable (e.g., rate limit reached, service outage), automatically switch to a fallback model.
flowchart TB
REQ[Request arrives] --> PRIMARY{Primary available?}
PRIMARY -->|Yes| EXEC1[Use primary]
PRIMARY -->|No| CHECK{Failover condition}
CHECK -->|Rate limit| SECONDARY1[Fallback 1]
CHECK -->|Service outage| SECONDARY2[Fallback 2]
CHECK -->|Timeout| SECONDARY3[Fallback 3]
SECONDARY1 --> EXEC2[Execute request]
SECONDARY2 --> EXEC2
SECONDARY3 --> EXEC2
EXEC1 --> RES[Return result]
EXEC2 --> RES
Configuring Failover
{
"agent": {
"model": "anthropic/claude-opus-4-6"
},
"models": {
"fallback": [
{
"model": "anthropic/claude-sonnet-4",
"condition": "rate_limit"
},
{
"model": "openai/gpt-4o",
"condition": "error"
},
{
"model": "ollama/llama3.1:70b",
"condition": "timeout"
}
]
}
}
Failover Conditions
| Condition | Description | Example Scenario |
|---|---|---|
rate_limit |
Rate limit | API returns 429 |
error |
Any error | Service unavailable, network error |
timeout |
Request timeout | Response too slow |
overloaded |
Service overload | API returns 503 |
always |
Always use | Simple round-robin |
Advanced Failover Configuration
{
"models": {
"fallback": [
{
"model": "anthropic/claude-sonnet-4",
"condition": "rate_limit",
"maxRetries": 3,
"retryDelay": 1000
},
{
"model": "openai/gpt-4o",
"condition": "error",
"maxRetries": 2
},
{
"model": "ollama/llama3.1:70b",
"condition": "always"
}
],
"fallbackPolicy": {
"retryPrimaryAfter": 60000,
"logFallbacks": true,
"notifyUser": true
}
}
}
Scene-Based Model Switching
Switch by Session Type
Use different models for different session types:
{
"agents": {
"defaults": {
"model": "anthropic/claude-sonnet-4"
},
"byChannel": {
"telegram": {
"model": "anthropic/claude-haiku-3.5"
},
"discord": {
"model": "anthropic/claude-sonnet-4"
}
},
"bySessionType": {
"main": {
"model": "anthropic/claude-opus-4-6"
},
"group": {
"model": "anthropic/claude-haiku-3.5"
}
}
}
}
Switch by Task Type
{
"agents": {
"taskModels": {
"code": "anthropic/claude-opus-4-6",
"reasoning": "anthropic/claude-opus-4-6",
"chat": "anthropic/claude-sonnet-4",
"simple": "anthropic/claude-haiku-3.5"
}
}
}
Dynamic Model Selection
Switch models at runtime:
# CLI switch
openclaw agent --model anthropic/claude-opus-4-6 --message "Complex task"
# Switch in chat
/model anthropic/claude-opus-4-6
Now using Claude Opus 4.6, suitable for complex reasoning
/model anthropic/claude-haiku-3.5
Switched to Haiku 3.5, fast response for simple tasks
Cost Optimization Strategies
Model Cost Comparison
| Model | Input Cost | Output Cost | Use Case |
|---|---|---|---|
| Claude Opus 4.6 | $15/1M | $75/1M | Complex reasoning, important decisions |
| Claude Sonnet 4 | $3/1M | $15/1M | Daily tasks, balanced choice |
| Claude Haiku 3.5 | $0.80/1M | $4/1M | Simple tasks, high-frequency calls |
| GPT-4o | $5/1M | $15/1M | Tool calling, multimodal |
| GPT-4o-mini | $0.15/1M | $0.6/1M | Fast response, simple tasks |
| Gemini Flash | $0.075/1M | $0.3/1M | Cost-sensitive, high-frequency |
Cost Optimization Configuration
{
"agents": {
"defaults": {
"model": "anthropic/claude-sonnet-4",
"costOptimization": {
"enabled": true,
"rules": [
{
"condition": "context_length > 50000",
"model": "anthropic/claude-sonnet-4"
},
{
"condition": "simple_query",
"model": "anthropic/claude-haiku-3.5"
},
{
"condition": "code_generation",
"model": "anthropic/claude-opus-4-6"
}
]
}
}
}
}
Token Usage Monitoring
# View current session usage
/status
# Output example:
# Session: main
# Model: anthropic/claude-opus-4-6
# Tokens: 12,345 input / 2,456 output
# Cost: $0.21
# Enable usage display
/usage full
Usage Display Configuration
{
"usageTracking": {
"enabled": true,
"showInResponse": true,
"trackBySession": true,
"trackByChannel": true,
"alertThreshold": 10.00
}
}
Thinking Level Configuration
Thinking Level Reference
| Level | Description | Token Usage | Use Case |
|---|---|---|---|
off |
No thinking display | Lowest | Simple tasks |
minimal |
Minimal thinking | Low | Fast response |
low |
Low thinking | Low-Medium | Daily chat |
medium |
Medium thinking | Medium | Balanced choice |
high |
High thinking | High | Complex reasoning |
xhigh |
Maximum thinking | Highest | Most complex tasks |
Configuring Thinking Level
{
"agent": {
"model": "anthropic/claude-opus-4-6",
"thinkingLevel": "high"
}
}
Dynamic Switching
# Switch in chat
/think high
Now using high thinking mode, suitable for complex reasoning
/think minimal
Switched to minimal thinking, fast response
Local Model Configuration Details
Ollama Configuration
{
"agent": {
"model": "ollama/llama3.1:70b"
},
"models": {
"ollama": {
"baseUrl": "http://localhost:11434",
"options": {
"temperature": 0.7,
"num_ctx": 32768,
"num_predict": 4096
}
}
}
}
Recommended Local Models
| Model | Parameters | Memory | Characteristics |
|---|---|---|---|
| Llama 3.1 8B | 8B | 8GB | Lightweight, fast |
| Llama 3.1 70B | 70B | 48GB | Strong reasoning |
| CodeLlama 34B | 34B | 24GB | Code-focused |
| Qwen 2.5 72B | 72B | 48GB | Multilingual |
| Mistral Large | 123B | 80GB | Strongest open-source |
Hardware Recommendations
| Model Size | CPU | GPU | RAM |
|---|---|---|---|
| 7B-8B | 8+ cores | 8GB VRAM | 16GB |
| 13B-14B | 12+ cores | 16GB VRAM | 32GB |
| 30B-34B | 16+ cores | 24GB VRAM | 48GB |
| 70B+ | 32+ cores | 48GB+ VRAM | 128GB |
Multi-Provider Load Balancing
Round-Robin Strategy
{
"models": {
"loadBalancing": {
"strategy": "round_robin",
"providers": [
{
"model": "anthropic/claude-sonnet-4",
"weight": 1
},
{
"model": "openai/gpt-4o",
"weight": 1
}
]
}
}
}
Weighted Strategy
{
"models": {
"loadBalancing": {
"strategy": "weighted",
"providers": [
{
"model": "anthropic/claude-sonnet-4",
"weight": 70
},
{
"model": "openai/gpt-4o",
"weight": 20
},
{
"model": "ollama/llama3.1:70b",
"weight": 10
}
]
}
}
}
Cost-Based Strategy
{
"models": {
"loadBalancing": {
"strategy": "cost_optimized",
"dailyBudget": 10.00,
"providers": [
{
"model": "anthropic/claude-opus-4-6",
"maxBudget": 5.00,
"useFor": ["complex", "reasoning"]
},
{
"model": "anthropic/claude-sonnet-4",
"maxBudget": 3.00,
"useFor": ["chat", "code"]
},
{
"model": "anthropic/claude-haiku-3.5",
"maxBudget": 2.00,
"useFor": ["simple", "high_frequency"]
}
]
}
}
}
Model Configuration Best Practices
1. Layer by Scenario
{
"agents": {
"defaults": {
"model": "anthropic/claude-sonnet-4",
"thinkingLevel": "medium"
},
"byUseCase": {
"coding": {
"model": "anthropic/claude-opus-4-6",
"thinkingLevel": "high"
},
"chat": {
"model": "anthropic/claude-haiku-3.5",
"thinkingLevel": "minimal"
},
"research": {
"model": "anthropic/claude-opus-4-6",
"thinkingLevel": "xhigh"
}
}
}
}
2. Set Reasonable Budget
{
"budget": {
"daily": 20.00,
"weekly": 100.00,
"monthly": 400.00,
"alertThreshold": 0.8,
"hardLimit": true
}
}
3. Monitor and Analyze
{
"analytics": {
"trackUsage": true,
"trackCosts": true,
"trackPerformance": true,
"exportPath": "~/.openclaw/analytics",
"retentionDays": 30
}
}
4. Test and Validate
# Test model connection
openclaw doctor --check models
# Test specific model
openclaw agent --model anthropic/claude-opus-4-6 --message "Test message"
# Compare model responses
openclaw benchmark --models "anthropic/claude-opus-4-6,openai/gpt-4o" --prompt "Complex question"
Troubleshooting
Model Connection Failed
# Check API Key
openclaw config get models.anthropic.apiKey
# Test connection
curl -X POST https://api.anthropic.com/v1/messages \
-H "x-api-key: $ANTHROPIC_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "claude-sonnet-4", "max_tokens": 10, "messages": [{"role": "user", "content": "hi"}]}'
# Check network
ping api.anthropic.com
Rate Limiting
# View usage
openclaw usage --today
# Output example:
# Date: 2026-02-26
# Total tokens: 123,456
# Cost: $1.23
# Requests: 89
# Configure rate limit handling
openclaw config set models.anthropic.rateLimitHandling auto_retry
Local Model Issues
# Check Ollama service
curl http://localhost:11434/api/tags
# Check if model is loaded
ollama list
# Manually load model
ollama run llama3.1:70b
# Check GPU usage
nvidia-smi
Summary
Multi-model configuration is one of OpenClaw’s powerful features:
- Flexible switching: Choose the right model for each task
- Failover protection: Automatically handle model unavailability
- Cost optimization: Allocate budget wisely, avoid waste
- Local support: Use local models for privacy-sensitive scenarios
With proper model configuration, you can find the best balance between performance, cost, and privacy.
Article Summary:
- Mastered configuration for multiple model providers
- Understood Failover strategy and configuration
- Learned scene-based dynamic model switching
- Explored cost optimization and monitoring
- Mastered local model configuration and usage
Changelog:
- 2026-02-26: Initial release, based on OpenClaw v2026.2
Series Navigation:
- ← Previous: Gateway Core Concepts Explained
- → Next: Skills System Explained