Skip to content

Examples index

This page indexes runnable programs under example/llm/ in the repository. For shorter task-oriented examples, use the LLM recipes.

Running an example

Each directory is a separate main package using the root module:

go run ./example/llm/basic

Live requests require the selected provider's API key. Check Protocol and provider status first.

Example programs

Example Source directory Demonstrates Documentation
Basic example/llm/basic LookupModel, Complete, text results Basic completion
Options example/llm/options System prompt, temperature, max tokens Configuration
Streaming example/llm/streaming Text deltas and terminal events Streaming responses
Reasoning example/llm/reasoning Reasoning effort and thinking events Requesting reasoning
Tools example/llm/tools Typed tools and an application tool loop Executing tool calls
Conversation example/llm/conversation Caller-owned multi-turn history Messages and context
Model switch example/llm/model_switch Changing protocol and model with one history Changing models in a conversation
Advanced example/llm/advanced Request hooks and low-level options Configuration
Providers example/llm/providers Provider registration and overrides Providers
Who am I example/llm/whoami Provider credential status Provider status

Compile check

This command compiles every tracked LLM example without sending a network request:

go test ./example/llm/...

Examples cover llm responsibilities only. A production application still owns session storage, tool authorization, retry policy, and context compaction.