Documentation
¶
Overview ¶
Package llm is the LLM client interface agentloop's ai()/aiJSON() sandbox capability calls against, and what drives the agent loop's own turn-taking.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Name() string
Complete(ctx context.Context, req CompletionRequest) (CompletionResponse, error)
// Stream delivers content deltas through onChunk as they arrive and
// still returns the full accumulated response — "best-effort
// incremental, full response always", so a caller that doesn't care
// about incremental output can pass a nil onChunk and just use the
// return value.
Stream(ctx context.Context, req CompletionRequest, onChunk func(chunk string)) (CompletionResponse, error)
}
Client is what the ai()/aiJSON() sandbox capability, and the agent loop's own turn-taking, call against.
type CompletionRequest ¶
type CompletionRequest struct {
Messages []Message
Model string // empty uses the client's configured default
Temperature *float64
MaxTokens *int
}
CompletionRequest is one call to Client.Complete or Client.Stream.
type CompletionResponse ¶
CompletionResponse is what a completion call returns.
type Config ¶
type Config struct {
APIKey string
ChatModel string
BaseURL string
ReasoningEffort string
// Headers carries extra request headers some gateways require or
// recommend — e.g. OpenRouter's optional HTTP-Referer / X-Title.
Headers map[string]string
// HTTPClient is optional; nil falls back to a 5-minute-timeout client.
HTTPClient *http.Client
}
Config configures the OpenAI-compatible client.
func ConfigFromEnv ¶
func ConfigFromEnv() Config
ConfigFromEnv reads OPENAI_API_KEY / OPENAI_CHAT_MODEL / OPENAI_BASE_URL / OPENAI_REASONING_EFFORT.
OPENAI_API_KEY — required to actually build a client.
OPENAI_CHAT_MODEL — default "gpt-4o-mini"; override to match
whatever BaseURL expects (e.g.
"openai/gpt-4o-mini" on OpenRouter,
"google/gemini-2.5-flash" on EdenAI).
OPENAI_BASE_URL — default the official OpenAI API; point this
at "https://openrouter.ai/api/v1",
"https://api.edenai.run/v3", or any other
OpenAI-wire-compatible host.
OPENAI_REASONING_EFFORT — optional ("low"|"medium"|"high"), caps
thinking on reasoning models.
Click to show internal directories.
Click to hide internal directories.