Skip to main content
The Anthropic provider supports all Claude models including Claude 4, Sonnet, Opus, Haiku, and extended thinking.

Configuration

string
required
Set to "anthropic"
string
required
Anthropic API key. Get yours at console.anthropic.com
string
Custom base URL for proxies (defaults to https://api.anthropic.com)
string
required
Model name: claude-sonnet-4, claude-opus-4, etc.
number
Sampling temperature (0.0-1.0). Defaults to 0.7.
number
Maximum output tokens. Defaults to 8192.

Example Configuration

OAuth Setup Tokens

Anthropic supports OAuth setup tokens (from anthropic.com/setup):
OAuth tokens use Bearer authentication instead of x-api-key:

Supported Models

  • Claude 4: claude-sonnet-4, claude-opus-4, claude-haiku-4
  • Claude 3.5: claude-3-5-sonnet-20241022, claude-3-5-haiku-20241022
  • Claude 3: claude-3-opus-20240229, claude-3-sonnet-20240229, claude-3-haiku-20240307
  • Extended thinking: Models with reasoning capabilities (thinking content)

Capabilities

Authentication

The Anthropic provider supports two authentication methods:

1. Standard API Key

2. OAuth Setup Token

API keys are read from:
  1. api_key field in config
  2. ANTHROPIC_API_KEY environment variable

Message Format

Anthropic uses a different message format than OpenAI:
  • System messages go in top-level system field (not in messages array)
  • Roles are user and assistant (tool messages use user role)
  • Messages are objects with role and content

Tool Calls

Anthropic uses a native tool_use content block format:

Vision Support

Claude supports image input via content_parts:

Custom Base URL

For proxies or self-hosted endpoints:
Or use anthropic-custom: prefix:

Code Example

From src/providers/anthropic.zig:

Error Handling

The provider classifies common Anthropic API errors:
  • error.RateLimited — 429 rate limit exceeded
  • error.InvalidApiKey — Authentication failed
  • error.ApiError — Generic API error
  • error.NoResponseContent — Empty response