Anthropic plugin
The Anthropic plugin provides access to Anthropic’s Claude models in Go.
Configuration
Section titled “Configuration”import "github.com/firebase/genkit/go/plugins/anthropic"g := genkit.Init(context.Background(), genkit.WithPlugins(&anthropic.Anthropic{}))You must provide an API key from Anthropic. You can get an API key from the Anthropic Console. The plugin will automatically use the ANTHROPIC_API_KEY environment variable.
Supported Models
Section titled “Supported Models”- claude-sonnet-4-5 - Claude Sonnet 4.5 with extended thinking support
- claude-sonnet-4 - Claude Sonnet 4
- claude-opus-4 - Claude Opus 4
- claude-3-5-haiku - Fast and efficient Claude 3.5 Haiku
- claude-3-haiku - Fastest Claude 3 model
Usage Example
Section titled “Usage Example”import ( "github.com/firebase/genkit/go/plugins/anthropic")
// Initialize Anthropic pluging := genkit.Init(ctx, genkit.WithPlugins(&anthropic.Anthropic{}))
// Use Claude for tasks requiring reasoningmodel := anthropic.Model(g, "claude-sonnet-4-6")resp, err := genkit.Generate(ctx, g, ai.WithModel(model), ai.WithPrompt("Analyze this complex problem step by step."),)Using Multiple Providers
Section titled “Using Multiple Providers”You can use both OpenAI and Anthropic providers in the same application:
import ( "github.com/firebase/genkit/go/plugins/compat_oai/openai" "github.com/firebase/genkit/go/plugins/anthropic")
oai := &openai.OpenAI{APIKey: "YOUR_OPENAI_KEY"}claude := &anthropic.Anthropic{}
g := genkit.Init(ctx, genkit.WithPlugins(oai, claude))
// Use OpenAI for embeddings and tool-heavy tasksopenaiModel := oai.Model(g, "gpt-4o")embedder := oai.Embedder(g, "text-embedding-3-large")
// Use Anthropic for reasoning and analysisclaudeModel := anthropic.Model(g, "claude-sonnet-4-6")Advanced Features
Section titled “Advanced Features”Multimodal Support
Section titled “Multimodal Support”Claude models support vision capabilities:
// Works with Claude modelsresp, err := genkit.Generate(ctx, g, ai.WithModel(model), ai.WithMessages( ai.NewUserMessage( ai.NewTextPart("What do you see in this image?"), ai.NewMediaPart("image/jpeg", imageData), ), ),)Streaming
Section titled “Streaming”Claude models support streaming responses:
resp, err := genkit.Generate(ctx, g, ai.WithModel(model), ai.WithPrompt("Write a long explanation."), ai.WithStreaming(func(ctx context.Context, chunk *ai.ModelResponseChunk) error { for _, content := range chunk.Content { fmt.Print(content.Text) } return nil }),)Configuration
Section titled “Configuration”Anthropic models support specific configuration options provided by the Anthropic SDK:
import "github.com/anthropics/anthropic-sdk-go"
config := &anthropic.MessageNewParams{ Temperature: anthropic.Float(0.7), MaxTokens: anthropic.Int(1000), TopP: anthropic.Float(0.9),}
resp, err := genkit.Generate(ctx, g, ai.WithModel(model), ai.WithPrompt("Your prompt here"), ai.WithConfig(config),)