Versions in this module Expand all Collapse all v1 v1.0.0 Jul 20, 2026 Changes in this version + func Ask(ctx context.Context, model Model, prompt string) (string, error) + func GenerateStructured[T any](ctx context.Context, model Model, req GenerateRequest) (T, error) + type ContentPart struct + Text string + ToolCall *ToolCall + ToolResult *ToolResult + Type ContentPartType + func TextPart(text string) ContentPart + type ContentPartType string + const ContentPartTypeReasoning + const ContentPartTypeText + const ContentPartTypeToolCall + const ContentPartTypeToolResult + type Error struct + Cause error + Code ErrorCode + Provider string + RequestID string + RetryAfter time.Duration + Retryable bool + func (e *Error) Error() string + func (e *Error) Unwrap() error + type ErrorCode string + const ErrorCodeAuthFailed + const ErrorCodeContextLength + const ErrorCodeInvalidRequest + const ErrorCodeOverloaded + const ErrorCodePermissionDenied + const ErrorCodeRateLimited + const ErrorCodeServerError + const ErrorCodeTimeout + type FallbackOption func(*fallbackConfig) + func WithBackoff(fn func(attempt int) time.Duration) FallbackOption + func WithBudget(d time.Duration) FallbackOption + func WithMaxRetries(n int) FallbackOption + type FinishReason string + const FinishReasonMaxTokens + const FinishReasonRefusal + const FinishReasonStop + const FinishReasonToolCalls + type GenerateRequest struct + MaxTokens int + Messages []Message + ProviderOptions map[string]any + ResponseSchema json.RawMessage + System string + Temperature float64 + Tools []Tool + type GenerateResponse struct + FinishReason FinishReason + Message Message + Usage Usage + type Message struct + Parts []ContentPart + Role Role + type Model interface + Generate func(ctx context.Context, req GenerateRequest) (GenerateResponse, error) + Stream func(ctx context.Context, req GenerateRequest) (<-chan StreamEvent, error) + func Fallback(models []Model, opts ...FallbackOption) Model + type ModelInfo interface + ModelName func() string + Provider func() string + type Provider interface + Model func(name string) Model + type Role string + const RoleAssistant + const RoleTool + const RoleUser + type StreamEvent struct + Delta string + Err error + FinishReason FinishReason + ToolCall *ToolCall + Type StreamEventType + Usage Usage + type StreamEventType string + const StreamEventTypeError + const StreamEventTypeFinish + const StreamEventTypeReasoningDelta + const StreamEventTypeTextDelta + const StreamEventTypeToolCallDelta + type Tool struct + Description string + Name string + Parameters json.RawMessage + type ToolCall struct + Arguments json.RawMessage + ID string + Name string + type ToolResult struct + Content string + IsError bool + ToolCallID string + type Usage struct + InputTokens int + OutputTokens int