All Models
Full support for all Claude models including Sonnet and Haiku 4-5
All Endpoints
/messages, count-tokens and more fully supportedMulti-Provider Support
Use Claude from Anthropic, Bedrock, and Vertex with native SDK support
Quick Start
Get Anthropic working in 3 steps:Tip: You can also set
provider="@anthropic" in Portkey() and use just model="claude-sonnet-4-5-20250929" in the request.max_tokensis required - Always specify this parameter- System prompts - Handled differently (see System Prompts section below)
- Model naming - Use full model names like
claude-sonnet-4-5-20250929
Add Provider in Model Catalog
- Go to Model Catalog → Add Provider
- Select Anthropic
- Choose existing credentials or create new by entering your Anthropic API key
- Name your provider (e.g.,
anthropic-prod)
Complete Setup Guide →
See all setup options, code examples, and detailed instructions
Basic Usage
Chat Completions
System Prompts
Anthropic handles system prompts differently than OpenAI. With Portkey, you can use the OpenAI-compatible format:Streaming
Streaming works the same as OpenAI:Advanced Features
Vision (Multimodal)
Portkey supports Anthropic’s vision models includingclaude-sonnet-4-5-20250929, claude-3-5-sonnet, claude-3-haiku, claude-3-opus, and claude-3.7-sonnet. Use the same format as OpenAI:
Anthropic only accepts base64-encoded images and does not support image URLs. Use the same base64 format to send images to both Anthropic and OpenAI models.
To prompt with PDFs, update the
url field to: data:application/pdf;base64,BASE64_PDF_DATAPDF Support
Anthropic Claude processes PDFs to extract text, analyze charts, and understand visual content. PDF support is available on:- Claude 3.7 Sonnet (
claude-3-7-sonnet-20250219) - Claude 3.5 Sonnet (
claude-3-5-sonnet-20241022,claude-3-5-sonnet-20240620) - Claude Sonnet 4-5 (
claude-sonnet-4-5-20250929) - Claude 3.5 Haiku (
claude-3-5-haiku-20241022)
- Maximum request size: 32MB
- Maximum pages per request: 100
- Format: Standard PDF (no passwords/encryption)
Extended Thinking (Reasoning Models)
Models likeclaude-3-7-sonnet-latest support extended thinking. Get the model’s reasoning as it processes the request.
The assistant’s thinking response is returned in the
response_chunk.choices[0].delta.content_blocks array, not the response.choices[0].message.content string.strict_open_ai_compliance=False to use this feature:
Using /messages Route
Portkey supports Anthropic’s/messages endpoint, allowing you to use either Anthropic’s native SDK or Portkey’s SDK with full gateway features.
Using Anthropic’s Native SDK
Using Portkey’s SDK
cURL
You can use all Portkey features (like caching, observability, configs) with this route. Just add the
x-portkey-config, x-portkey-provider, x-portkey-... headers.Prompt Caching
Portkey works with Anthropic’s prompt caching feature to save time and money. Refer to this guide:Prompt Caching
Learn how to enable prompt caching for Anthropic requests
Web Search
Anthropic Claude models support web search as a tool, allowing the model to search the web for up-to-date information.Set
strict_open_ai_compliance to false (or use the header x-portkey-strict-open-ai-compliance: false) to receive citations in the response.Beta Features
Portkey supports Anthropic’s beta features through headers. Pass the beta feature name as the value:Managing Anthropic Prompts
Manage all prompt templates to Anthropic in the Prompt Library. All current Anthropic models are supported, and you can easily test different prompts. Use theportkey.prompts.completions.create interface to use the prompt in an application.
Next Steps
Add Metadata
Add metadata to your Anthropic requests
Gateway Configs
Add gateway configs to your Anthropic requests
Tracing
Trace your Anthropic requests
Fallbacks
Setup fallback from OpenAI to Anthropic
SDK Reference
Complete Portkey SDK documentation

