Advanced Claude API Integration
/** Route complex reasoning tasks to Claude 3.5 Sonnet when local models reach their limit. Maintain a "Hybrid-First" workflow. */
The 'Hybrid-First' Philosophy
OpenClaw is designed to be model-agnostic. While running 100% locally on Ollama is ideal for privacy and cost, certain tasksβlike massive code refactors, complex logical puzzles, or 200K+ token document analysisβrequire the frontier intelligence of Claude 3.5. Our integration focuses on 'Smart Routing': using local models for intent classification and simple automation, while transparently escalating complex payloads to the Anthropic cloud.
π€ When to Use Claude vs. Ollama
π Frontier Model Selection
| Model | Context | Cost / 1M tok | Optimized Usage |
|---|---|---|---|
| claude-3-5-sonnet-20241022 | 200K | $3 in / $15 out | The Gold Standard for coding and reasoning β |
| claude-3-5-haiku-20241022 | 200K | $0.80 / $4 | Ultra-fast, cheaper than GPT-4o-mini |
| claude-3-opus-20240229 | 200K | $15 / $75 | Highest capability, maximum nuance |
Pro Feature: Prompt Caching
For repetitive tasks (like asking questions about the same large PDF), OpenClaw automatically enables Anthropic's Prompt Caching. This reduces your API costs by up to 90% and cuts latency by 50% for sequential queries on the same context.
βοΈ config.yaml Configuration
π‘// π‘ Pro Tip: Set 'max_tokens' to 8192 for Sonnet to enable the extended output window.