Configuration
TheAnthropicHandler accepts the following options:
string
required
Your Anthropic API key. Get one from Anthropic Console
string
Custom base URL for API requests. Defaults to Anthropic’s production API
string
required
Claude model to use. Examples:
claude-4.5-sonnet-20250514claude-sonnet-4-20250514claude-opus-4-20250514claude-3-5-sonnet-20241022
number
default:"0"
Token budget for extended thinking. Set to
0 to disable thinking.Recommended values:- Light tasks: 2000-5000 tokens
- Medium tasks: 5000-10000 tokens
- Complex tasks: 10000-24000 tokens
function
Callback invoked when retrying failed requests
Basic Setup
Extended Thinking
Claude models support extended thinking for complex reasoning tasks:Thinking Modes
Redacted Thinking
Some thinking blocks may be redacted (encrypted):Prompt Caching
The handler automatically enables prompt caching for supported models:Cache Strategy
The handler implements this caching strategy fromanthropic.ts:74-80:
- System prompt marked with
cache_control: { type: "ephemeral" } - New tasks can reuse cached system prompt
- Cache breakpoints set at end of system prompt
- Reduces token usage on subsequent requests
Tool Calling
Tool Use Constraints
Fromanthropic.ts:84-90:
1M Context Window
Enable the experimental 1M context window:Streaming Response
The handler processes these Anthropic stream events:message_start
content_block_start
content_block_delta
Error Handling
The handler includes automatic retry logic:Custom Error Handling
Model Information
Implementation Reference
Source:~/workspace/source/src/core/api/providers/anthropic.ts
Key methods:
ensureClient()- Creates Anthropic SDK client with proxy supportcreateMessage()- Streams responses with thinking/caching/toolsgetModel()- Returns model ID and metadata
Next Steps
OpenAI Provider
Configure OpenAI models
OpenRouter Provider
Access multiple providers
Provider Overview
View all providers
Custom Provider
Build your own