Prerequisites
- Go 1.21 or later
- A Google AI API key (get one at Google AI Studio)
Step 1: Initialize Your Project
Create a new Go module:Step 2: Install Genkit
Add Genkit and the Google AI plugin to your project:Step 3: Set Your API Key
Set your Google AI API key as an environment variable:Step 4: Create Your First Application
Create a file namedmain.go:
main.go
Step 5: Run Your Application
Run your application with the Genkit CLI for automatic tracing:Access the Developer UI
When running withgenkit start, open http://localhost:4000 to access the Developer UI where you can:
- View execution traces
- Test flows interactively
- Debug multi-step operations
Generate Structured Data
Genkit for Go provides type-safe JSON output withGenerateData:
Stream Responses
Stream text as it’s generated for responsive user experiences:Define Tools
Give models the ability to take actions and access external data:Create a Flow
Flows wrap your AI logic for better observability and deployment:Define Prompts
Create reusable prompts with Handlebars templating:Expose Flows as HTTP Endpoints
Serve your flows over HTTP with automatic JSON serialization:Try Other Model Providers
Genkit supports multiple AI providers:Learn More
Go API Reference
Explore the complete Go API
Structured Output
Generate type-safe JSON responses
Tool Calling
Give AI models access to functions
Deployment
Deploy your Go applications