Recipes
Each recipe is one task, one complete program and links to the guide and reference for more depth. Every program lives in examples/recipes, is built by CI, and compiles without API keys. Set the keys a recipe names to run it.
| Recipe | Task |
|---|---|
| Serve a useChat frontend | Serve an endpoint that the useChat hook from @ai-sdk/react can talk to. |
| Ask before running a tool | Let the model request a tool, but run it only after the user says yes. |
| Use tools from an MCP server | Call the tools of a Model Context Protocol (MCP) server from GenerateText. |
| Get typed data from a model | Get a Go struct back from a model, not free text. |
| Switch providers | Run the same code on different providers, chosen by configuration. |
| Use Claude with reasoning | Have Claude think before it answers, and read what it thought. |
| Run Claude Code or Codex | Hand a coding task to Claude Code or Codex and read what it changed. |
| Retrieve context with embeddings | Answer questions from your own documents. |
| Handle rate limits and retries | Make calls resilient to 429 and 5xx responses, and fail clearly when they are not. |
| Test code that calls a model | Write fast, deterministic tests for code that calls a language model. |
| Run a tool loop with an agent | Let a model call your Go functions until it has an answer. |
| Stream text as it arrives | Print a model's answer while it is still being written. |
Reference app
For a full application that combines several of these recipes, see the Build a chat app guides and the Shipyard demo.