Skip to content

Latest commit

 

History

4 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cai

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 demo

cai supports two generation providers:

  • codex: uses the Codex CLI. This is the default.
  • openai: uses an OpenAI-compatible /chat/completions HTTP server.

Requirements

  • Go
  • For codex: Codex CLI installed and available on your PATH
  • For openai: an OpenAI-compatible server, base URL, and model

Check cai:

cai doctor

Build

From this project directory:

go build -o cai .

Install it somewhere on your PATH:

sudo mv cai /usr/local/bin/cai

Confirm:

cai doctor

Usage

Generate a command:

cai what is in the file test.txt

Example output:

cat test.txt

Override the provider or model for one command:

cai --provider openai --model google/gemini-3.1-flash-lite list large files here

OpenAI-Compatible Provider

Configure 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/v1

For 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.

zsh Integration

To make generated commands appear in your next zsh prompt, add this to ~/.zshrc:

eval "$(cai init zsh)"

Reload your shell:

source ~/.zshrc

Then:

cai what is in the file test.txt

will place this into your prompt:

cat test.txt

You can edit it, cancel it, or press Enter to run it.

Configuration

The default config file is:

~/.cai/config.json

Override it with:

export CAI_CONFIG=/path/to/config.json

Example:

{
  "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/v1

Environment 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_KEY

Development

Run tests:

go test ./...

Build a local binary:

go build -o cai .

About

A small Go CLI that turns natural language into shell commands

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages