Versions in this module Expand all Collapse all v0 v0.10.0 Aug 6, 2026 Changes in this version type Option + func WithCacheTTL(ttl string) Option v0.8.6 Jul 31, 2026 Changes in this version type Option + func WithUnknownToolResult(result string) Option v0.8.5 Jul 21, 2026 Changes in this version + const ReasoningEffortHigh + const ReasoningEffortLow + const ReasoningEffortMax + const ReasoningEffortMedium + const ReasoningEffortMinimal + const ReasoningEffortNone type Option + func WithReasoningEffort(effort string) Option + func WithRetryObserver(fn RetryObserver) Option + type RetryObserver func(attempt int, err error, delay time.Duration) v0.8.4 Jun 9, 2026 Changes in this version + const ToolChoiceAuto + const ToolChoiceNone + const ToolChoiceRequired + var ErrUnknownTool = errors.New("goai: unknown tool") + func AssistantMessage(text string) provider.Message + func ClassifyStreamError(body []byte) error + func IsOverflow(message string) bool + func ParseHTTPError(providerID string, statusCode int, body []byte) error + func ParseHTTPErrorWithHeaders(providerID string, statusCode int, body []byte, headers http.Header) error + func SchemaFrom[T any]() json.RawMessage + func SystemMessage(text string) provider.Message + func ToolCallIDFromContext(ctx context.Context) string + func ToolMessage(toolCallID, toolName, output string) provider.Message + func UserMessage(text string) provider.Message + type APIError struct + IsRetryable bool + Message string + ResponseBody string + ResponseHeaders map[string]string + StatusCode int + func (e *APIError) Error() string + type AfterToolExecuteInfo struct + Ctx context.Context + Error error + Input json.RawMessage + Output string + Step int + ToolCallID string + ToolName string + type AfterToolExecuteResult struct + Error error + Metadata map[string]any + Output string + type AgentState struct + func (s *AgentState) Observe() (kind StepKind, step int) + func (s *AgentState) SetTerminal(kind StepKind) bool + type BeforeStepInfo struct + Ctx context.Context + Messages []provider.Message + Step int + type BeforeStepResult struct + ExtraMessages []provider.Message + Stop bool + type BeforeToolExecuteInfo struct + Ctx context.Context + Input json.RawMessage + Step int + ToolCallID string + ToolName string + type BeforeToolExecuteResult struct + Ctx context.Context + Error error + Input json.RawMessage + Result string + Skip bool + type ContextOverflowError struct + Message string + ResponseBody string + func (e *ContextOverflowError) Error() string + type EmbedManyResult struct + Embeddings [][]float64 + ProviderMetadata map[string]map[string]any + Response provider.ResponseMetadata + Usage provider.Usage + func EmbedMany(ctx context.Context, model provider.EmbeddingModel, values []string, ...) (*EmbedManyResult, error) + type EmbedResult struct + Embedding []float64 + ProviderMetadata map[string]map[string]any + Response provider.ResponseMetadata + Usage provider.Usage + func Embed(ctx context.Context, model provider.EmbeddingModel, value string, ...) (*EmbedResult, error) + type FinishInfo struct + FinishReason provider.FinishReason + StepsExhausted bool + StoppedBy provider.StopCause + TotalSteps int + TotalUsage provider.Usage + type ImageOption func(*imageOptions) + func WithAspectRatio(ratio string) ImageOption + func WithImageCount(n int) ImageOption + func WithImageMaxRetries(n int) ImageOption + func WithImagePrompt(prompt string) ImageOption + func WithImageProviderOptions(opts map[string]any) ImageOption + func WithImageSize(size string) ImageOption + func WithImageTimeout(d time.Duration) ImageOption + type ImageResult struct + Images []provider.ImageData + ProviderMetadata map[string]map[string]any + Response provider.ResponseMetadata + Usage provider.Usage + func GenerateImage(ctx context.Context, model provider.ImageModel, opts ...ImageOption) (*ImageResult, error) + type ObjectResult struct + FinishReason provider.FinishReason + Object T + ProviderMetadata map[string]map[string]any + Response provider.ResponseMetadata + ResponseMessages []provider.Message + Steps []StepResult + Usage provider.Usage + func GenerateObject[T any](ctx context.Context, model provider.LanguageModel, opts ...Option) (_ *ObjectResult[T], err error) + type ObjectStream struct + func StreamObject[T any](ctx context.Context, model provider.LanguageModel, opts ...Option) (_ *ObjectStream[T], err error) + func (os *ObjectStream[T]) Err() error + func (os *ObjectStream[T]) PartialObjectStream() <-chan *T + func (os *ObjectStream[T]) Result() (*ObjectResult[T], error) + type Option func(*options) + func WithEmbeddingProviderOptions(opts map[string]any) Option + func WithExplicitSchema(schema json.RawMessage) Option + func WithFrequencyPenalty(p float64) Option + func WithHeaders(h map[string]string) Option + func WithMaxOutputTokens(n int) Option + func WithMaxParallelCalls(n int) Option + func WithMaxRetries(n int) Option + func WithMaxSteps(n int) Option + func WithMessages(msgs ...provider.Message) Option + func WithOnAfterToolExecute(fn func(AfterToolExecuteInfo) AfterToolExecuteResult) Option + func WithOnBeforeStep(fn func(BeforeStepInfo) BeforeStepResult) Option + func WithOnBeforeToolExecute(fn func(BeforeToolExecuteInfo) BeforeToolExecuteResult) Option + func WithOnFinish(fn func(FinishInfo)) Option + func WithOnPanic(fn func(PanicInfo)) Option + func WithOnRequest(fn func(RequestInfo)) Option + func WithOnResponse(fn func(ResponseInfo)) Option + func WithOnStepFinish(fn func(StepResult)) Option + func WithOnToolCall(fn func(ToolCallInfo)) Option + func WithOnToolCallStart(fn func(ToolCallStartInfo)) Option + func WithOptions(opts ...Option) Option + func WithPresencePenalty(p float64) Option + func WithPrompt(s string) Option + func WithPromptCaching(b bool) Option + func WithProviderOptions(opts map[string]any) Option + func WithSchemaName(name string) Option + func WithSeed(s int) Option + func WithSequentialToolExecution() Option + func WithStateRef(ref *AgentState) Option + func WithStopSequences(seqs ...string) Option + func WithStopWhen(predicate StopCondition) Option + func WithSystem(s string) Option + func WithTemperature(t float64) Option + func WithTimeout(d time.Duration) Option + func WithToolChoice(tc string) Option + func WithTools(tools ...Tool) Option + func WithTopK(k int) Option + func WithTopP(p float64) Option + func WrapOnAfterToolExecute(...) Option + func WrapOnBeforeStep(...) Option + func WrapOnBeforeToolExecute(...) Option + type PanicError struct + Phase string + Stack []byte + Value any + func (e *PanicError) Error() string + func (e *PanicError) Unwrap() error + type PanicInfo struct + Phase string + Stack []byte + Value any + type ParsedStreamError struct + IsRetryable bool + Message string + ResponseBody string + Type StreamErrorType + func ParseStreamError(body []byte) *ParsedStreamError + type RequestInfo struct + Ctx context.Context + MessageCount int + Messages []provider.Message + Model string + Timestamp time.Time + ToolCount int + type ResponseInfo struct + Error error + FinishReason provider.FinishReason + Latency time.Duration + StatusCode int + Usage provider.Usage + type StepKind int + const StepCancelled + const StepDone + const StepError + const StepIdle + const StepLLMInFlight + const StepStarting + const StepStepFinished + const StepToolExecuting + func (k StepKind) IsTerminal() bool + func (k StepKind) String() string + type StepResult struct + FinishReason provider.FinishReason + Number int + ProviderMetadata map[string]map[string]any + Reasoning string + Response provider.ResponseMetadata + Sources []provider.Source + Text string + ToolCalls []provider.ToolCall + ToolResults []provider.ToolResult + Usage provider.Usage + type StopCondition func(steps []StepResult) bool + type StreamErrorType string + const StreamErrorAPI + const StreamErrorContextOverflow + type TextResult struct + FinishReason provider.FinishReason + ProviderMetadata map[string]map[string]any + Reasoning string + Response provider.ResponseMetadata + ResponseMessages []provider.Message + Sources []provider.Source + Steps []StepResult + StepsExhausted bool + Text string + ToolCalls []provider.ToolCall + TotalUsage provider.Usage + func GenerateText(ctx context.Context, model provider.LanguageModel, opts ...Option) (_ *TextResult, err error) + type TextStream struct + func StreamText(ctx context.Context, model provider.LanguageModel, opts ...Option) (_ *TextStream, err error) + func (ts *TextStream) Err() error + func (ts *TextStream) Result() *TextResult + func (ts *TextStream) Stream() <-chan provider.StreamChunk + func (ts *TextStream) TextStream() <-chan string + type Tool struct + Description string + Execute func(ctx context.Context, input json.RawMessage) (string, error) + InputSchema json.RawMessage + Name string + ProviderDefinedOptions map[string]any + ProviderDefinedType string + func NewTool[In any](name, description string, ...) Tool + type ToolCallInfo struct + Duration time.Duration + Error error + Input json.RawMessage + Metadata map[string]any + Output string + OutputObject any + Skipped bool + StartTime time.Time + Step int + ToolCallID string + ToolName string + type ToolCallStartInfo struct + Input json.RawMessage + Step int + ToolCallID string + ToolName string