API reference¶
This page indexes the public symbols of github.com/ktsoator/or/llm by module.
It does not duplicate field defaults, event tables, or behavioral rules. Current
source and pkg.go.dev remain
authoritative for exact Go declarations; the linked reference page owns each
group's semantics.
Request entry points¶
| API | Return | Purpose |
|---|---|---|
Complete(ctx, model, input, options) |
(AssistantMessage, error) |
Collect a response and return the final or partial message |
Stream(ctx, model, input, options) |
(<-chan Event, error) |
Receive normalized events while generation runs |
NewClient(adapters, providers) |
*Client |
Create an independent client with explicit registries |
(*Client).Complete(...) |
(AssistantMessage, error) |
Complete through a specified client |
(*Client).Stream(...) |
(<-chan Event, error) |
Stream through a specified client |
See Failure signals for preflight and streaming failures, and Getting started for the shortest request path.
Inputs, messages, and history¶
| Category | Public symbols | Reference |
|---|---|---|
| Context constructors | Prompt, PromptWithSystem, NewContext |
Messages and context |
| Message constructors | UserText, UserImage, AssistantText, ToolResult |
Messages and context |
| Message interfaces | Message, UserMessage, AssistantMessage, ToolResultMessage |
Messages and context |
| Content blocks | TextContent, ImageContent, ThinkingContent, ToolCall |
Messages and context |
| Response access | AssistantMessage.Text, AssistantMessage.ToolCalls |
Responses and usage |
| Serialization | MarshalMessage, UnmarshalMessage |
Messages and context |
| History transformation | TransformMessages |
Messages and context |
NewAssistantMessage initializes adapter output. Context and the concrete
message types implement JSON marshal and unmarshal.
Streaming¶
| Category | Public symbols | Reference |
|---|---|---|
| Events | Event, EventType, EventStart, text/reasoning/tool-call events, EventDone, EventError |
Streaming events |
| Adapter output | StreamWriter, NewStreamWriter |
Custom protocols |
| Tool-call copying | CloneToolCall |
Streaming events |
Valid event fields, order, and termination rules are maintained only in Streaming events.
Request options¶
| Category | Public symbols | Reference |
|---|---|---|
| Shared options | StreamOptions, StreamOptions.Validate |
Request options |
| Protocol option interface | ProtocolStreamOptions |
Request options |
| OpenAI options | OpenAICompletionsStreamOptions, OpenAIResponsesStreamOptions, and OpenAIToolChoice types and constants |
Tool definitions and calls |
| Anthropic options | AnthropicStreamOptions and AnthropicToolChoice types and constants |
Tool definitions and calls |
| Thinking display | ThinkingDisplay, ThinkingDisplaySummarized, ThinkingDisplayOmitted |
Reasoning options |
See Request options for field defaults, credential precedence, hooks, and request rewriting.
Tools¶
| Category | Public symbols | Reference |
|---|---|---|
| Definition | ToolDefinition, NewTool[T], MustTool[T] |
Tool definitions and calls |
| Reading and decoding | ToolCall, DecodeToolCall[T] |
Tool definitions and calls |
| Generic validation | ValidateToolCall, ValidateToolArguments |
Tool definitions and calls |
| Best-effort parsing | ParseToolArguments, ParseToolArgumentsMode, ArgumentsMode constants |
Tool definitions and calls |
| Diagnostics | ToolArgumentsDiagnostic, DiagnosticToolArgumentsRecovered |
Responses and usage |
These APIs do not execute or authorize tools. See Executing tool calls for the complete application flow.
Models and providers¶
| Category | Public symbols | Reference |
|---|---|---|
| Built-in catalog | LookupModel, GetModel, GetProviders, GetModels, GetRunnableModels, SupportsProtocol |
Models and providers |
| Model capability | Model, ModelInput, ModelThinkingLevel, SupportedThinkingLevels, ClampThinkingLevel |
Models and providers, Reasoning options |
| Cost estimation | ModelCost, CalculateCost |
Responses and usage |
| Model registry | ModelRegistry, NewModelRegistry |
Clients and registries |
| Provider definition | Provider, ProviderSpec, NewSpecProvider |
Models and providers |
| Provider overrides | ProviderOverride, AuthStatus |
Models and providers |
| Provider registry | ProviderRegistry, NewProviderRegistry, NewBuiltInProviderRegistry, DefaultProviderRegistry |
Clients and registries |
| Credential helpers | APIKeyEnvVars, FindEnvAPIKeys, FindEnvAPIKeysWithEnv, GetEnvAPIKey, GetEnvAPIKeyWithEnv, MissingAPIKeyError |
Request options |
Model fields, compatibility configuration, and provider override behavior are maintained only in Models and providers. See Protocol and provider status for live-support boundaries.
Protocols and registries¶
| Category | Public symbols | Reference |
|---|---|---|
| Protocols | Protocol, ProtocolOpenAICompletions, ProtocolOpenAIResponses, ProtocolAnthropicMessages |
Protocol and provider status |
| Compatibility | ModelCompatibility, OpenAICompletionsCompatibility, AnthropicMessagesCompatibility |
Models and providers |
| Adapter | ProtocolAdapter |
Custom protocols |
| Adapter registry | AdapterRegistry, NewAdapterRegistry, Register |
Clients and registries |
| Built-in adapters | openai.NewAdapter, openai.NewResponsesAdapter, anthropic.NewAdapter, llm/all |
Getting started |
Results, failures, and diagnostics¶
| Category | Public symbols | Reference |
|---|---|---|
| Stop reasons | StopReason and StopReasonStop, Length, ToolUse, Error, Aborted |
Responses and usage |
| Tokens and cost | Usage, UsageCost, ModelCost |
Responses and usage |
| Context overflow | IsContextOverflow, OverflowPatterns |
Responses and usage |
| Diagnostics | Diagnostic, DiagnosticToolArgumentsRecovered |
Responses and usage |
See Failure signals for how returned errors, EventError, and
failed messages relate across request stages.