# Quick Start Build your first AgentKit agent in 5 minutes URL: https://agentkit.tech/docs/quick-start.mdx This guide will help you create your first AgentKit agent in under 5 minutes. ## Prerequisites * Go 1.19 or later * OpenAI API key (get one at [platform.openai.com](https://platform.openai.com/)) ## Step 1: Set up your environment First, set your OpenAI API key: ```bash export OPENAI_API_KEY="your-openai-api-key" ``` ## Step 2: Create your first agent Create a new file called `main.go`: ```go package main import ( "context" "fmt" "log" "os" "github.com/model-box/agent-kit/agent" "github.com/model-box/agent-kit/model" "github.com/model-box/agent-kit/session" ) func main() { // Create model model := model.Model("gpt-4o"). SetAPIKey(os.Getenv("OPENAI_API_KEY")) // Create agent ag := agent.New(). SetModel(model). SetSystemPrompt("You are a helpful assistant.") // Create session and run sess := session.New(ag) result, err := sess.Run(context.Background(), []agent.ChatMessage{ agent.NewUserMessage("Hello, world!"), }, nil) if err != nil { log.Fatal(err) } fmt.Println(result.FinalOutput) } ``` ## Step 3: Run your agent ```bash go run main.go ``` You should see your agent respond to your greeting! ## Step 4: Try a conversation Let's make it more interactive by adding a simple conversation loop: ```go package main import ( "bufio" "context" "fmt" "log" "os" "strings" "github.com/model-box/agent-kit/agent" "github.com/model-box/agent-kit/model" "github.com/model-box/agent-kit/session" ) func main() { // Create model model := model.Model("gpt-4o"). SetAPIKey(os.Getenv("OPENAI_API_KEY")) // Create agent ag := agent.New(). SetModel(model). SetSystemPrompt("You are a helpful assistant.") // Create a conversation session sess := session.New(ag) fmt.Println("🤖 ChatBot: Hello! I'm your AI assistant. Type 'quit' to exit.") scanner := bufio.NewScanner(os.Stdin) ctx := context.Background() for { fmt.Print("👤 You: ") if !scanner.Scan() { break } input := strings.TrimSpace(scanner.Text()) if input == "quit" { fmt.Println("🤖 ChatBot: Goodbye!") break } if input == "" { continue } // Send message to agent result, err := sess.Run(ctx, []agent.ChatMessage{agent.NewUserMessage(input)}, nil) if err != nil { log.Printf("Error: %v", err) continue } fmt.Printf("🤖 ChatBot: %s\n\n", result.FinalOutput) } } ``` Run this version to have a back-and-forth conversation with your agent! ## What's Next? Congratulations! 🎉 You've built your first AgentKit agent. Here's what you can explore next: ### Learn Core Concepts * [Agents](/agents) - Learn about agent configuration * [Models](/models) - Explore different model providers * [Tools](/tools) - Add function calling capabilities * [Sessions](/sessions) - Manage conversation state ### Follow Guides * [Multi-turn Conversations](/multi-turn-conversation) - Build persistent conversations * [Streaming Responses](/streaming-agent) - Add real-time streaming * [Tool Calling](/tool-calling) - Give agents access to external functions ### Explore Examples * [Examples](/examples) - See complete working examples * [GitHub Repository](https://github.com/model-box/agent-kit/tree/main/examples) - More example code ## Need Help? * 📚 Browse the [documentation](/docs) * 💬 Join our [GitHub Discussions](https://github.com/model-box/agent-kit/discussions) * 🐛 Report issues on [GitHub Issues](https://github.com/model-box/agent-kit/issues)