Getting Started
August 21, 2026 · View on GitHub
Languages: English (current) · Português
This guide takes you from zero to a working crew.
Prerequisites
- Go 1.24+ — check with
go version. - An API key for an LLM provider (e.g.
OPENAI_API_KEY) — or use an offline/custom LLM.
1. Create a project
mkdir my-crew && cd my-crew
go mod init example.com/my-crew
go get github.com/rhgs/crewai-go@latest
2. Write the program
main.go:
package main
import (
"context"
"fmt"
"log"
"github.com/rhgs/crewai-go"
"github.com/rhgs/crewai-go/llm/openai"
)
func main() {
llm := openai.New("gpt-4o-mini")
researcher := crewai.NewAgent(
"Researcher",
"Find relevant, reliable information",
"You are an experienced, skeptical analyst.",
llm,
)
task := crewai.NewTask(
"Explain in 3 points why Go is good for back-end.",
"A list of 3 short items.",
researcher,
)
crew := crewai.NewCrew([]*crewai.Agent{researcher}, []*crewai.Task{task})
crew.Verbose = true // or use WithLogger for structured logging (see below)
out, err := crew.Kickoff(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
fmt.Println(out.Final)
}
Tip: For structured logging via
log/slog, replacecrew.Verbose = truewithcrew.WithLogger(slog.New(slog.NewJSONHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelDebug}))). See Logging for details.
3. Run it
export OPENAI_API_KEY=sk-...
go run .
4. No API key? Run offline
You can implement the crewai.LLM interface yourself (see
llms.md) or use the mock LLM from the test package. The
examples/custom_llm example runs fully offline:
go run github.com/rhgs/crewai-go/examples/custom_llm
Next steps
- Agents — configure roles, goals, tools, and the agentic loop.
- Tasks — chain tasks with context,
Asyncwaves, structured output, and warnings. - Crews — sequential, hierarchical, staged, and async-wave scheduling; progress callbacks.
- Memory — short-term bag,
MemoryStore, FileStore, embeddings. - Tools — give "hands" to your agents (including web search).
- LLMs — providers, native tool calling, and logging.
- MCP — connect external Model Context Protocol servers.