This document provides a high-level introduction to Firebase Genkit, explaining its purpose as a multi-language framework for building generative AI applications. It covers the core architecture, abstractions, plugin ecosystem, and repository structure.
For detailed information about specific subsystems:
Firebase Genkit is an open-source framework for building, deploying, and monitoring production-grade AI-powered applications. It provides a unified interface across multiple programming languages (JavaScript/TypeScript, Go, and Python) for interacting with various AI models, managing conversational flows, implementing retrieval-augmented generation (RAG), and deploying to cloud platforms.
Genkit abstracts away the complexity of working with different AI providers (Google AI, Vertex AI, Anthropic, Ollama, etc.) through a plugin-based architecture, while providing built-in observability, testing tools, and type-safe interfaces.
Key Features:
Sources: js/genkit/package.json1-10 js/core/package.json1-10 js/ai/package.json1-10
Genkit is implemented as three separate SDKs that share common design patterns and core abstractions. Each SDK is optimized for its target language while maintaining API consistency.
JavaScript/TypeScript SDK Structure:
| Package | Purpose | Location |
|---|---|---|
@genkit-ai/core | Core registry, tracing, logging, schema system | js/core/ |
@genkit-ai/ai | AI-specific abstractions (models, embedders, retrievers) | js/ai/ |
genkit | Main entry point combining core and AI packages | js/genkit/ |
Go SDK Structure:
| Package | Purpose | Location |
|---|---|---|
go/core | Core action, flow, registry, tracing implementations | go/core/ |
go/ai | AI generation, prompt, tool, model implementations | go/ai/ |
go/genkit | Main package combining core and AI functionality | go/genkit/ |
Python SDK Structure:
| Package | Purpose | Location |
|---|---|---|
genkit-ai | Main Python package with core and AI features | python/genkit-ai/ |
dotprompt | Template engine for prompts | python/dotprompt/ |
handlebarz | Handlebars-style template helpers | python/handlebarz/ |
Sources: js/core/package.json1-30 js/ai/package.json1-30 js/genkit/package.json1-30
Genkit's architecture is built around several key abstractions that work together to enable AI application development. These abstractions are implemented consistently across all SDKs.
Core Abstraction Details:
| Abstraction | Purpose | JavaScript Export | Key Concepts |
|---|---|---|---|
| Action | Base unit of work with input/output schemas | @genkit-ai/core | Registry key, middleware, tracing |
| Flow | Orchestrated sequence of actions with state | @genkit-ai/core | Streaming, interrupts, resumability |
| Model | Interface to AI model providers | @genkit-ai/ai/model | Generation, tool calling, streaming |
| Prompt | Templated model inputs with variable substitution | @genkit-ai/ai (DotPrompt) | Rendering, execution, history |
| Tool | Functions callable by models | @genkit-ai/ai/tool | Schema definition, execution |
| Embedder | Convert text to vector embeddings | @genkit-ai/ai/embedder | Dimensionality, batch processing |
| Retriever | Query-based document retrieval | @genkit-ai/ai/retriever | Similarity search, metadata filtering |
| Reranker | Reorder retrieval results by relevance | @genkit-ai/ai/reranker | Scoring, optimization |
| Evaluator | Assess AI output quality | @genkit-ai/ai/evaluator | Metrics, scoring, datasets |
Sources: js/ai/package.json52-131 js/core/package.json62-106
Genkit's functionality is extended through a rich plugin ecosystem. Plugins register new models, embedders, retrievers, and other components with the central registry.
Official Plugin Catalog (JavaScript/TypeScript):
| Plugin Package | Type | Purpose |
|---|---|---|
@genkit-ai/googleai | Model Provider | Gemini models via Google AI API |
@genkit-ai/vertexai | Model Provider | Gemini, Imagen, embeddings via Vertex AI |
genkitx-ollama | Model Provider | Local models via Ollama |
genkitx-chromadb | Vector Store | ChromaDB integration for RAG |
genkitx-pinecone | Vector Store | Pinecone vector database integration |
@genkit-ai/dev-local-vectorstore | Vector Store | In-memory vector store for development |
@genkit-ai/firebase | Cloud Platform | Firestore trace/state store, Cloud Functions deployment |
@genkit-ai/google-cloud | Cloud Platform | Cloud Trace, Cloud Monitoring, Model Armor |
@genkit-ai/evaluator | Evaluation | Built-in evaluators (DeepEqual, Regex, JSONata) |
Plugin Initialization Pattern:
Plugins are initialized during application startup and register their components with the global registry:
Sources: js/plugins/googleai/package.json1-20 js/plugins/vertexai/package.json1-20 js/plugins/firebase/package.json1-20 js/plugins/google-cloud/package.json1-20 js/plugins/chroma/package.json1-20 js/plugins/pinecone/package.json1-20 js/plugins/dev-local-vectorstore/package.json1-20 js/plugins/ollama/package.json1-20 js/plugins/evaluators/package.json1-20
Genkit integrates OpenTelemetry for distributed tracing, metrics collection, and structured logging. All actions, flows, and model calls are automatically instrumented.
Observability Integration:
| Component | Package | Purpose |
|---|---|---|
| OpenTelemetry API | @opentelemetry/api | Standard tracing/metrics interface |
| OTel SDK | @opentelemetry/sdk-node | OpenTelemetry implementation |
| Cloud Trace Exporter | @google-cloud/opentelemetry-cloud-trace-exporter | Export traces to GCP |
| Cloud Monitoring Exporter | @google-cloud/opentelemetry-cloud-monitoring-exporter | Export metrics to GCP |
| Telemetry Server | @genkit-ai/telemetry-server | Local development UI |
Automatic Instrumentation:
All Genkit components emit telemetry automatically:
Sources: js/core/package.json28-35 js/plugins/google-cloud/package.json33-51
The Genkit repository is a monorepo containing all SDKs, plugins, and tooling.
Directory Structure:
| Path | Purpose |
|---|---|
js/core/ | Core JavaScript framework (registry, tracing, schema) |
js/ai/ | AI-specific JavaScript abstractions |
js/genkit/ | Main JavaScript package entry point |
js/plugins/ | Official JavaScript plugins |
go/core/ | Core Go framework |
go/ai/ | AI-specific Go abstractions |
go/genkit/ | Main Go package |
go/plugins/ | Official Go plugins |
python/genkit-ai/ | Main Python package |
python/dotprompt/ | Python prompt templating |
python/plugins/ | Official Python plugins |
genkit-cli/ | Command-line interface tool |
genkit-tools/telemetry-server/ | Local development telemetry UI |
Build System:
Sources: js/core/package.json22-26 js/ai/package.json22-26 js/genkit/package.json22-26
To begin using Genkit, developers typically:
For detailed installation and setup instructions, see Getting Started.
For information about configuring specific features:
Quick Example (JavaScript):
Sources: js/genkit/package.json1-60
Refresh this wiki
This wiki was recently refreshed. Please wait 2 days to refresh again.