What are Plugins?
A plugin extends Genkit by registering new actions (models, tools, retrievers, etc.) and providing configuration for external services. Plugins can:- Provide AI models: Gemini, Claude, GPT, Llama, etc.
- Add telemetry: Cloud Trace, Datadog, Sentry, etc.
- Enable vector search: Pinecone, Chroma, Vertex AI Vector Search
- Add safety checks: Content filtering, PII detection
- Integrate frameworks: Express, Flask, FastAPI
- Register custom tools: Any function you want models to call
Using Plugins
Plugin Architecture
All plugins implement the same interface:Plugin Lifecycle
Plugins follow a four-phase lifecycle:1. Registration
Plugins are registered when you create a Genkit instance:2. Lazy Initialization
Plugins are initialized only when first used:- Registry calls
plugin.init() - Plugin returns pre-registered actions
- Actions are cached in registry
- Subsequent calls use cached actions (no re-init)
3. Action Resolution
When you reference an action by name:- Check cache - already resolved?
- If namespaced (
googleai/...), find that plugin - Call
plugin.resolve(ActionKind.MODEL, 'googleai/gemini-2.0-flash') - Cache and return the action
4. Action Discovery
The Developer UI queries plugins without initializing them:Official Plugins
Model Providers
| Plugin | Models | Installation |
|---|---|---|
| Google AI | Gemini, Imagen, Veo, Lyria, TTS | npm i @genkit-ai/google-genaipip install genkit[google-genai] |
| Anthropic | Claude 3.5 Sonnet, Claude 3 Opus | npm i @genkit-ai/anthropicpip install genkit[anthropic] |
| Vertex AI | Model Garden (1000+ models) | npm i @genkit-ai/vertexaipip install genkit[vertexai] |
| Ollama | Llama, Mistral, CodeLlama (local) | npm i @genkit-ai/ollamapip install genkit[ollama] |
| OpenAI-compatible | Any OpenAI-compatible API | npm i @genkit-ai/compat-oaipip install genkit[compat-oai] |
| Mistral AI | Mistral, Mixtral models | npm i @genkit-ai/mistralpip install genkit[mistral] |
| DeepSeek | DeepSeek models | npm i @genkit-ai/deepseekpip install genkit[deepseek] |
| xAI | Grok models | npm i @genkit-ai/xaipip install genkit[xai] |
Telemetry & Observability
| Plugin | Purpose | Installation |
|---|---|---|
| Google Cloud | Cloud Trace + Cloud Logging | npm i @genkit-ai/google-cloudpip install genkit[google-cloud] |
| Firebase | Firebase telemetry + Auth | npm i @genkit-ai/firebasepip install genkit[firebase] |
| Observability | Sentry, Datadog, Honeycomb | npm i @genkit-ai/observabilitypip install genkit[observability] |
Vector Stores
| Plugin | Purpose | Installation |
|---|---|---|
| Vertex AI Vector Search | Production vector DB | npm i @genkit-ai/vertexaipip install genkit[vertexai] |
| Pinecone | Vector search | npm i @genkit-ai/pinecone |
| Chroma | Local vector DB | npm i @genkit-ai/chroma |
| Dev Local Vector Store | Development/testing | npm i @genkit-ai/dev-local-vectorstorepip install genkit[dev-local-vectorstore] |
Safety & Evaluation
| Plugin | Purpose | Installation |
|---|---|---|
| Checks | Content safety guardrails | npm i @genkit-ai/checkspip install genkit[checks] |
| Evaluators | RAGAS metrics, custom evals | npm i @genkit-ai/evaluatorspip install genkit[evaluators] |
Framework Integration
| Plugin | Purpose | Installation |
|---|---|---|
| Express | Node.js HTTP server | npm i @genkit-ai/express |
| Flask | Python HTTP server | pip install genkit[flask] |
| Next.js | Next.js integration | npm i @genkit-ai/next |
Community Plugins
Community-maintained plugins (best-effort support):- Amazon Bedrock: Claude, Llama, Titan + AWS X-Ray telemetry
- Azure AI: Azure Monitor telemetry
- Cloudflare Workers AI: Edge AI models + OTLP telemetry
- Cohere: Command models + reranking
- HuggingFace: Inference API models
- Microsoft Foundry: Azure AI Foundry (11,000+ models)
Plugin Configuration
Most plugins accept configuration options:Environment Variables
Most plugins support environment variable configuration:Creating Custom Plugins
Basic Plugin
Create a custom plugin to add your own models or tools:Plugin with Multiple Action Types
Plugin Namespaces
Each plugin has a namespace that prefixes its actions:googleai/gemini-2.0-flash- plugin:googleai, model:gemini-2.0-flashanthropic/claude-3-5-sonnet- plugin:anthropic, model:claude-3-5-sonnetmyplugin/my-model- plugin:myplugin, model:my-model
Plugin Discovery
The Developer UI useslist_actions() to discover available actions:
list_actions()must be fast - no expensive operations- Does NOT trigger
init()- plugins remain uninitialized - Only returns metadata, not full action objects
Dynamic Action Providers
For actions that are discovered at runtime (like MCP servers):Combining Multiple Plugins
Use multiple plugins together:Plugin Best Practices
1. Lazy Initialization
Defer expensive operations toinit(), not __init__():
2. Fast Action Listing
list_actions() must be fast - no API calls:
3. Graceful Degradation
Handle missing API keys gracefully:4. Clear Error Messages
Provide helpful errors when things go wrong:Example: Complete Custom Plugin
A complete weather plugin:Next Steps
- Learn about Architecture - how plugins fit into Genkit
- Explore Models - using model provider plugins
- See Observability - telemetry plugins