cai is a small Go CLI that turns natural language into shell commands.
It does not execute generated commands. By default it prints the command, and with the zsh integration it can preload the command into your next prompt so you can review it and press Enter.
cai supports two generation providers:
codex: uses the Codex CLI. This is the default.openai: uses an OpenAI-compatible/chat/completionsHTTP server.
- Go
- For
codex: Codex CLI installed and available on yourPATH - For
openai: an OpenAI-compatible server, base URL, and model
Check cai:
cai doctorFrom this project directory:
go build -o cai .Install it somewhere on your PATH:
sudo mv cai /usr/local/bin/caiConfirm:
cai doctorGenerate a command:
cai what is in the file test.txtExample output:
cat test.txtOverride the provider or model for one command:
cai --provider openai --model google/gemini-3.1-flash-lite list large files hereConfigure a local OpenAI-compatible server:
cai config set provider openai
cai config set model google/gemini-3.1-flash-lite
cai config set openai.base_url http://localhost:11434/v1For the OpenAI API:
export CAI_PROVIDER=openai
export CAI_MODEL=your-model
export CAI_OPENAI_BASE_URL=https://api.openai.com/v1
export CAI_OPENAI_API_KEY=...API keys can be stored in the config file, but environment variables are usually safer for secrets.
To make generated commands appear in your next zsh prompt, add this to ~/.zshrc:
eval "$(cai init zsh)"Reload your shell:
source ~/.zshrcThen:
cai what is in the file test.txtwill place this into your prompt:
cat test.txtYou can edit it, cancel it, or press Enter to run it.
The default config file is:
~/.cai/config.jsonOverride it with:
export CAI_CONFIG=/path/to/config.jsonExample:
{
"provider": "openai",
"model": "google/gemini-3.1-flash-lite",
"codex": {
"command": "codex",
"reasoning_effort": "low"
},
"openai": {
"base_url": "http://localhost:11434/v1",
"api_key": ""
}
}Config commands:
cai config get model
cai config set provider codex
cai config set model gpt-5.3-codex-spark
cai config set codex.reasoning_effort low
cai config set openai.base_url http://localhost:11434/v1Environment variables override the config file:
CAI_CONFIG
CAI_PROVIDER
CAI_MODEL
CAI_CODEX_MODEL
CAI_CODEX_COMMAND
CAI_CODEX_REASONING_EFFORT
CAI_OPENAI_MODEL
CAI_OPENAI_BASE_URL
CAI_OPENAI_API_KEYRun tests:
go test ./...Build a local binary:
go build -o cai .