Overview
Anthropic develops Claude, a family of highly capable AI assistants known for their strong performance, safety features, and long context windows. Portkey provides full support for all Claude models and features. Base URL:https://api.anthropic.com/v1
Supported Features
- ✅ Messages API (Chat Completions)
- ✅ Streaming
- ✅ Tool Use (Function Calling)
- ✅ Vision (Image inputs)
- ✅ System Prompts
- ✅ Token Counting
- ✅ Batch API
- ✅ Prompt Caching
- ❌ Embeddings (not available)
- ❌ Fine-tuning (not available)
Quick Start
Chat Completions
Streaming Responses
Available Models
| Model | Context Window | Description | Best For |
|---|---|---|---|
claude-3-5-sonnet-20241022 | 200K tokens | Latest, most capable model | Complex tasks, coding, analysis |
claude-3-5-haiku-20241022 | 200K tokens | Fastest Claude 3.5 model | Quick responses, high throughput |
claude-3-opus-20240229 | 200K tokens | Most powerful Claude 3 | Highly complex tasks |
claude-3-sonnet-20240229 | 200K tokens | Balanced performance | General purpose |
claude-3-haiku-20240307 | 200K tokens | Fastest, most compact | Simple tasks, cost-effective |
Claude models excel at:
- Long document analysis (200K context)
- Coding and technical tasks
- Thoughtful, nuanced responses
- Following complex instructions
- Refusing unsafe requests
Configuration Options
Headers
| Header | Description | Default | Required |
|---|---|---|---|
Authorization | Anthropic API key | - | Yes |
anthropic_version | API version | 2023-06-01 | No |
anthropic_beta | Beta feature flags | messages-2023-12-15 | No |
Body Parameters
You can also pass these in the request body:Advanced Features
System Prompts
Claude supports powerful system prompts:Tool Use (Function Calling)
Vision (Image Analysis)
Claude 3 models support image inputs:Prompt Caching
Reduce costs by caching frequently used prompts:Token Counting
Count tokens before making a request:Fallback Configuration
Use GPT-4 as fallback for Claude:Load Balancing
Distribute load across different Claude models:Error Handling
Request & Response Format
Request
Response
Best Practices
- Always set max_tokens - Required parameter for Claude
- Use system prompts - Claude responds well to detailed system instructions
- Leverage long context - Claude handles 200K tokens effectively
- Enable prompt caching - Save costs on repeated large contexts
- Use Haiku for speed - When fast responses matter more than complexity
- Implement streaming - For better user experience with long responses
- Add retry logic - Handle rate limits gracefully
Important Differences from OpenAI
| Feature | OpenAI | Anthropic |
|---|---|---|
max_tokens | Optional | Required |
| System messages | In messages array | In messages array |
| Context window | Up to 128K | Up to 200K |
| Embeddings | ✅ Available | ❌ Not available |
| Image generation | ✅ DALL-E | ❌ Not available |
| Audio | ✅ TTS, STT | ❌ Not available |
Pricing
For up-to-date Anthropic pricing:Anthropic Pricing
View detailed pricing for all Claude models
Related Resources
AWS Bedrock
Use Claude through AWS Bedrock
Fallback Routing
Set up fallbacks from Anthropic
Prompt Caching
Reduce costs with caching
Tool Use
Advanced tool use guide