Versions in this module Expand all Collapse all v1 v1.3.0 Jul 16, 2026 Changes in this version + const RoleAssistant + const RoleSystem + const RoleTool + const RoleUser + var DefaultPricing = map[string]ModelPricing + var ExportFormats = map[string]OutputFormat + var FormatCinematic = OutputFormat + var FormatInstagram = OutputFormat + var FormatSquare = OutputFormat + var FormatTikTok = OutputFormat + var FormatWide = OutputFormat + var FormatYouTube = OutputFormat + func AddSpanExporter(exp SpanExporter) + func AllProviders() []string + func ChunkText(text string, opts ...ChunkOption) []string + func Classify(ctx context.Context, text string, labels []string, opts ...ExtractOption) (string, error) + func CosineSimilarity(a, b []float32) float32 + func CostGuard(maxCostUSD float64) httpMiddleware + func CostReport() string + func Embed(ctx context.Context, text string, opts ...GenerateOption) ([]float32, error) + func EmitRequestEvent(e RequestEvent) + func EnableCostTracking(cfg CostConfig) + func EnableTracing(cfg TracingConfig) + func ExecuteTool(ctx context.Context, name string, args json.RawMessage) (json.RawMessage, error) + func ExtractSlice[T any](ctx context.Context, text string, opts ...ExtractOption) ([]T, error) + func Extract[T any](ctx context.Context, text string, opts ...ExtractOption) (*T, error) + func GenerateConcatFileContent(scenes []Scene) string + func GenerateFFmpegResizeCommand(inputPath string, format OutputFormat, outputPath string) []string + func GenerateStitchCommand(scenes []Scene, cfg StitchConfig) []string + func GetTotalCost() float64 + func IngestDocuments(ctx context.Context, store *Store, documents map[string]string, ...) error + func IsConfigured() bool + func Logger() httpMiddleware + func OnCompletion(h RequestHook) + func OnError(h RequestHook) + func OnRequest(h RequestHook) + func RateLimit(maxRequests int, window time.Duration) httpMiddleware + func RegisterProvider(name string, factory ProviderFactory) + func RegisterTool(t Tool) + func ResetCosts() + func SetModelPricing(model string, pricing ModelPricing) + func Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error) + func Summarize(ctx context.Context, text string, opts ...SummarizeOption) (string, error) + func UsageReport() string + func WithTraceContext(ctx context.Context, tc TraceContext) context.Context + type Agent struct + func NewAgent(instructions string) *Agent + func (a *Agent) MaxSteps(n int) *Agent + func (a *Agent) OnStep(h AgentHook) *Agent + func (a *Agent) Prompt(ctx context.Context, userMessage string, opts ...GenerateOption) (*GenerateResponse, error) + func (a *Agent) Stream(ctx context.Context, userMessage string, opts ...GenerateOption) (*StreamResponse, error) + func (a *Agent) WithClient(c *Client) *Agent + func (a *Agent) WithMemory(m Memory, key string) *Agent + func (a *Agent) WithMessages(msgs []Message) *Agent + func (a *Agent) WithModel(model string) *Agent + func (a *Agent) WithToolObjects(tools ...*Tool) *Agent + func (a *Agent) WithTools(names ...string) *Agent + type AgentHook func(step int, msg Message) + type CameraMove string + const CameraCrane + const CameraDolly + const CameraDrone + const CameraHandheld + const CameraMacro + const CameraOrbit + const CameraPan + const CameraStatic + const CameraTracking + const CameraZoomIn + const CameraZoomOut + type ChunkOption func(*chunkConfig) + func ChunkOverlap(n int) ChunkOption + func ChunkSeparator(sep string) ChunkOption + func ChunkSize(n int) ChunkOption + type Client struct + func GetClient() *Client + func NewClient(cfg *Config) (*Client, error) + func WithGuardrailsClient(c *Client, g *Guardrails) *Client + func (c *Client) Generate(ctx context.Context, prompt string, opts ...GenerateOption) (*GenerateResponse, error) + func (c *Client) GenerateRequest(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error) + func (c *Client) Provider() Provider + func (c *Client) Stream(ctx context.Context, prompt string, opts ...GenerateOption) (<-chan string, <-chan error) + func (c *Client) StreamRequest(ctx context.Context, req *GenerateRequest) (*StreamResponse, error) + type ComparisonReport struct + Reports []EvalReport + Suite string + func CompareModels(ctx context.Context, suite *EvalSuite, models ...string) *ComparisonReport + func (cr *ComparisonReport) Summary() string + type Config struct + AnthropicKey string + CohereKey string + ElevenLabsKey string + GeminiKey string + JinaKey string + MaxTokens int + MistralKey string + Model string + OllamaHost string + OpenAIKey string + Provider string + Timeout int + VoyageAIKey string + XAIKey string + type ContentFilter int + const FilterHate + const FilterNone + const FilterPII + const FilterSelfHarm + const FilterSexual + const FilterViolence + type ConversationRecord struct + CreatedAt time.Time + ID uint + Key string + Messages string + UpdatedAt time.Time + func (ConversationRecord) TableName() string + type CostConfig struct + AlertThresholds []float64 + CustomPricing map[string]ModelPricing + MonthlyBudget float64 + OnBudgetAlert func(CostSummary) + type CostEntry struct + CompletionCost float64 + CompletionTokens int + Model string + PromptCost float64 + PromptTokens int + Provider string + Timestamp time.Time + TotalCost float64 + TotalTokens int + type CostSummary struct + BudgetPercent float64 + BudgetRemaining float64 + CostByModel map[string]*ModelCostSummary + CostByProvider map[string]*ProviderCostSummary + HourlyCosts [24]float64 + MonthlyBudget float64 + RecentEntries []CostEntry + TotalCost float64 + TotalRequests int64 + TotalTokens int64 + func GetCostDashboard() CostSummary + type DatabaseMemoryOption func(*databaseMemory) + func WithAutoMigrate(enabled bool) DatabaseMemoryOption + type DocQA struct + func DocumentQA(text string) *DocQA + func (d *DocQA) Ask(ctx context.Context, question string) (string, error) + func (d *DocQA) Model(m string) *DocQA + func (d *DocQA) SystemPrompt(s string) *DocQA + type Document struct + ID string + Metadata map[string]string + Score float32 + Text string + Vector []float32 + type EmbeddingProvider interface + Embed func(ctx context.Context, req *EmbeddingRequest) (*EmbeddingResponse, error) + type EmbeddingRequest struct + Input []string + Model string + type EmbeddingResponse struct + Embeddings [][]float32 + Model string + Usage *Usage + func EmbedBatch(ctx context.Context, texts []string, opts ...GenerateOption) (*EmbeddingResponse, error) + type EvalCase struct + Checks []EvalCheck + Metadata map[string]string + Name string + Options []GenerateOption + Prompt string + System string + type EvalCheck func(response string) EvalScore + func CustomCheck(name string, fn func(response string) (float64, string)) EvalCheck + func ExpectContains(substr string) EvalCheck + func ExpectJSON() EvalCheck + func ExpectMaxLength(n int) EvalCheck + func ExpectMinLength(n int) EvalCheck + func ExpectNotContains(substr string) EvalCheck + func ExpectSimilarity(expected string, threshold float64) EvalCheck + func LLMJudge(criteria string) EvalCheck + type EvalReport struct + AvgLatency time.Duration + AvgScore float64 + Duration time.Duration + Errors int + Failed int + Model string + Passed int + Provider string + Results []EvalResult + Suite string + Timestamp time.Time + TotalCases int + TotalCost float64 + func (r *EvalReport) Summary() string + type EvalResult struct + AvgScore float64 + Case string + Cost float64 + Error string + Latency time.Duration + Model string + Passed bool + Prompt string + Provider string + Response string + Scores []EvalScore + Tokens int + type EvalScore struct + Details string + Name string + Passed bool + Score float64 + type EvalSuite struct + func NewEvalSuite(name string) *EvalSuite + func (s *EvalSuite) AddCase(name, prompt string, checks ...EvalCheck) *EvalSuite + func (s *EvalSuite) AddCaseWithSystem(name, system, prompt string, checks ...EvalCheck) *EvalSuite + func (s *EvalSuite) Parallel(n int) *EvalSuite + func (s *EvalSuite) Run(ctx context.Context) *EvalReport + func (s *EvalSuite) WithModel(model string) *EvalSuite + func (s *EvalSuite) WithOptions(opts ...GenerateOption) *EvalSuite + type Example struct + Input string + Output string + type ExtractOption func(*extractConfig) + func WithExtractModel(model string) ExtractOption + func WithExtractSystem(system string) ExtractOption + func WithMaxRetries(n int) ExtractOption + type FewShotTemplate struct + func FewShot(instruction string) *FewShotTemplate + func (f *FewShotTemplate) Add(input, output string) *FewShotTemplate + func (f *FewShotTemplate) Format(input string) string + func (f *FewShotTemplate) Generate(ctx context.Context, input string, opts ...GenerateOption) (*GenerateResponse, error) + func (f *FewShotTemplate) Separator(sep string) *FewShotTemplate + type GenerateOption func(*GenerateRequest) + func WithImages(images []string) GenerateOption + func WithMaxTokens(n int) GenerateOption + func WithMessages(msgs []Message) GenerateOption + func WithModel(model string) GenerateOption + func WithSchema(schema json.RawMessage) GenerateOption + func WithStop(stop ...string) GenerateOption + func WithSystem(s string) GenerateOption + func WithTemperature(t float32) GenerateOption + func WithTopP(p float32) GenerateOption + type GenerateRequest struct + Images []string + MaxTokens int + Messages []Message + Model string + Schema json.RawMessage + Stop []string + Stream bool + System string + Temperature float32 + Tools []ToolSpec + TopP float32 + type GenerateResponse struct + FinishReason string + Model string + Text string + ToolCalls []ToolCall + Usage *Usage + func Generate(ctx context.Context, prompt string, opts ...GenerateOption) (*GenerateResponse, error) + type GuardrailCheck func(output string) error + type Guardrails struct + func NewGuardrails() *Guardrails + func (g *Guardrails) BlockPatterns(patterns ...string) *Guardrails + func (g *Guardrails) CustomCheck(fn GuardrailCheck) *Guardrails + func (g *Guardrails) MaxLength(n int) *Guardrails + func (g *Guardrails) MinLength(n int) *Guardrails + func (g *Guardrails) RequireKeywords(keywords ...string) *Guardrails + func (g *Guardrails) SetContentFilter(f ContentFilter) *Guardrails + func (g *Guardrails) Validate(output string) error + func (g *Guardrails) ValidateResponse(resp *GenerateResponse) error + type ImageBuilder struct + func Image() *ImageBuilder + func (b *ImageBuilder) Count(n int) *ImageBuilder + func (b *ImageBuilder) Generate(ctx context.Context) (*ImageResponse, error) + func (b *ImageBuilder) Model(model string) *ImageBuilder + func (b *ImageBuilder) Prompt(prompt string) *ImageBuilder + func (b *ImageBuilder) Size(size string) *ImageBuilder + func (b *ImageBuilder) Style(style string) *ImageBuilder + func (b *ImageBuilder) WithClient(c *Client) *ImageBuilder + type ImageData struct + B64JSON string + URL string + type ImageProvider interface + GenerateImage func(ctx context.Context, req *ImageRequest) (*ImageResponse, error) + type ImageRequest struct + Model string + N int + Prompt string + Size string + Style string + type ImageResponse struct + Images []ImageData + Model string + type LegacyStreamProvider interface + Generate func(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error) + LegacyStream func(ctx context.Context, req *GenerateRequest) (<-chan string, <-chan error) + type LogExporter struct + func (e *LogExporter) ExportSpan(_ context.Context, span Span) error + type Memory interface + Clear func(ctx context.Context, key string) error + Load func(ctx context.Context, key string) ([]Message, error) + Save func(ctx context.Context, key string, messages []Message) error + func DatabaseMemory(db *lucid.DB, opts ...DatabaseMemoryOption) Memory + func MemoryStore(opts ...MemoryStoreOption) Memory + func RedisMemory(client *redis.Client, opts ...RedisMemoryOption) Memory + func SlidingWindowMemory(inner Memory, maxMessages int) Memory + func SummaryMemory(inner Memory, threshold int) Memory + type MemoryStoreOption func(*memoryStore) + func WithMemoryTTL(ttl time.Duration) MemoryStoreOption + type Message struct + Content string + Images []string + Role string + ToolCallID string + ToolCalls []ToolCall + type Metrics struct + RequestsByModel sync.Map + TotalErrors int64 + TotalLatency time.Duration + TotalRequests int64 + TotalTokens int64 + func GetMetrics() *Metrics + type ModelCostSummary struct + AvgCostPerReq float64 + CompletionTokens int64 + Model string + PromptTokens int64 + Requests int64 + TotalCost float64 + type ModelPricing struct + CompletionPer1K float64 + PromptPer1K float64 + type NamedStep struct + Handler StepHandler + Name string + func StepFunc(name string, handler StepHandler) NamedStep + type OTLPExporter struct + Endpoint string + func (e *OTLPExporter) ExportSpan(_ context.Context, span Span) error + type OutputFormat struct + Aspect string + Height int + Name string + Width int + type PgvectorOption func(*pgvectorStore) + func WithPgvectorDimension(d int) PgvectorOption + func WithPgvectorTable(name string) PgvectorOption + type PgvectorRecord struct + ID string + Metadata string + Text string + Vector string + type PineconeOption func(*pineconeStore) + func WithPineconeNamespace(ns string) PineconeOption + type Plugin struct + func New() *Plugin + func (p *Plugin) Boot(app *nimbus.App) error + func (p *Plugin) DefaultConfig() map[string]any + func (p *Plugin) Register(app *nimbus.App) error + type PromptChain struct + func Chain(templates ...*PromptTemplate) *PromptChain + func (c *PromptChain) Generate(ctx context.Context, vars map[string]any, opts ...GenerateOption) (*GenerateResponse, error) + type PromptTemplate struct + func SystemTemplate(s string) *PromptTemplate + func Template(s string) *PromptTemplate + func (p *PromptTemplate) Format(vars map[string]any) (string, error) + func (p *PromptTemplate) Generate(ctx context.Context, vars map[string]any, opts ...GenerateOption) (*GenerateResponse, error) + func (p *PromptTemplate) MustFormat(vars map[string]any) string + func (p *PromptTemplate) Role(role string) *PromptTemplate + type Provider interface + Generate func(ctx context.Context, req *GenerateRequest) (*GenerateResponse, error) + Name func() string + Stream func(ctx context.Context, req *GenerateRequest) (*StreamResponse, error) + type ProviderCostSummary struct + Provider string + Requests int64 + TotalCost float64 + type ProviderFactory func(cfg *Config) (Provider, error) + func GetProviderFactory(name string) (ProviderFactory, bool) + type QdrantOption func(*qdrantStore) + func WithQdrantAPIKey(key string) QdrantOption + func WithQdrantDimension(d int) QdrantOption + type RAG struct + func NewRAG(store *Store) *RAG + func (r *RAG) Ask(ctx context.Context, question string, opts ...GenerateOption) (*RAGResponse, error) + func (r *RAG) AskStream(ctx context.Context, question string, opts ...GenerateOption) (*StreamResponse, []Document, error) + func (r *RAG) MinScore(score float32) *RAG + func (r *RAG) Model(m string) *RAG + func (r *RAG) OnPostprocess(fn func(string, []Document) string) *RAG + func (r *RAG) OnPreprocess(fn func(string) string) *RAG + func (r *RAG) SystemPrompt(s string) *RAG + func (r *RAG) TopK(k int) *RAG + func (r *RAG) WithCitations(enabled bool) *RAG + func (r *RAG) WithClient(c *Client) *RAG + type RAGResponse struct + Answer string + Sources []Document + Usage *Usage + type RedisMemoryOption func(*redisMemory) + func WithRedisPrefix(prefix string) RedisMemoryOption + func WithRedisTTL(ttl time.Duration) RedisMemoryOption + type RequestEvent struct + Error error + Latency time.Duration + Messages []Message + Model string + Prompt string + Provider string + Timestamp time.Time + Usage *Usage + type RequestHook func(RequestEvent) + type Scene struct + Camera CameraMove + Duration int + Index int + KeyframeURL string + Metadata map[string]any + Prompt string + VideoURL string + type ScenePlan struct + ExpandedPrompt string + GlobalStyle string + OriginalPrompt string + Scenes []Scene + type SocialPackage struct + Caption string + Formats map[string]string + Hashtags []string + ThumbnailURL string + type Span struct + Attributes map[string]string + Duration time.Duration + EndTime time.Time + Error string + Events []SpanEvent + Kind string + Name string + ParentID string + SpanID string + StartTime time.Time + Status string + TraceID string + func GetTraceSpans(limit int) []Span + type SpanEvent struct + Attributes map[string]string + Name string + Timestamp time.Time + type SpanExporter interface + ExportSpan func(ctx context.Context, span Span) error + type StepHandler func(wc *WorkflowContext) error + type StepResult struct + Duration time.Duration + Error error + Name string + type StitchConfig struct + CaptionText string + ConcatFile string + FadeSeconds float64 + MusicPath string + OutputPath string + type Store struct + func VectorStoreInstance(name string, backend ...VectorStoreBackend) *Store + func (s *Store) Add(ctx context.Context, id, text string, metadata ...map[string]string) error + func (s *Store) AddBatch(ctx context.Context, items []struct{ ... }) error + func (s *Store) AddDocument(ctx context.Context, doc Document) error + func (s *Store) Count(ctx context.Context) (int, error) + func (s *Store) Delete(ctx context.Context, id string) error + func (s *Store) Search(ctx context.Context, query string, topK int) ([]Document, error) + func (s *Store) SearchVector(ctx context.Context, vector []float32, topK int) ([]Document, error) + type StreamChunk struct + Done bool + Text string + ToolCalls []ToolCall + Usage *Usage + type StreamResponse struct + Chunks <-chan StreamChunk + Err <-chan error + func GenerateToStream(ctx context.Context, p Provider, req *GenerateRequest) (*StreamResponse, error) + func (s *StreamResponse) Collect(ctx context.Context) (*GenerateResponse, error) + type SummarizeOption func(*summarizeConfig) + func SummarizeMaxLength(n int) SummarizeOption + func SummarizeModel(m string) SummarizeOption + func SummarizeStyle(s string) SummarizeOption + type Tool struct + Description string + Name string + Run any + func AllTools() []*Tool + func GetTool(name string) (*Tool, bool) + func (t *Tool) Execute(ctx context.Context, argsJSON json.RawMessage) (json.RawMessage, error) + func (t *Tool) Schema() json.RawMessage + func (t *Tool) ToSpec() ToolSpec + type ToolBuilder struct + func NewTool(name string) *ToolBuilder + func (b *ToolBuilder) Build() (*Tool, error) + func (b *ToolBuilder) Desc(desc string) *ToolBuilder + func (b *ToolBuilder) Handler(fn any) *ToolBuilder + func (b *ToolBuilder) Register() error + type ToolCall struct + Args json.RawMessage + ID string + Name string + type ToolSpec struct + Description string + Name string + Parameters json.RawMessage + func ToolSpecs() []ToolSpec + type TraceContext struct + ParentID string + SpanID string + TraceID string + func GetTraceContext(ctx context.Context) (TraceContext, bool) + type TracingConfig struct + Enabled bool + RecordPrompts bool + RecordResponses bool + ServiceName string + type Usage struct + CompletionTokens int + PromptTokens int + TotalTokens int + type VectorStoreBackend interface + Add func(ctx context.Context, doc Document) error + AddBatch func(ctx context.Context, docs []Document) error + Count func(ctx context.Context) (int, error) + Delete func(ctx context.Context, id string) error + Search func(ctx context.Context, vector []float32, topK int) ([]Document, error) + func NewMemoryVectorStore() VectorStoreBackend + func NewPgvectorStore(db *lucid.DB, opts ...PgvectorOption) VectorStoreBackend + func NewPineconeStore(host, apiKey string, opts ...PineconeOption) VectorStoreBackend + func NewQdrantStore(baseURL, collection string, opts ...QdrantOption) VectorStoreBackend + type VideoBuilder struct + func Video() *VideoBuilder + func (b *VideoBuilder) Duration(seconds int) *VideoBuilder + func (b *VideoBuilder) FPS(fps int) *VideoBuilder + func (b *VideoBuilder) FromImage(url string) *VideoBuilder + func (b *VideoBuilder) Generate(ctx context.Context) (*VideoResponse, error) + func (b *VideoBuilder) Model(model string) *VideoBuilder + func (b *VideoBuilder) Prompt(prompt string) *VideoBuilder + func (b *VideoBuilder) Size(size string) *VideoBuilder + func (b *VideoBuilder) WithClient(c *Client) *VideoBuilder + type VideoPipeline struct + func NewVideoPipeline() *VideoPipeline + func (p *VideoPipeline) ConcurrentScenes(n int) *VideoPipeline + func (p *VideoPipeline) DefaultDuration(seconds int) *VideoPipeline + func (p *VideoPipeline) DraftMode(draft bool) *VideoPipeline + func (p *VideoPipeline) ExpanderModel(model string) *VideoPipeline + func (p *VideoPipeline) Generate(ctx context.Context, prompt string) (*VideoProject, error) + func (p *VideoPipeline) GenerateWithSocial(ctx context.Context, prompt string) (*VideoProject, error) + func (p *VideoPipeline) GlobalStyle(style string) *VideoPipeline + func (p *VideoPipeline) ImageModel(model string) *VideoPipeline + func (p *VideoPipeline) MaxScenes(n int) *VideoPipeline + func (p *VideoPipeline) OnScene(fn func(scene Scene, stage string)) *VideoPipeline + func (p *VideoPipeline) OutputFmt(format OutputFormat) *VideoPipeline + func (p *VideoPipeline) PlannerModel(model string) *VideoPipeline + func (p *VideoPipeline) SeedVariants(n int) *VideoPipeline + func (p *VideoPipeline) VideoModel(model string) *VideoPipeline + func (p *VideoPipeline) WithClient(c *Client) *VideoPipeline + type VideoPipelineConfig struct + DefaultDuration int + DraftMode bool + ExpanderModel string + Format OutputFormat + GlobalStyle string + ImageModel string + MaxScenes int + OnScene func(scene Scene, stage string) + Parallelism int + PlannerModel string + Seeds int + VideoModel string + type VideoProject struct + Duration time.Duration + FinalVideoURL string + Format OutputFormat + ID string + Plan *ScenePlan + Prompt string + RenderDuration time.Duration + Scenes []Scene + Social *SocialPackage + type VideoProvider interface + GenerateVideo func(ctx context.Context, req *VideoRequest) (*VideoResponse, error) + type VideoRequest struct + Duration int + FPS int + ImageURL string + Model string + Prompt string + Size string + type VideoResponse struct + Duration int + Model string + URL string + type Workflow struct + func NewWorkflow(name string) *Workflow + func (w *Workflow) Branch(name string, selector func(wc *WorkflowContext) string, ...) *Workflow + func (w *Workflow) OnStep(h WorkflowHook) *Workflow + func (w *Workflow) Parallel(name string, steps ...NamedStep) *Workflow + func (w *Workflow) Run(ctx context.Context, input WorkflowInput) (*WorkflowResult, error) + func (w *Workflow) Step(name string, handler StepHandler) *Workflow + type WorkflowContext struct + func (wc *WorkflowContext) All() map[string]any + func (wc *WorkflowContext) Get(key string) any + func (wc *WorkflowContext) GetString(key string) string + func (wc *WorkflowContext) Set(key string, value any) + type WorkflowHook func(step string, event string, wc *WorkflowContext) + type WorkflowInput map[string]any + type WorkflowResult struct + Data map[string]any + Duration time.Duration + Steps []StepResult v1.2.0 Jul 15, 2026 v1.1.0 May 8, 2026 v1.0.1 May 8, 2026 v0 v0.1.9 Apr 23, 2026 v0.1.8 Apr 23, 2026 v0.1.7 Mar 16, 2026 v0.1.6 Mar 11, 2026 v0.1.5 Mar 11, 2026