
Section
Basics
How AI agents work, from the ground up: what an agent is, the loop at its center, calling a model from Go, tool calling, what each turn costs, and how a model picks its next token.
Start here if you are new to agents or to LLM (large language model) APIs.
The pages build on each other in the order listed, and each one points at runnable Go code.
The Go an agent leans on, such as context.Context, error handling, and streams, has its own section, Go in depth, which the guides here link to where they use it.
Show guides by loop stage
On the agent compass
No guides here work on this stage alone.
Covers every stage
Part 1
Get oriented
- Getting set upGo 1.27, the companion code, offline and live runs, and the newer Go features the code uses.Beginner
- What an agent isWhat makes a program an agent, followed through one run that fixes a failing test.Beginner
- The agent loopThe whole agent loop in about 30 lines of Go, read stage by stage.Beginner
Part 2
Talk to a model
- Your first model callAn API key, one request with curl, and every part of the reply, including what it cost.Beginner
- Messages and rolesThe four roles in a conversation, the Go type that holds them, and how to write a system prompt.Beginner
- Calling a model from GoA chat completions client in standard-library Go, with deadlines, error checks, and finish reasons.Beginner
- Common first errorsA missing key, no credit, a bad model ID, rate limits, cut-off replies, and two Go traps.Beginner
Part 3
Tools and the model
- Tool calling on the wireA tool call as raw JSON, how a Go client sends and reads one, and the rules that keep it valid.Beginner
- Tokens, cost, and contextHow an agent’s requests grow each turn, what a run costs, and why the context window misleads.Beginner
- How models pick the next tokenA toy model in Go shows why answers vary, what temperature does, and why a tool call is text.Beginner
- Choosing a modelTool support, cost per finished task, reasoning models, local models, and how to compare.Beginner

