Genkit Go 1.0: Google brings stable AI framework to the Go ecosystem
Google introduces Genkit Go 1.0 and aims to facilitate AI development in the Go programming language with type-safe flows, CLI tools and assistant integration.
(Image: Besjunior/Shutterstock.com)
Google has released Genkit Go 1.0, the first stable version of its open source framework for AI development in the Go ecosystem. Developers can now use it to create and deploy production-ready AI applications. At the same time, Google is bringing direct integration for common AI coding assistants with the new CLI command genkit init:ai-tools.
Create type-safe AI flows
One of the most exciting new features in Genkit Go 1.0 is the ability to create type-safe AI flows with Go structs and JSON schema validation. This apparently allows model responses to be structured reliably and tested more easily.
In the following example from the announcement post, a flow generates a structured recipe:
package main
import (
"context"
"encoding/json"
"fmt"
"log"
"github.com/firebase/genkit/go/ai"
"github.com/firebase/genkit/go/genkit"
"github.com/firebase/genkit/go/plugins/googlegenai"
)
// Define your data structures
type RecipeInput struct {
Ingredient string `json:"ingredient" jsonschema:"description=Main ingredient or cuisine type"`
DietaryRestrictions string `json:"dietaryRestrictions,omitempty" jsonschema:"description=Any dietary restrictions"`
}
type Recipe struct {
Title string `json:"title"`
Description string `json:"description"`
PrepTime string `json:"prepTime"`
CookTime string `json:"cookTime"`
Servings int `json:"servings"`
Ingredients []string `json:"ingredients"`
Instructions []string `json:"instructions"`
Tips []string `json:"tips,omitempty"`
}
func main() {
ctx := context.Background()
// Initialize Genkit with plugins
g := genkit.Init(ctx,
genkit.WithPlugins(&googlegenai.GoogleAI{}),
genkit.WithDefaultModel("googleai/gemini-2.5-flash"),
)
// Define a type-safe flow
recipeFlow := genkit.DefineFlow(g, "recipeGeneratorFlow",
func(ctx context.Context, input *RecipeInput) (*Recipe, error) {
dietaryRestrictions := input.DietaryRestrictions
if dietaryRestrictions == "" {
dietaryRestrictions = "none"
}
prompt := fmt.Sprintf(`Create a recipe with the following requirements:
Main ingredient: %s
Dietary restrictions: %s`, input.Ingredient, dietaryRestrictions)
// Generate structured data with type safety
recipe, _, err := genkit.GenerateData[Recipe](ctx, g,
ai.WithPrompt(prompt),
)
if err != nil {
return nil, fmt.Errorf("failed to generate recipe: %w", err)
}
return recipe, nil
})
// Run the flow
recipe, err := recipeFlow.Run(ctx, &RecipeInput{
Ingredient: "avocado",
DietaryRestrictions: "vegetarian",
})
if err != nil {
log.Fatalf("could not generate recipe: %v", err)
}
// Print the structured recipe
recipeJSON, _ := json.MarshalIndent(recipe, "", " ")
fmt.Println("Sample recipe generated:")
fmt.Println(string(recipeJSON))
<-ctx.Done() // Used for local testing only
}
Here, a flow(recipeGeneratorFlow) is defined that generates recipes based on a main ingredient and optional dietary specifications such as "vegetarian". The prompt is built dynamically, passed to the AI model (Google Gemini), and the answer is written back to a clearly defined Go data structure (recipe). At the end, the flow runs with the input "avocado, vegetarian" and returns a complete JSON recipe with ingredients, cooking time and tips.
Videos by heise
Connection to common language models
Genkit Go 1.0 also gives developers the option of integrating external APIs via tool calling and using models from Google AI, Vertex AI, OpenAI, Anthropic and Ollama via a standardized interface. Provisioning should be straightforward as an HTTP endpoint. A standalone CLI and an interactive developer UI provide support for writing tests, debugging and monitoring.
The new genkit init:ai-tools command automatically sets up AI assistance tools such as Gemini CLI, Firebase Studio, Claude Code and Cursor. This allows developers to directly look for the Genkit documentation, test flows, execute debug traces, and generate Go code according to best practices.
(mdo)