interfaces.LLMClient. Pass it to NewAgent with WithLLMClient.
Built-in clients live under pkg/llm/ and share option helpers from pkg/llm:
Supported providers
| Provider | Package | GetProvider() value |
|---|---|---|
| OpenAI | pkg/llm/openai | openai |
| Anthropic | pkg/llm/anthropic | anthropic |
| Gemini | pkg/llm/gemini | gemini |
OpenAI
gpt-4o, gpt-4o-mini. The model name is sent as-is to the provider — an invalid name will return an API error at run time, not at NewAgent.
Anthropic
WithLLMSampling. See Reasoning.
Gemini
llm.WithAPIKey takes precedence. If you omit it, the Gemini client falls back to the GOOGLE_API_KEY environment variable automatically.Shared LLM options
All built-in clients accept functional options frompkg/llm:
| Option | Purpose |
|---|---|
llm.WithAPIKey(key) | Provider API key |
llm.WithModel(model) | Model name sent to the provider |
llm.WithBaseURL(url) | Custom base URL (OpenAI-compatible endpoints, proxies) |
Sampling and reasoning
Control temperature, max tokens, and reasoning per agent withWithLLMSampling:
| Field | OpenAI | Anthropic | Gemini |
|---|---|---|---|
Temperature | ✓ | ✓ | ✓ |
MaxTokens | ✓ | ✓ | ✓ |
TopP | ✓ | — | ✓ |
TopK | — | ✓ | — |
Reasoning | Partial | ✓ | ✓ |
Bring your own LLM client
Implementinterfaces.LLMClient and pass your implementation to WithLLMClient.
Your implementation must handle:
Generate— synchronous completion; populateLLMResponse.ToolCallswhen the provider returns tool callsGenerateStream— streaming chunks viaLLMStream.Next()andLLMStream.Current()whenIsStreamSupported()returnstrueGetModel/GetProvider— metadata that appears onAgentRunResult.ModelandAgentRunResult.AgentName
Related
Quickstart
Run your first agent end to end
Configuration
WithLLMClient, WithLLMSampling, and other options
Reasoning
Extended thinking on Anthropic and Gemini
Token Usage
Read LLMUsage from run results