Go library
askx exposes a clean, concurrent-safe Go API (CGO_ENABLED=0, no process os.Chdir, no writes to os.Stdout).
go get github.com/muthuishere/askx@v0.1.0Basic usage
Section titled “Basic usage”package main
import ( "context" "errors" "fmt" "log"
"github.com/muthuishere/askx")
func main() { ctx := context.Background()
// Create or update profiles.yaml programmatically cfg, _ := askx.LoadConfig("") cfg.Profiles["local"] = &askx.Profile{ BaseURL: "http://127.0.0.1:11434/v1", Style: "openai", Model: "qwen3.5:4b", Fallback: []string{"claude-cli"}, Category: "ops", Description: "Fast local triage", WhenToUse: "When summarizing long logs locally", } _ = askx.SaveConfig("", cfg)
// Run with host tools, schema validation, budgets, and policy guardrails res, err := askx.Ask(ctx, askx.Request{ Profile: "local", Prompt: "Summarize README.md", Files: []string{"README.md"}, Schema: `{"type":"object","properties":{"summary":{"type":"string"}},"required":["summary"]}`, MaxTokensBudget: 25000, }) if errors.Is(err, askx.ErrPolicyDenied) { log.Fatalf("policy refused a tool call: %v", err) } if errors.Is(err, askx.ErrBudgetExceeded) { log.Fatalf("budget exceeded: %v", err) } if err != nil { log.Fatal(err) } fmt.Println(res.Answer, res.Data)}Key exported APIs
Section titled “Key exported APIs”askx.Ask(ctx, req)— Synchronous completion with full tool loop,--schemavalidation, fallback chains, budgets, and audit logging.askx.AskStream(ctx, req, onEvent)— Streaming completion receiving typedStreamEventcallbacks (text,tool_call,tool_result,denied,done).askx.LoadConfig(home)/askx.SaveConfig(home, cfg)— Read and atomically writeprofiles.yaml(0600).askx.Catalog(home, category)/askx.RenderSubagentSkill(entry)— Enumerate annotated profiles/templates and generateSKILL.mddocuments programmatically.- Sentinel errors:
askx.ErrPolicyDenied,askx.ErrBudgetExceeded,askx.ErrConfig,askx.ErrUsage,askx.ErrIO.