Anthropic Plugin
The@genkit-ai/anthropic plugin provides access to Anthropic’s Claude models, including the latest Claude 4.5 series (Haiku, Sonnet, Opus). This plugin is now officially maintained by Google and supersedes the earlier community package genkitx-anthropic.
Installation
Supported Models
The plugin supports the most recent Anthropic models:- Claude Haiku 4.5 (
claude-haiku-4-5) - Fast, cost-effective - Claude Sonnet 4.5 (
claude-sonnet-4-5) - Balanced performance - Claude Opus 4.5 (
claude-opus-4-5) - Most capable
Basic Setup
Initialize the Plugin
Simple Text Generation
Features
Multi-modal Prompts
Claude supports text and image inputs:Extended Thinking
Claude 4.5 models can expose their internal reasoning process:- Request bodies include the
thinkingpayload - Streamed responses deliver
reasoningparts incrementally - You can render the chain-of-thought as it arrives
Document Citations
Claude can cite specific parts of documents, making it easy to trace information sources. Use theanthropicDocument() helper:
text- Plain text (returnschar_locationcitations)base64- Base64-encoded PDFs (returnspage_locationcitations)url- PDFs via URL (returnspage_locationcitations)content- Custom content blocks (returnscontent_block_locationcitations)file- Anthropic Files API references, beta only (returnspage_locationcitations)
Prompt Caching
Cache prompts to reduce costs and latency for repeated requests:Using in Flows
Direct Model Usage (Plugin API v2)
The plugin supports using models directly without initializing the full Genkit framework:- Framework developers needing raw model access
- Testing models in isolation
- Using Genkit models in non-Genkit applications
Beta API Limitations
The beta API provides access to experimental features, but some server-managed tool blocks are not yet supported: Not supported:web_fetch_tool_resultcode_execution_tool_resultbash_code_execution_tool_resulttext_editor_code_execution_tool_resultmcp_tool_resultmcp_tool_usecontainer_upload
server_tool_use✅web_search_tool_result✅
Configuration Options
Plugin Options
Model Config
Best Practices
Model Selection
- Claude Haiku 4.5 - Use for fast, cost-effective tasks
- Claude Sonnet 4.5 - Best for most production use cases
- Claude Opus 4.5 - Use for complex reasoning and research
Error Handling
Streaming Responses
Acknowledgements
This plugin builds on community work published asgenkitx-anthropic by Bloom Labs Inc. Their Apache 2.0-licensed implementation provided the foundation for this maintained package.