Installation
Setup
Get an API Key
- Sign up at Anthropic Console
- Navigate to API Keys
- Create a new API key
- Set it as an environment variable:
Configure the Plugin
Available Models
Anthropic offers the Claude model family in three tiers:Claude 4.5 (Latest)
- claude-sonnet-4-5 - Most powerful, balanced performance and intelligence
- claude-opus-4-5 - Highest intelligence for complex tasks
- claude-haiku-4-5 - Fastest, most cost-effective
Claude 4
- claude-sonnet-4 - Previous generation Sonnet
- claude-opus-4 - Previous generation Opus
Claude 3.5
- claude-3-5-haiku - Fast and lightweight
- claude-3-5-sonnet - Balanced (older version)
Claude 3
- claude-3-haiku - Budget-friendly option
- Multi-turn conversations (200K+ token context)
- Vision (images)
- Function calling (tools)
- System instructions
- JSON mode
Usage Examples
Basic Text Generation
Extended Thinking
Claude 4 models can expose their internal reasoning process:Extended thinking is only available on Claude 4+ models and requires additional tokens.
Document Citations
Claude can cite specific parts of documents you provide:text- Plain text (returns character locations)base64- Base64-encoded PDFs (returns page numbers)url- PDFs from URLs (returns page numbers)content- Custom content blocks (returns block indices)
Prompt Caching
Reduce costs by caching large prompts:Caching only activates when prompts exceed minimum token thresholds (see Anthropic docs).
Vision (Image Analysis)
Streaming Responses
Function Calling
JSON Output Mode
Using in a Flow
Configuration Options
Model Parameters
API Version
Specify a specific Anthropic API version:Model Selection Guide
When to Use Each Model
claude-sonnet-4-5 (recommended default):- Most tasks requiring intelligence and speed
- Research and analysis
- Content generation
- Code assistance
- Best balance of performance and cost
- Most complex reasoning tasks
- Research requiring highest accuracy
- Legal or medical analysis
- When quality is paramount
- Simple queries
- High-volume applications
- Real-time chat
- Cost-sensitive use cases
Direct Model Usage (Without Genkit Instance)
You can use Claude models directly without initializing Genkit:- Framework developers needing raw model access
- Testing models in isolation
- Using Genkit models in non-Genkit applications
Key Features
Long Context Windows
Claude models support 200K+ tokens of context:Constitutional AI
Claude is trained with Constitutional AI for:- Helpful, harmless, and honest responses
- Better refusal of harmful requests
- More nuanced understanding of ethics
Advanced Reasoning
Claude excels at:- Multi-step reasoning
- Logical deduction
- Mathematical proofs
- Code analysis
- Research synthesis
Troubleshooting
API Key Not Found
Rate Limiting
If you exceed rate limits:Context Length Exceeded
Best Practices
- Use environment variables for API keys
- Enable thinking for complex reasoning tasks
- Use citations when factual accuracy is critical
- Cache large prompts to reduce costs
- Choose the right model - Haiku for speed, Sonnet for balance, Opus for quality
- Implement retry logic for rate limits
- Stream long responses for better UX
Pricing
Anthropic pricing is based on token usage:
Cost Optimization:
- Use Haiku for simple tasks
- Enable prompt caching for repeated prompts
- Set appropriate
maxOutputTokenslimits - Use streaming to allow early termination