Home

Back

[Part 1] Genkit Go Quickstart: Setup, Flows, and Debugging

1. Introduction#

  • Tutorial: https://genkit.org.cn/docs/go/overview/ ↗
  • What it is: Genkit is an open-source framework from Google for building full-stack, AI-powered and agentic applications. It provides a unified interface for integrating AI models from many model providers, so you can pick the model that fits your needs. With streamlined APIs for multimodal content, structured outputs, tool calling and agentic workflows, you can quickly build and deploy production-ready AI-powered and agentic applications such as chatbots, automations and recommendation systems.

Key Capabilities#

Genkit ships with a set of core capabilities:

Genkit is designed for server-side deployment in multiple language environments, while dedicated helper tools and the client SDK ↗ provide seamless client-side integration.

CapabilityDescription
Broad AI model supportIntegrate hundreds of models from Google ↗, OpenAI ↗, Anthropic ↗, Ollama ↗ and other providers through a unified interface. Explore, compare and use the model that best fits your needs.
Simplified AI developmentBuild AI features with streamlined APIs that support structured output ↗, agentic tool calling ↗, context-aware generation ↗ and multimodal input/output ↗. Genkit handles the complexity of AI development so you can build and iterate faster.
Web and mobile readyUse dedicated client SDKs ↗ and helper tools to integrate seamlessly with frameworks and platforms such as Next.js, React, Angular, iOS and Android.
Cross-language supportBuild with the language that suits your project. Genkit provides JavaScript/TypeScript, Go, Python and Dart SDKs, with consistent APIs and capabilities across all supported languages.
Deploy anywhereDeploy your AI logic to any environment that supports your chosen language, such as Cloud Functions for Firebase ↗, Google Cloud Run ↗ or third-party platforms ↗ — with or without Google services.
Developer toolsSpeed up AI development with a purpose-built local CLI and Developer UI ↗. Test prompts and flows against a single input or a dataset, compare outputs across models, debug through detailed execution traces, and iterate on prompts with instant visual feedback.
Production monitoringShip AI features with confidence using comprehensive production monitoring. Track model performance, request volume, latency and error rates in a dedicated dashboard ↗. Spot issues quickly with detailed observability metrics and make sure your AI features meet their quality and performance targets in real-world usage.

2. Quickstart#

1. Prerequisites#

  • Go 1.24 or later (download and install ↗)
  • Genkit CLI: curl -sL cli.genkit.dev | bash or via NPM npm install -g genkit-cli
    • This gives you access to the local developer tools, including the Developer UI.
  • A model API key: the default is a Gemini model, and you can get an API key from Google AI Studio. Other models are also supported through the github.com/firebase/genkit/go/plugins/compat_oai package.

2. Your First Program#

Initialize the project:

mkdir genkit-intro && cd genkit-intro

go mod init example/genkit-intro

# Install the Genkit Go package
go get github.com/firebase/genkit/go
shell

main.go:

What this example does:

  • Defines reusable input and output schemas with Go structs that carry JSON schema tags.
  • Uses a custom model, reading the model config from .env.
  • Defines a Genkit flow that generates a structured recipe from your input.
  • Runs the flow with sample input and prints the structured result.

Why use flows?

  • Type-safe input and output: define explicit schemas for your data.
  • Developer UI integration: test and debug flows visually.
  • Easy to deploy as an API: expose flows as HTTP endpoints.
  • Built-in tracing and observability: monitor performance and debug issues.

3. Run It#

Run go run . and you will see a structured recipe printed as JSON, after which the server starts on http://localhost:3400. The server keeps running, serving your flow as an HTTP endpoint and enabling the Developer UI.

3. Debugging#

1. Debug over HTTP#

curl -s -X POST "http://localhost:3400/recipeGeneratorFlow" \
  -H "Content-Type: application/json" \
  -d '{"data": {"ingredient": "tomato", "dietaryRestrictions": "vegan"}}' \
  | jq .result
bash

2. Debug with the Developer UI#

Start it from the project root:

genkit start -- go run .
shell

Default address: http://localhost:4000 ↗

Select recipeGeneratorFlow in the flow list and provide:

{
  "ingredient": "avocado",
  "dietaryRestrictions": "vegetarian"
}
json

Click run and you will see the trace of the execution.

4. Genkit CLI#

1. Command-Line Interface (CLI)#

genkit --help
shell

The CLI supports several commands to make developing Genkit projects easier:

  • genkit start -- <command to run your code>: starts the Developer UI and connects it to the running code process.
  • genkit flow:run <flowName>: runs the given flow. Your runtime must already be running in a separate terminal with the GENKIT_ENV=dev environment variable set.
  • genkit eval:flow <flowName>: evaluates the given flow. Your runtime must already be running in a separate terminal with the GENKIT_ENV=dev environment variable set.
genkit start -- go run .
genkit start -- go run main.go
shell

You can also pass the -o flag to the start command to open the Developer UI automatically in your default browser tab.

genkit start -o -- <command to run your code>
shell

2. Analytics#

The Genkit CLI and Developer UI use cookies and similar technologies from Google to provide and improve the quality of the service and to analyze usage. Learn more ↗.

To opt out of analytics, run:

genkit config set analyticsOptOut true
shell

You can check the current setting by running:

genkit config get analyticsOptOut
shell
[Part 1] Genkit Go Quickstart: Setup, Flows, and Debugging
https://jimdeng.com/blog/genkit-go-intro
Author jimdeng
Published at 2026-10-12 08:00