Get started with Genkit
Welcome to Genkit. To get started, pick the guide that matches how you’re building. Each guide is self-contained and takes you from an empty project to a running app without any prior setup.
Every guide walks you through building the same small app, Bargain Chef, so you learn the same core Genkit patterns (streaming structured output and tool calling) no matter which stack you choose. By the end you’ll have a working flow that streams a recipe into a UI and calls a tool to ground its response in live data. Once you’ve finished one guide, the concepts carry directly over to your own app.
Choose your Genkit SDK
Section titled “Choose your Genkit SDK”Start by choosing the SDK for the language you’ll write your Genkit code in. The rest of this page adapts to that choice.
Hello, Genkit
Section titled “Hello, Genkit”Before picking a framework, get one model call running. This takes about two minutes and needs nothing but the Go toolchain and an API key.
1. Create a module and add Genkit.
mkdir hello-genkit && cd hello-genkitgo mod init example/hello-genkitgo get github.com/firebase/genkit/goGenkit for Go needs Go 1.25 or later. The plugins live in the same module,
so a single go get is enough; run go mod tidy after you paste the code below
to pull in the provider SDK it needs.
2. Get a Gemini API key from Google AI Studio and put it in your environment:
export GEMINI_API_KEY=<your API key>3. Write main.go.
package main
import ( "context" "fmt" "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()
// Init registers the plugin's models and returns the handle every other // Genkit call takes. It returns one value, not (value, error): a plugin // that cannot start panics here, so a missing API key fails at startup // rather than on the first request. g := genkit.Init(ctx, genkit.WithPlugins(&googlegenai.GoogleAI{}), genkit.WithDefaultModel("googleai/gemini-flash-latest"), )
// A flow is an ordinary Go function that Genkit traces, validates against // the input and output types you declared, and exposes to the Developer UI // and to HTTP. jokeFlow := genkit.DefineFlow(g, "jokeFlow", func(ctx context.Context, topic string) (string, error) { resp, err := genkit.Generate(ctx, g, ai.WithSystem("You are a stand-up comedian. One line, no preamble."), ai.WithPrompt("Tell a joke about %s.", topic), ) if err != nil { return "", err } return resp.Text(), nil })
joke, err := jokeFlow.Run(ctx, "gophers") if err != nil { log.Fatal(err) } fmt.Println(joke)}4. Run it.
go mod tidygo run .You should see a one-line joke. If you see a panic mentioning GEMINI_API_KEY,
step 2 did not take effect in this shell.
5. Optional: open the Developer UI. Install the CLI, then run your program under it to get a visual flow runner and a trace for every model call:
curl -sL cli.genkit.dev | bashgenkit start -- go run .The UI opens at http://localhost:4000. See
Developer tools for what it can do.
That is the whole core loop: initialize, define a flow, generate, run. Everything below builds on it.
What Init gives you
Section titled “What Init gives you”func Init(ctx context.Context, opts ...GenkitOption) *GenkitInit returns one value and no error. Configuration problems fail loudly at
startup instead of on the first request: a plugin with a missing API key, two
plugins claiming the same name, or a prompt directory you named that does not
exist all panic inside Init. There is no error-returning variant, so validate
anything you need to choose at runtime before you call it.
The *genkit.Genkit it returns is the handle every other Genkit call takes.
Pass it to functions that define flows, tools, or prompts, such as
func defineTools(g *genkit.Genkit). Create exactly one per process in
main(): it is safe for concurrent use by many goroutines, and so are the
flow, tool, and prompt values the Define* functions return. Define everything
during startup, before you serve traffic, and share the one instance across all
request handlers.
There is no default per-request timeout, and retries and provider fallback are opt-in middleware rather than defaults. See Concurrency, cancellation, and lifecycle before you put this behind a server.
Serve it over HTTP
Section titled “Serve it over HTTP”With Genkit for Go, your AI logic runs in a standalone backend. You’ll get there in two steps:
- Build a backend. Pick a backend framework below and follow its guide to expose your Genkit flows over HTTP. This is where your model calls, tools, and flows live.
- Add a frontend (optional). Once your backend is running, pick an app framework guide to connect a web or mobile UI that calls your flows over HTTP.
Start with a backend framework, then come back for a frontend when you’re ready.
Backend frameworks
Section titled “Backend frameworks”App frameworks
Section titled “App frameworks”Pair a Go Genkit backend with any of these frontends. Each guide shows how to call your flows over HTTP.
If you’re not ready to choose a framework yet, explore Creating flows and Generating content to learn the core concepts first. For a runnable version of each of those concepts, the Go sample programs are one self-documenting program per topic, starting with basic.
Two more pages pay off early: Testing your AI logic, which runs flows in-process against a fake model so CI needs no API key, and Concurrency, cancellation, and lifecycle, which states what is safe to share and how deadlines propagate.
After you choose a stack
Section titled “After you choose a stack”Once your app is running, the next pages most teams need are:
- Creating flows
- Generating content
- Tool calling
- Developer tools
- AI-assisted development with Genkit Agent Skills