Genkit is Google’s open-source framework for building full-stack, AI-powered and agentic applications.
It offers a unified interface for integrating AI models from many model providers, so you can use the best models for your needs. Rapidly build and deploy production-ready AI-powered and agentic applications—chatbots, automations, recommendation systems, and more—using streamlined APIs for multimodal content, structured outputs, tool calling, and agentic workflows.
Get started with just a few lines of code:
Each tab is a complete program. Add Genkit to a module with
go get github.com/firebase/genkit/go, then go mod tidy after you paste the
code so the provider plugin and any provider SDK it needs are resolved. Each
plugin reads its credential from the environment: GEMINI_API_KEY for Google
AI, OPENAI_API_KEY for OpenAI, ANTHROPIC_API_KEY for Anthropic. Ollama runs
locally and needs no key.
package main
import ( "context" "log"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/plugins/googlegenai")
func main() { ctx := context.Background() g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}))
resp, err := genkit.Generate(ctx, g, ai.WithPrompt("Why is the sky blue?"), ai.WithModelName("googleai/gemini-flash-latest"), ) if err != nil { log.Fatal(err) }
log.Println(resp.Text())}package main
import ( "context" "log"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/plugins/googlegenai" "google.golang.org/genai")
func main() { ctx := context.Background() g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}))
resp, err := genkit.Generate(ctx, g, ai.WithPrompt("a banana riding a bicycle"), ai.WithModelName("googleai/gemini-3.1-flash-image"), // Without IMAGE in ResponseModalities the model describes what it // would draw instead of drawing it. ai.WithConfig(&genai.GenerateContentConfig{ ResponseModalities: []string{"IMAGE", "TEXT"}, }), ) if err != nil { log.Fatal(err) }
// Media returns the data URI of the first media part. Use MediaParts when // the response can carry more than one picture. if uri := resp.Media(); uri != "" { log.Printf("Generated image: %s", uri) }}package main
import ( "context" "log"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/plugins/compat_oai/openai")
func main() { ctx := context.Background() g := genkit.Init(ctx, genkit.WithPlugins(&openai.OpenAI{}))
resp, err := genkit.Generate(ctx, g, ai.WithPrompt("Why is the sky blue?"), ai.WithModelName("openai/gpt-5.5"), ) if err != nil { log.Fatal(err) }
log.Println(resp.Text())}package main
import ( "context" "log"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/plugins/anthropic")
func main() { ctx := context.Background()
// The plugin reads ANTHROPIC_API_KEY from the environment. Set APIKey to // pass the credential yourself. g := genkit.Init(ctx, genkit.WithPlugins(&anthropic.Anthropic{}))
resp, err := genkit.Generate(ctx, g, ai.WithPrompt("Why is the sky blue?"), ai.WithModelName("anthropic/claude-opus-4-8"), ) if err != nil { log.Fatal(err) }
log.Println(resp.Text())}package main
import ( "context" "log"
"github.com/firebase/genkit/go/ai" "github.com/firebase/genkit/go/genkit" "github.com/firebase/genkit/go/plugins/ollama")
func main() { ctx := context.Background()
o := &ollama.Ollama{ ServerAddress: "http://localhost:11434", // Default Ollama server Timeout: 60, // Response timeout in seconds }
g := genkit.Init(ctx, genkit.WithPlugins(o))
// Any model installed on the server resolves by name. resp, err := genkit.Generate(ctx, g, ai.WithPrompt("Why is the sky blue?"), ai.WithModelName("ollama/gemma4:latest"), ) if err != nil { log.Fatal(err) }
log.Println(resp.Text())}Using Genkit in a server
Section titled “Using Genkit in a server”genkit.Init returns a *genkit.Genkit. Create one per process in main() and
share it across every request handler: it is safe for concurrent use by many
goroutines, as are the flow, tool, and prompt values you define from it. The
ctx you pass to genkit.Generate propagates cancellation to the provider
call, but there is no default per-request timeout, so set one with
context.WithTimeout. Retries and provider fallback are opt-in
middleware. For the whole contract, including parallel tool
fan-out and shutdown, see
Concurrency, cancellation, and lifecycle.
Sample programs
Section titled “Sample programs”Every concept below has a runnable Go program in the repository. Each one opens
with a package comment naming what it teaches and giving the ways to run it:
directly, in the Developer UI, and, where the sample serves HTTP, with curl.
| Sample | What it teaches |
|---|---|
| basic | The two kinds of flow: one that returns its answer whole, one that forwards the model’s chunks as they arrive. |
| basic-structured | Typed output, where the Go type you ask for is the schema the model is held to. |
| basic-formats | What the output format decides, including what a streamed chunk means under json, jsonl, and enum. |
| basic-prompts | Every prompt defined twice, inline in code and as a .prompt file, so the pair shows what moves out of code. |
| basic-prompt-content | Filling the system, conversation, user, and context slots of a prompt from one typed input. |
| basic-media | Reading a picture, editing one, generating one, and animating one with a background model. |
| basic-tools | Tools, including one that returns a value plus attached content the model and the client both receive. |
| basic-tools-exp | The same program on the in-preview tools API, which also streams progress from inside a running tool. |
| basic-tool-interrupts | Human in the loop: a tool pauses generation to ask a person, then resumes with their answer. |
| basic-tool-interrupts-exp | The same program on the in-preview tools API, where the resume payload is a typed value rather than a metadata map. |
| basic-middleware/retry-fallback | Composing Retry and Fallback into a model pipeline that survives a bad model id. |
| basic-middleware/filesystem | Scoped file access for the model, read-only and write-enabled. |
| basic-middleware/skills | A local library of instructions the model loads on demand, so the heavy text stays off the hot path. |
| basic-middleware/a2ui | An agent that streams generative UI to a browser through the A2UI middleware, served at the endpoint the JavaScript client expects. Runs on an in-preview API. |
| basic-agents | Seven agents in seven styles behind one interactive CLI, including typed session state, delegation, and sub-agents that run in the background. Agent APIs are in preview. |
| basic-agents-server | Two agents served as plain HTTP endpoints, one turn per request, showing session state held by the server and held by the client. Agent APIs are in preview. |
| basic-errors | Classifying a failure once with core/status so the classification survives to the HTTP boundary. |
| basic-durable-streaming-exp | Rejoining a stream by ID, with the buffered chunks replayed before live updates resume. Runs on an in-preview API. |
Provider samples for Anthropic, OpenAI, and the other OpenAI-compatible providers are the same one-flow program with only the plugin and its config changed, so they read as a diff against each other.
Explore & build with Genkit
Section titled “Explore & build with Genkit”Play with AI sample apps, with visualizations of the Genkit code that powers them, at no cost to you.
Create your own AI-powered feature in minutes with our guides.
Key capabilities
Section titled “Key capabilities”| Broad AI model support | Use a unified interface to integrate with hundreds of models from providers like Google, OpenAI, Anthropic, Ollama, and more. Explore, compare, and use the best models for your needs. |
| Simplified AI development | Use streamlined APIs to build AI features with structured output, agentic tool calling, context-aware generation, multi-modal input/output, and more. Genkit handles the complexity of AI development, so you can build and iterate faster. |
| Web and mobile ready | Integrate seamlessly with frameworks and platforms including Next.js, React, Angular, iOS, and Android using client helpers that call your flows over HTTP. |
| Cross-language support | Build with the language that best fits your project. Genkit provides SDKs for JavaScript/TypeScript, Go, Python, and Dart with consistent APIs and capabilities across all supported languages. |
| Deploy anywhere | Deploy AI logic to any environment that supports your chosen programming language, such as Google Cloud Run or any other platform that runs your language’s binaries or containers, with or without Google services. |
| Developer tools | Accelerate AI development with a purpose-built, local CLI and Developer UI. Test prompts and flows against individual inputs or datasets, compare outputs from different models, debug with detailed execution traces, and use immediate visual feedback to iterate rapidly on prompts. Coding with an AI assistant? Genkit Agent Skills teach it to write idiomatic Genkit code. |
| Production monitoring | Ship AI features with confidence using comprehensive production monitoring. Track model performance, request volumes, latency, and error rates in a purpose-built dashboard. Identify issues quickly with detailed observability metrics, and ensure your AI features meet quality and performance targets in real-world usage. |
How does it work?
Section titled “How does it work?”Genkit simplifies building AI-powered and agentic applications with an open-source SDK and unified APIs that work across various model providers and programming languages. It abstracts away complexity so you can focus on delivering great app experiences.
Some key features offered by Genkit include:
- Text and image generation
- Type-safe, structured data generation
- Tool calling
- Prompt templating
- Persisted chat interfaces
- AI workflows
- AI-powered data retrieval (RAG)
Genkit is designed for server-side deployment in multiple language environments, and also provides seamless client-side integration through dedicated client helpers.
Implementation path
Section titled “Implementation path”| 1 | Choose your language and model provider | Select the Genkit SDK for your preferred language (JavaScript/TypeScript, Go, Python, or Dart). Choose a model provider like Google Gemini or Anthropic, and get an API key. Some providers, like Vertex AI, may rely on a different means of authentication. |
| 2 | Install the SDK and initialize | Install the Genkit SDK, model-provider package of your choice, and the Genkit CLI. Import the Genkit and provider packages and initialize Genkit with the provider API key. |
| 3 | Write and test AI features | Use the Genkit SDK to build AI features for your use case, from basic text generation to complex multi-step agentic applications. Use the CLI and Developer UI to help you rapidly test and iterate. |
| 4 | Deploy and monitor | Deploy your AI features to Firebase, Google Cloud Run, or any environment that supports your chosen programming language. Integrate them into your app, and monitor them in production in the Firebase console. |
Connect with us
Section titled “Connect with us”- Join us on Discord – Get help, share ideas, and chat with other developers.
- Contribute on GitHub – Report bugs, suggest features, or explore the source code.