clai
Agentic harness focused on terminal workflows, following UNIX principles. No external dependencies, ideal for scripting/prototyping agentic apps, engine is also exposed as a package
About clai
Test coverage: 92.4% ππ
Get started
Installing:
curl -fsSL https://raw.githubusercontent.com/baalimago/clai/main/setup.sh | sh
You can also install via go:
go install github.com/baalimago/clai@latest
Or run it from the Nix flake without installing (flakes must be enabled):
nix run github:baalimago/clai
Then run:
clai | clai query Please give a concise explanation of clai
Install Glow for formatted markdown output when querying text responses.
man clai documents every command. setup.sh installs the page, and the first run of a new release in a terminal installs or updates it; clai man install does it on demand and CLAI_MANPAGE=off turns the automatic install off.
See clai.chat for details on usecase of all the features. Here's a brief summary:
Features
- Shell context injection - Inject shell context into the system prompt via configurable templates.
- Seamless conversation import - Ran out of session? Continue in clai!
- Agent Skills - Import skills from custom global directories, or project-level
.agents/skills. - Profiles - Pre-prompted profiles enabling customized workflows and agents, run locally or from the Hub.
- Model fallback - Name a verb (
strong,fast,cheap) instead of a model: each machine resolves it to its own ordered list and the run tries them in turn, so a shared profile runs anywhere. - Loop until verified - Add
-loopto a query and clai iterates toward the goal, accepting completion only when-checkpasses. - Structured output -
-response-formatreturns JSON instead of prose, from any vendor; Jev answers a fixed set of questions about the data you pipe in. - MCP client support - Add any MCP server you'd like by pasting their configuration.
- Images, both ways - Attach images with
-image, a glob or stdin to any model, and get images back through thegenerate_imagetool, or from an image-output model. - Sync, git-style -
clai cloud pullandcommitcarry your config and conversations between machines, only when you ask. - Reply only -
-reply-onlykeeps stdout for the answer and draws the progress on stderr. - Unix-like - Clai follows the unix philosophy and works with data piped in and out.
All of these features are easily combined and tweaked, empowering users to accomplish very diverse use cases. See examples for additional info and clai.chat for in-depth guides.
Featured supported vendors
| Vendor | Environment Variable | Models |
|---|---|---|
| Jev | TYPESAFE_API_KEY | System One evaluation, model jev-latest, questions from -response-format |
| OpenRouter | OPENROUTER_API_KEY | Text models, image models, use prefix or: |
| Ollama | OLLAMA_API_KEY | Use format ollama: (defaults to llama3), server defaults to localhost:11434 |
| Mistral | MISTRAL_API_KEY | Text models |
| OpenAI | OPENAI_API_KEY | Text models, photo models |
| DeepSeek | DEEPSEEK_API_KEY | Text models, key is optional, no prefix (defaults to deepseek-flash) |
| Gemini | GEMINI_API_KEY | Text models, photo models |
| Anthropic | ANTHROPIC_API_KEY | Text models |
Moved but never forgotten:
Frequently Asked Questions
What is clai?
clai is a Artificial Intelligence library for the Go programming language. Agentic harness focused on terminal workflows, following UNIX principles. No external dependencies, ideal for scripting/prototyping agentic apps, engine is also exposed as a package
How do I install clai?
Install clai with the Go module system using `go get baalimago/clai`. Check the repository for the current installation instructions.
What category does clai belong to?
clai is listed under Artificial Intelligence, specifically Artificial Intelligence.