Awesome Go

clai

CategoryArtificial Intelligence
SubcategoryArtificial Intelligence
Stars148

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

Command Line Artificial Intelligence

Wakatime Go Reference

Test coverage: 91.5% πŸ˜πŸ‘Œ

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

Then run:

clai | clai query Please give a concise explanation of clai

Either run bare clai (or clai <command> -h) or look at the examples for how to use clai. Prompt text starting with - is read as a flag, so pass it after --: clai q -- -why does this fail. If you have time, you can also check out this blogpost for a slightly more structured introduction on how to use Clai efficiently.

Install Glow for formatted markdown output when querying text responses.

Use clai as a Go library

Embed the agent loop in a Go program with github.com/baalimago/clai/pkg/agent:

// Supports strucutred output via types
// Support all things the CLI does
review, err := agent.NewTyped[Review](agent.WithModel("gpt-5.2")).Query(ctx, chat)

The agent runs silent and returns typed errors. See pkg/agent for the option surface, the command ban list and the token stoploss, and pkg/tools for the tool catalog.

Features

All of these features are easily combined and tweaked, empowering users to accomplish very diverse use cases. See examples for additional info.

Supported vendors

VendorEnvironment VariableModels
JevTYPESAFE_API_KEYSystem One evaluation, model jev-latest, questions from -rf
OpenRouterOPENROUTER_API_KEYText models, use prefix or:
OllamaOLLAMA_API_KEYUse format ollama: (defaults to llama3), server defaults to localhost:11434
HuggingFaceHF_API_KEYText models, use prefix hf:
MistralMISTRAL_API_KEYText models
OpenAIOPENAI_API_KEYText models, photo models
DeepSeekDEEPSEEK_API_KEYText models, key is optional, no prefix (defaults to deepseek-chat)
Berget AIBERGET_API_KEYText models, use prefix berget:
GeminiGEMINI_API_KEYText models, photo models
xAiXAI_API_KEYText models
InceptionINCEPTION_API_KEYText models
AnthropicANTHROPIC_API_KEYText models

Shell completions are also available:

# bash
mkdir -p ~/.local/share/bash-completion/completions
clai completion bash > ~/.local/share/bash-completion/completions/clai
# zsh
mkdir -p ~/.zsh/completions
clai completion zsh > ~/.zsh/completions/_clai

For zsh, ensure your fpath includes the completions directory before compinit, for example:

fpath=(~/.zsh/completions $fpath)
autoload -Uz compinit && compinit

Then restart your shell or reload your shell configuration.

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.

← Back to Artificial Intelligence