Welcome to AgenticGoKit! You'll build and run your first AI agent in just 5 minutes.
AgenticGoKit is a production-ready framework for building AI agents in Go. An agent is a program that takes user input, thinks about it (optionally with tools and memory), and returns a response from an LLM.
# Install the library
go get github.com/agenticgokit/agenticgokit/v1beta
# Set your LLM provider API key
export OPENAI_API_KEY="sk-..." # OpenAI
export OLLAMA_HOST="http://localhost:11434" # Ollama (local)For Ollama, install from ollama.com and pull a model:
ollama pull llama2Create a file called main.go:
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/agenticgokit/agenticgokit/v1beta"
)
func main() {
// Set your LLM API key (or use environment variables)
os.Setenv("OPENAI_API_KEY", "your-api-key-here")
// Create an agent
agent, err := v1beta.NewChatAgent("Assistant",
v1beta.WithLLM("openai", "gpt-4"),
)
if err != nil {
log.Fatal(err)
}
// Run the agent
result, err := agent.Run(context.Background(), "What is Go?")
if err != nil {
log.Fatal(err)
}
// Print the result
fmt.Println("Response:", result.Content)
fmt.Println("Success:", result.Success)
}go run main.goOutput:
Response: Go is a statically typed, compiled programming language developed at Google...
Success: true
Congratulations! You just built your first AgenticGoKit agent! 🎉
An Agent is your interface to an LLM. You create it once with configuration (which model, what to remember, which tools to use), then call it repeatedly.
agent, err := v1beta.NewChatAgent("Assistant", v1beta.WithLLM("openai", "gpt-4"))
// Result: An Agent that uses OpenAI's GPT-4 modelRun executes the agent with user input and waits for the complete response.
result, err := agent.Run(context.Background(), "Your question here")
// Returns: Complete response + metadata (tokens used, execution time, etc.)The Result contains:
Content- The LLM's response textSuccess- Whether execution succeededDuration- How long it tookTokensUsed- LLM tokens consumedMemory- Whether memory was used- Other metadata
if result.Success {
fmt.Println(result.Content) // The response
fmt.Println(result.TokensUsed) // Cost indicator
}By default, agents remember the conversation. Each agent automatically stores interactions using an embedded memory provider (chromem). Call the same agent multiple times and it remembers what you said.
result1, _ := agent.Run(ctx, "My name is Alice")
result2, _ := agent.Run(ctx, "What is my name?")
// Result2 will answer: "Your name is Alice" ← From memory!If you prefer stateless agents (no memory), you can disable it—see Memory & RAG.
// Use GPT-3.5-turbo instead
agent, err := v1beta.NewChatAgent("Assistant",
v1beta.WithLLM("openai", "gpt-3.5-turbo"),
)
// Or use Ollama locally
agent, err := v1beta.NewChatAgent("Assistant",
v1beta.WithLLM("ollama", "llama2"),
)agent, err := v1beta.NewBuilder("Assistant").
WithPreset(v1beta.ChatAgent).
WithConfig(&v1beta.Config{
SystemPrompt: "You are a friendly pirate",
}).
Build()
result, _ := agent.Run(ctx, "Hello!")
// Response: "Ahoy, matey! What be bringin' ye to these waters?"agent, err := v1beta.NewChatAgent("Assistant",
v1beta.WithLLM("openai", "gpt-4"),
v1beta.WithAgentTimeout(15 * time.Second), // Max 15 seconds
)Want more control? See the Configuration Guide for all builder options, presets, and advanced settings.
The agent you just built is functional but basic. Here's what you can add depending on your needs:
Display responses token-by-token as they're generated (instead of waiting for the complete response).
Build pipelines where multiple agents work together (one researches, another writes, another reviews).
Give agents the ability to call external APIs, databases, file systems, etc. via the Model Context Protocol (MCP).
Enable agents to store and retrieve custom knowledge, documents, and long-term facts.
Get complete visibility into agent execution with distributed tracing, workflow tracking, and LLM call metrics.
Write handlers to control exactly how agents process input (bypass LLM for certain queries, apply custom rules, etc.).
Fine-tune temperature, max tokens, timeouts, caching, and more.
We recommend exploring in this order:
- ✅ You are here: Getting Started (5 min) - Build and run an agent
- Core Concepts (15 min) - Understand agents, handlers, tools, and memory
- Pick your path:
- Want real-time responses? → Streaming Guide
- Multiple agents? → Workflows Guide
- External APIs? → Tool Integration
- Knowledge base? → Memory & RAG
- Custom behavior? → Custom Handlers
- Explore examples - See complete projects in examples/
- Troubleshoot - Visit Troubleshooting if something breaks
- Problems? → Troubleshooting Guide
- See it in action → Examples & Tutorials
- Questions? → GitHub Discussions
- Found a bug? → GitHub Issues
Ready to learn more? Continue to Core Concepts →