SDK How-To Guides
Practical, task-focused guides for common SDK operations.
Getting Started
Section titled “Getting Started”- Open a Conversation - Use
sdk.Open()to get started - Send Messages - Send messages with
Send()andStream()
Tools & Functions
Section titled “Tools & Functions”- Register Tools - Add tools with
OnTool() - HTTP Tools - External API calls with
OnToolHTTP() - HITL Workflows - Approval with
OnToolAsync()
Variables & Templates
Section titled “Variables & Templates”- Manage Variables - Use
SetVar()andGetVar()
Context Management
Section titled “Context Management”- Manage Context - Configure token budgets and relevance-based truncation
Media Processing
Section titled “Media Processing”- Preprocess Images - Automatically resize and optimize images before sending to LLM providers
Observability
Section titled “Observability”- Monitor Events - Subscribe to events with
Subscribe()
Quick Reference
Section titled “Quick Reference”Open a Conversation
Section titled “Open a Conversation”conv, err := sdk.Open("./app.pack.json", "assistant")if err != nil { log.Fatal(err)}defer conv.Close()Send Message
Section titled “Send Message”resp, err := conv.Send(ctx, "Hello!")fmt.Println(resp.Text())Stream Response
Section titled “Stream Response”for chunk := range conv.Stream(ctx, "Tell me a story") { if chunk.Type == sdk.ChunkDone { break } fmt.Print(chunk.Text)}Register Tool
Section titled “Register Tool”conv.OnTool("get_time", func(args map[string]any) (any, error) { return time.Now().Format(time.RFC3339), nil})Set Variables
Section titled “Set Variables”conv.SetVar("user_name", "Alice")conv.SetVars(map[string]any{ "role": "admin", "language": "en",})Subscribe to Events
Section titled “Subscribe to Events”conv.Subscribe(hooks.EventSend, func(e hooks.Event) { log.Printf("Sent: %v", e.Data["message"])})By Use Case
Section titled “By Use Case”Building a Chatbot
Section titled “Building a Chatbot”Adding Function Calling
Section titled “Adding Function Calling”- Register Tools
- HTTP Tools (for external APIs)
Building Safe AI Agents
Section titled “Building Safe AI Agents”See Also
Section titled “See Also”- Tutorials - Step-by-step learning
- Reference Documentation - API reference
- Examples - Working code examples