Versions in this module Expand all Collapse all v0 v0.1.0 Dec 5, 2026 Changes in this version + const DefaultToolSearchThreshold + const OpGenerateObject + const OpGenerateText + const OpStreamObject + const OpStreamText + const SearchToolsName + const SimilaritySearchName + var ErrContentFiltered = errors.New("aikit: content filtered") + var ErrContextLength = errors.New("aikit: context length exceeded") + var ErrInsufficientCredits = errors.New("aikit: insufficient credits") + var ErrInvalidRequest = errors.New("aikit: invalid request") + var ErrOverloaded = errors.New("aikit: provider overloaded") + var ErrRateLimited = errors.New("aikit: rate limited") + var ErrStopped = errors.New("aikit: stopped by middleware") + func Failoverable(err error) bool + func Stop(reason string) error + func StreamObject[T any](ctx context.Context, m Model, p Prompt, opts ...Option) iter.Seq2[Partial[T], error] + func StreamText(ctx context.Context, m Model, p Prompt, opts ...Option) iter.Seq2[Event, error] + type ApprovalDecision struct + Approved bool + Args json.RawMessage + Reason string + type ApprovalRequest struct + Args json.RawMessage + ID string + Tool string + type ApprovalRequested struct + Request ApprovalRequest + type Approver interface + Approve func(ctx context.Context, req ApprovalRequest) (ApprovalDecision, error) + type ApproverFunc func(ctx context.Context, req ApprovalRequest) (ApprovalDecision, error) + func (f ApproverFunc) Approve(ctx context.Context, req ApprovalRequest) (ApprovalDecision, error) + type Audio struct + Data []byte + MIMEType string + type CachePolicy uint8 + const CacheHistory + const CacheSystem + const CacheTools + type EmbedConfig struct + Dimensions int + Task string + func NewEmbedConfig(opts ...EmbedOption) EmbedConfig + type EmbedOption func(*EmbedConfig) + func WithDimensions(n int) EmbedOption + func WithEmbedTask(task string) EmbedOption + type Embedder interface + Embed func(ctx context.Context, in []string, o ...EmbedOption) (Embeddings, error) + type Embeddings struct + Usage Usage + Vectors [][]float32 + type Event interface + type FailoverEvent struct + Err error + From string + To string + type File struct + Data []byte + FileID string + MIMEType string + Name string + URL string + type Filter struct + Key string + Value string + type Finish struct + Response *Response + type FinishReason string + const FinishApproval + const FinishContentFilter + const FinishLength + const FinishOther + const FinishStop + const FinishToolCalls + type GeneratedImage struct + Data []byte + MIMEType string + RevisedPrompt string + type Guardrail interface + CheckInput func(ctx context.Context, msgs []Message) error + CheckOutput func(ctx context.Context, r *StepResult) error + type GuardrailError struct + Name string + Reason string + Stage string + func (e *GuardrailError) Error() string + type HostedTool interface + HostedBy func() string + type Image struct + Data []byte + MIMEType string + URL string + type ImageGenerator interface + GenerateImage func(ctx context.Context, p ImagePrompt) (*GeneratedImage, error) + type ImagePrompt struct + Prompt string + Quality string + Size string + type Limit func(s *Step) error + func MaxCost(usd float64, p Pricing) Limit + func MaxInputTokens(n int) Limit + func MaxSteps(n int) Limit + func MaxTotalTokens(n int) Limit + type Message struct + Parts []Part + Role Role + func Assistant(text string, parts ...Part) Message + func System(text string) Message + func ToolMessage(results ...ToolResult) Message + func User(text string, parts ...Part) Message + func (m Message) Text() string + func (m Message) ToolCalls() []ToolCall + type Messages []Message + type Middleware func(next StepFunc) StepFunc + func Budget(limits ...Limit) Middleware + func Guard(gs ...Guardrail) Middleware + func Redact(r Redactor, scope RedactScope) Middleware + func RouteModel(fn func(s *Step) Model) Middleware + type Model interface + Generate func(ctx context.Context, req *Request) (*Response, error) + ID func() string + Provider func() string + Stream func(ctx context.Context, req *Request) iter.Seq2[Event, error] + func Failover(primary Model, fallbacks ...Model) Model + type Named interface + Name func() string + type NativeToolSearch interface + NativeToolSearch func() bool + type Notice struct + Approval *ApprovalRequest + Approved bool + Err error + From string + Kind NoticeKind + Reason string + RunID string + Step int + To string + type NoticeKind string + const NoticeApproval + const NoticeApprovalResolved + const NoticeFailover + const NoticeGuardrail + const NoticeRepair + const NoticeStopped + type Observer interface + Notice func(ctx context.Context, n Notice) + StartRun func(ctx context.Context, r RunInfo) (context.Context, func(RunEnd)) + StartStep func(ctx context.Context, s StepInfo) (context.Context, func(StepEnd)) + StartTool func(ctx context.Context, t ToolInfo) (context.Context, func(ToolEnd)) + type Option func(*config) + func WithApprover(a Approver) Option + func WithCache(p CachePolicy) Option + func WithContentCapture() Option + func WithMaxSteps(n int) Option + func WithMaxTokens(n int) Option + func WithMeta(kv map[string]string) Option + func WithMiddleware(mw ...Middleware) Option + func WithObserver(o Observer) Option + func WithProviderOptions(provider string, fields map[string]any) Option + func WithReasoning(r ReasoningOptions) Option + func WithRepair(n int) Option + func WithSystem(s string) Option + func WithTemperature(t float64) Option + func WithToolChoice(tc ToolChoice) Option + func WithToolSearchThreshold(n int) Option + func WithTools(ts ...Tool) Option + type Part interface + type Partial struct + Done bool + Response *Response + Text string + Value T + type Price struct + CacheRead float64 + CacheWrite float64 + Input float64 + Output float64 + type Pricing map[string]Price + func (p Pricing) Cost(model string, u Usage) (float64, bool) + type Prompt interface + type ProviderError struct + Code string + Err error + Message string + Model string + Provider string + RetryAfter time.Duration + Status int + func StatusError(provider, model string, status int, h http.Header, code, msg string) *ProviderError + func (e *ProviderError) Error() string + func (e *ProviderError) Unwrap() error + type Ranked struct + Index int + Score float64 + type Reasoning struct + Redacted string + Signature string + Text string + type ReasoningDelta struct + Text string + type ReasoningOptions struct + BudgetTokens int + Effort string + type RedactScope uint8 + const RedactObserver + const RedactPrompt + type Redactor interface + Redact func(ctx context.Context, s string) string + type RedactorFunc func(ctx context.Context, s string) string + func (f RedactorFunc) Redact(ctx context.Context, s string) string + type Request struct + Cache CachePolicy + DeferTools bool + MaxTokens int + Messages []Message + Output *schema.Schema + Provider map[string]map[string]any + Reasoning *ReasoningOptions + System string + Temperature *float64 + ToolChoice ToolChoice + Tools []Tool + func (r *Request) Clone() *Request + type Reranker interface + Rerank func(ctx context.Context, query string, docs []string, topN int) ([]Ranked, error) + type Response struct + Approvals []ApprovalRequest + FinishReason FinishReason + Message Message + Raw json.RawMessage + Steps []StepResult + Usage Usage + func Collect(seq iter.Seq2[Event, error]) (*Response, error) + func GenerateObject[T any](ctx context.Context, m Model, p Prompt, opts ...Option) (T, *Response, error) + func GenerateText(ctx context.Context, m Model, p Prompt, opts ...Option) (*Response, error) + func (r *Response) Text() string + func (r *Response) ToolCalls() []ToolCall + type Role string + const RoleAssistant + const RoleSystem + const RoleTool + const RoleUser + type RunEnd struct + Duration time.Duration + Err error + FinishReason FinishReason + Output string + Steps int + Usage Usage + type RunInfo struct + Meta map[string]string + Model string + Operation string + Provider string + RunID string + Start time.Time + type SchemaError struct + Err error + Problems []schema.Problem + Schema string + Text string + func (e *SchemaError) Error() string + func (e *SchemaError) Unwrap() error + type SimilarDoc struct + ID string + Meta map[string]string + Score float64 + Text string + type SpeechConfig struct + Format string + Instructions string + Voice string + func NewSpeechConfig(opts ...SpeechOption) SpeechConfig + type SpeechGenerator interface + Speak func(ctx context.Context, text string, o ...SpeechOption) (io.ReadCloser, error) + type SpeechOption func(*SpeechConfig) + func WithAudioFormat(f string) SpeechOption + func WithSpeechInstructions(s string) SpeechOption + func WithVoice(v string) SpeechOption + type Step struct + History []StepResult + Index int + Meta map[string]string + Model Model + Request *Request + Usage Usage + type StepEnd struct + Duration time.Duration + Err error + FinishReason FinishReason + Model string + Output *Message + Provider string + Usage Usage + type StepFinish struct + Step StepResult + type StepFunc func(ctx context.Context, s *Step) (*StepResult, error) + type StepInfo struct + Index int + MaxTokens int + Messages []Message + Meta map[string]string + Model string + Provider string + RunID string + System string + Temperature *float64 + Tools []string + type StepResult struct + Duration time.Duration + FinishReason FinishReason + Index int + Message Message + Model string + Provider string + ToolResults []ToolResult + Usage Usage + type Text struct + Text string + type TextDelta struct + Text string + type Tool interface + Call func(ctx context.Context, args json.RawMessage) (json.RawMessage, error) + Description func() string + InputSchema func() json.RawMessage + Name func() string + func SimilaritySearch(store VectorStore, e Embedder, ns string, k int) Tool + type ToolAnnotated interface + Destructive func() bool + ReadOnly func() bool + type ToolApproval interface + NeedsApproval func(ctx context.Context, args json.RawMessage) bool + type ToolAuthorizer interface + Authorize func(ctx context.Context) error + type ToolCall struct + Args json.RawMessage + Hosted bool + ID string + Name string + Signature string + type ToolCallDelta struct + Args string + ID string + type ToolCallEnd struct + Call ToolCall + type ToolCallError struct + Args json.RawMessage + Err error + Tool string + func (e *ToolCallError) Error() string + func (e *ToolCallError) Unwrap() error + type ToolCallGuardrail interface + CheckToolCall func(ctx context.Context, call ToolCall) error + type ToolCallStart struct + ID string + Name string + type ToolChoice string + const ToolAuto + const ToolNone + const ToolRequired + type ToolDeferred interface + Deferred func() bool + type ToolEnd struct + Duration time.Duration + Err error + IsError bool + Output json.RawMessage + type ToolInfo struct + Args json.RawMessage + CallID string + Name string + RunID string + Step int + type ToolOption func(*toolConfig) + func Deferred() ToolOption + func Destructive() ToolOption + func ReadOnly() ToolOption + func RequireApproval(pred ...func(ctx context.Context, in any) bool) ToolOption + func ToolTimeout(d time.Duration) ToolOption + type ToolOutputSchema interface + OutputSchema func() json.RawMessage + type ToolResult struct + CallID string + IsError bool + Name string + Output json.RawMessage + type Toolset struct + func Tools(ts ...Tool) (*Toolset, error) + func (s *Toolset) Deferred() []Tool + func (s *Toolset) Lookup(name string) (Tool, bool) + func (s *Toolset) Tools() []Tool + type TranscribeConfig struct + Filename string + Language string + Prompt string + func NewTranscribeConfig(opts ...TranscribeOption) TranscribeConfig + type TranscribeOption func(*TranscribeConfig) + func WithFilename(name string) TranscribeOption + func WithLanguage(lang string) TranscribeOption + type Transcriber interface + Transcribe func(ctx context.Context, audio io.Reader, o ...TranscribeOption) (*Transcript, error) + type Transcript struct + Language string + Text string + type TypedTool struct + func NewTool[In, Out any](name, desc string, fn func(ctx context.Context, in In) (Out, error), ...) *TypedTool[In, Out] + func (t *TypedTool[In, Out]) Call(ctx context.Context, args json.RawMessage) (json.RawMessage, error) + func (t *TypedTool[In, Out]) Deferred() bool + func (t *TypedTool[In, Out]) Description() string + func (t *TypedTool[In, Out]) Destructive() bool + func (t *TypedTool[In, Out]) InputSchema() json.RawMessage + func (t *TypedTool[In, Out]) Name() string + func (t *TypedTool[In, Out]) NeedsApproval(ctx context.Context, args json.RawMessage) bool + func (t *TypedTool[In, Out]) OutputSchema() json.RawMessage + func (t *TypedTool[In, Out]) ReadOnly() bool + type Usage struct + CacheRead int + CacheWrite int + Input int + Output int + Reasoning int + func (u Usage) Add(v Usage) Usage + func (u Usage) Total() int + type VectorDoc struct + ID string + Meta map[string]string + Text string + Vector []float32 + type VectorHit struct + Score float64 + type VectorStore interface + Delete func(ctx context.Context, ns string, ids ...string) error + Query func(ctx context.Context, ns string, v []float32, k int, f ...Filter) ([]VectorHit, error) + Upsert func(ctx context.Context, ns string, docs ...VectorDoc) error