Overview
The Anthropic provider enables ZeroClaw to use Claude models via the Anthropic API. It supports both API key authentication and OAuth setup tokens. Provider ID:anthropic
Base URL: https://api.anthropic.com
API Version: 2023-06-01
Authentication
Environment Variables
Credentials are resolved in the following order:ANTHROPIC_API_KEY- Standard API keyANTHROPIC_OAUTH_TOKEN- Setup token (OAuth)- Generic fallback:
ZEROCLAW_API_KEYorAPI_KEY
Setup Token (OAuth)
Setup tokens use the formatsk-ant-oat01-* and require special headers:
Authorization: Bearer <token>anthropic-beta: oauth-2025-04-20
API Key
Standard API keys use the formatsk-ant-api* and send:
x-api-key: <key>
Configuration
Config File
Custom Base URL
For proxy or custom endpoints:Features
Native Tool Calling
Supported: Yes The provider converts ZeroClaw’s tool definitions to Anthropic’s native format:Vision Support
Supported: Yes Images are sent as base64-encoded inline data:Prompt Caching (Automatic)
Enabled by default for cost optimization.System Prompt Caching
System prompts larger than 3KB (approximately 1024 tokens) are automatically cached:Conversation Caching
Conversations with more than 4 non-system messages automatically cache the last message:Tool Definition Caching
When tools are provided, the last tool definition is automatically cached:Token Usage Tracking
Supported: Yes Usage data is extracted from response:API Endpoints
Chat Completion
Endpoint:POST /v1/messages
Request:
Request Configuration
Max Tokens
Default: 4096 Fixed in the provider implementation. Use model-specific limits for production.Temperature
Range: 0.0 - 2.0 Default: 0.7 (from config) Controls response randomness.Timeouts
- Request timeout: 120 seconds
- Connection timeout: 10 seconds
Message Format
System Prompt
Sent as top-levelsystem field:
User Messages
Simple text:Assistant Messages
Text only:Tool Results
Sent as user message with tool_result blocks:Stop Reasons
Normalized stop reasons:| Anthropic | ZeroClaw Normalized |
|---|---|
end_turn | EndTurn |
max_tokens | MaxTokens |
stop_sequence | StopSequence |
tool_use | ToolUse |
Error Handling
Authentication Errors
Rate Limiting
HTTP 429 responses include retry information in headers. ZeroClaw’s quota adapter automatically extracts rate limit metadata.API Errors
Error responses are sanitized before display:Provider Capabilities
Warmup
Supported: Yes Sends a minimal request to establish TLS and HTTP/2 connections:Example Usage
Simple Chat
With Tools
With Vision
Limitations
- Max tokens is fixed at 4096 (not configurable per request)
- Only ephemeral cache type is supported
- System prompt is consolidated (multiple system messages merge)
- Image format auto-detection from base64 data URI