Index of every page on this site: llms.txt
All skills
genkit-ai avatar

/developing-genkit-go

@d12c988
by Genkitgenkit-ai/skills40 stars
13
Run it yourself

Provides guidance on developing AI-powered applications using Genkit in Go. Use when the user asks to build AI features, agents, flows, or tools in Go using Genkit, or when working with Genkit Go code involving generation, prompts, streaming, tool calling, or model providers. Don't use for Genkit in JavaScript/TypeScript, Python, or Dart.

Use this Skill: https://skilld.dev/gh/genkit-ai/skills/developing-genkit-go

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesgetting-started.md

≈914 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Getting Started


Project Setup

mkdir my-genkit-app && cd my-genkit-app
go mod init my-genkit-app
go get github.com/firebase/genkit/go@latest

Provider plugins ship in the same module under plugins/, so they don't need to be fetched separately. Just import the ones you want and run go mod tidy afterwards. The available plugins include:

  • plugins/googlegenai for Google AI and Vertex AI
  • plugins/anthropic for Anthropic Claude
  • plugins/compat_oai for OpenAI-compatible APIs (OpenAI, Groq, xAI, etc.)
  • plugins/ollama for local Ollama models
  • plugins/middleware for the built-in middleware bundle (Retry, Fallback, ToolApproval, Filesystem, Skills)

Initialization

Every Genkit app starts with genkit.Init, which returns a *Genkit instance:

import (
	"context"
	"github.com/firebase/genkit/go/genkit"
	"github.com/firebase/genkit/go/plugins/googlegenai"
)

ctx := context.Background()
g := genkit.Init(ctx,
	genkit.WithPlugins(&googlegenai.GoogleAI{}),
)

The *Genkit Instance

The *Genkit value g is the central registry. Pass it to every Genkit function:

// Defining resources
genkit.DefineFlow(g, "myFlow", ...)
genkit.DefineTool(g, "myTool", ...)
genkit.DefinePrompt(g, "myPrompt", ...)

// Generating content
genkit.GenerateText(ctx, g, ...)
genkit.Generate(ctx, g, ...)

Do not store g in a global variable. Pass it explicitly through your call chain.

Init Options

g := genkit.Init(ctx,
	// Register one or more plugins
	genkit.WithPlugins(&googlegenai.GoogleAI{}, &anthropic.Anthropic{}),

	// Set a default model (used when no model is specified)
	genkit.WithDefaultModel("googleai/gemini-flash-latest"),

	// Set directory for .prompt files (default: "prompts")
	genkit.WithPromptDir("my-prompts"),

	// Or embed prompts using Go's embed package
	// genkit.WithPromptFS(promptsFS),
)

Embedding Prompts

Use go:embed to bundle .prompt files into the binary:

//go:embed prompts
var promptsFS embed.FS

g := genkit.Init(ctx,
	genkit.WithPlugins(&googlegenai.GoogleAI{}),
	genkit.WithPromptFS(promptsFS),
)

Genkit CLI

The Genkit CLI provides a local Developer UI for running flows, tracing executions, and inspecting model interactions.

Install:

curl -sL cli.genkit.dev | bash

Verify:

genkit --version

Developer UI

Start your app with the Developer UI attached:

genkit start -- go run .

This launches:

  • Your app (with tracing enabled)
  • The Developer UI at http://localhost:4000
  • A telemetry API at http://localhost:4033

Add -o to auto-open the UI in your browser:

genkit start -o -- go run .

The Developer UI lets you:

  • Run and test flows interactively
  • View traces for each generation call (inputs, outputs, latency, token usage)
  • Inspect prompt rendering and tool calls
  • Debug multi-step flows with per-step trace data

Without the CLI

Set GENKIT_ENV=dev to enable the reflection API without the CLI:

GENKIT_ENV=dev go run .

Import Paths

import (
	"github.com/firebase/genkit/go/genkit"          // Core: Init, Generate*, DefineFlow, etc.
	"github.com/firebase/genkit/go/ai"              // Types: WithModel, WithPrompt, Message, Part, etc.
	"github.com/firebase/genkit/go/core"            // Low-level: Run (sub-steps), Flow types
	"github.com/firebase/genkit/go/plugins/server"  // server.Start for HTTP
)

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 warning2d3 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    The skill provides comprehensive documentation and code samples for developing AI applications with Genkit in Go. It includes instructions for installing the Genkit CLI from an official source and documents security features like tool approval and filesystem sandboxing. No malicious patterns were detected.

  • Socket2d

    No alerts

  • Snyk3d

    Risk: MEDIUM · 2 issues

Signed by skilld at d12c988. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 5 days ago
metadata
{
  "version": "1.0.0",
  "category": "AiAndMachineLearning"
}

README badge

README badge for genkit-ai/skills/developing-genkit-go