Reference
Go packages (pkg/agent and pkg/tools)
Embed clai agents and tools directly in your own Go applications via pkg/agent and pkg/tools.
On this page
In addition to the clai CLI binary, the repository exports github.com/baalimago/clai/pkg/agent and github.com/baalimago/clai/pkg/tools so Go programs can embed clai’s multi-vendor agent loop and tool registry as a library.
Installing the Go module
go get github.com/baalimago/clai@latest
pkg/agent
pkg/agent provides a high-level agent abstraction that wraps clai’s vendor queriers, conversation history, system prompts, and tool execution loop. You can initialize an agent from existing clai configuration files or construct one programmatically with custom options.
pkg/tools
pkg/tools exposes the tool interface and builtin terminal tools (bash, rg, file_tree, find, write_file, web_search, website_text, recall) so you can register your own typed Go functions alongside clai’s builtin and MCP tools.
See the package READMEs in the clai repository for complete runnable Go examples.