Skip to main content
The Anthropic provider gives you access to Claude models, known for their advanced reasoning, long context windows, and safety features. Claude excels at complex analysis, extended thinking, and providing accurate citations.

Installation

Setup

Get an API Key

  1. Sign up at Anthropic Console
  2. Navigate to API Keys
  3. Create a new API key
  4. 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
All Claude models support:
  • 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:
Supported Document Types:
  • 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)
All documents in a request must have citations enabled or disabled - you cannot mix.

Prompt Caching

Reduce costs by caching large prompts:
You can specify custom TTL:
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
claude-opus-4-5:
  • Most complex reasoning tasks
  • Research requiring highest accuracy
  • Legal or medical analysis
  • When quality is paramount
claude-haiku-4-5:
  • 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:
This is useful for:
  • 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

Solution:
Or pass explicitly:

Rate Limiting

If you exceed rate limits:

Context Length Exceeded

Solution: Reduce prompt size or split into multiple requests.

Best Practices

  1. Use environment variables for API keys
  2. Enable thinking for complex reasoning tasks
  3. Use citations when factual accuracy is critical
  4. Cache large prompts to reduce costs
  5. Choose the right model - Haiku for speed, Sonnet for balance, Opus for quality
  6. Implement retry logic for rate limits
  7. 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 maxOutputTokens limits
  • Use streaming to allow early termination
See Anthropic Pricing for latest rates.

Next Steps