ai is a .NET global tool that uses OpenRouter by default, or any OpenAI-compatible chat-completions endpoint you configure, to turn natural-language goals into shell commands or answer questions about your current workspace.
It is cross-platform and targets your current shell — PowerShell, bash, or zsh — automatically.
Install the global tool from NuGet:
dotnet tool install --global Ai.CliUpdate to the latest published version:
dotnet tool update --global Ai.CliThis puts the ai command on your PATH. It works the same on Windows, Linux, and macOS.
ai <goal...>generates a shell command for your current shell, displays it, and prompts for Enter-to-execute.ai -q <question...>/ai --question <question...>prints a plain text answer instead of generating a command.ai -r <follow-up...>/ai --resume <follow-up...>continues from the last history entry, sending the prior conversation as context for a multi-turn exchange.ai --bash <goal...>generates a bash command body and prints it asbash -lc "<command>".ai --shell <target> <goal...>generates a command for the specified shell (powershell,bash,zsh).ai -x <goal...>/ai --execute <goal...>generates a command, displays it, prompts for Enter-to-confirm, and runs it directly via the target shell.ai -f <path> .../ai --file <path> ...includes up to 3 files as additional context for command generation or-qanswers.ai -hs/ai --historyshows recent history (most recent 50 entries). Append search tokens to filter:ai -hs <terms...>. Resume entries are shown with theresumelabel.ai -nh/ai --no-historyskips recording the current invocation in history.ai --modelslists available model IDs from the configured provider alphabetically.ai --model <model-id> <goal...>overrides the configured default model.ai --versionprints the built tool version.ai --timing <goal...>prints timing information to stderr, including the AI call duration.
The tool reads JSON config from:
- Windows:
%USERPROFILE%\.config\ai\config.json - Unix:
$XDG_CONFIG_HOME/ai/config.jsonor~/.config/ai/config.json
History is stored as JSONL (one entry per line) in the same directory:
- Windows:
%USERPROFILE%\.config\ai\history.jsonl - Unix:
$XDG_CONFIG_HOME/ai/history.jsonlor~/.config/ai/history.jsonl
Supported keys:
{
"apiKey": "your-openrouter-api-key",
"baseUrl": "https://openrouter.ai/api/v1/",
"defaultModel": "openai/gpt-5-mini",
"defaultShell": "bash"
}baseUrl is optional. When omitted, ai defaults to https://openrouter.ai/api/v1/. For LM Studio, set baseUrl to http://localhost:1234/v1/ and choose a local defaultModel.
The defaultShell key accepts powershell, bash, or zsh. When omitted, the default is platform-specific: PowerShell on Windows, bash on Linux, zsh on macOS.
Environment overrides:
OPENROUTER_API_KEYoverridesapiKeyOPENROUTER_BASE_URLoverridesbaseUrl--modeloverridesdefaultModel--shellor--bashoverridesdefaultShell
OpenRouter requires an API key. Local providers such as LM Studio may not. If no model can be resolved, ai exits with a setup error.
Generate a command and run it (prompts for confirmation before executing):
ai list all files in the current directory, remove everything after the underscore and give me a distinct listThe generated command is displayed, and you are prompted:
Press Enter to execute, any other key to cancel
Press Enter to run it, or any other key to cancel.
Generate and execute a command directly with -x:
ai -x list all files in the current directoryGenerate a bash command wrapper:
ai --bash list all markdown files modified in the last dayAsk a question without generating a command:
ai -q what does src/Ai.Cli/AiApplication.cs doInclude files in the request context:
ai -q -f README.md -f src/Ai.Cli/AiApplication.cs summarize how the CLI behaves-f accepts up to 3 files and shares a 12,000-character budget across all included file contents.
List models from the configured provider:
ai --modelsPrint the installed tool version:
ai --versionPrint timing information while generating a command:
ai --timing list all files in the current directoryContinue from the last history entry (multi-turn conversation):
ai -q why would i want to use git lfs
ai -r i am not using github
ai -r what about for large video assetsEach -r invocation chains from the previous entry so the full conversation context is sent. Entries are saved to history with the resume kind and a back-link to the entry they continued from.
Search history for commands involving "dotnet":
ai -hs dotnetRun a command without recording it to history:
ai -nh list all files in the current directoryRestore and test:
dotnet restore tests/Ai.Cli.Tests/Ai.Cli.Tests.csproj
dotnet test tests/Ai.Cli.Tests/Ai.Cli.Tests.csproj --no-restorePack the global tool:
dotnet pack src/Ai.Cli/Ai.Cli.csproj -c ReleaseInstall from the local package output:
dotnet tool install --global --add-source ./src/Ai.Cli/bin/Release Ai.CliPushing a tag matching v* (e.g. v1.0.0) triggers a GitHub Actions workflow that packs the tool and publishes the NuGet package to nuget.org. The tag name (minus the v prefix) is used as the package version.