Kimi Code CLI
Kimi Code CLI is an AI agent that runs in the terminal, assisting with software development tasks and terminal operations. It can read and edit code, execute shell commands, search web pages, and autonomously plan and adjust actions. The library is actively maintained with frequent updates, with the current version being 1.33.0.
Warnings
- gotcha The `cd` command does not change the working directory of Kimi Code CLI in shell mode. Each shell command runs in an independent subprocess, so directory changes are local to that process. To change the working directory, restart `kimi` in the target directory or use the `--work-dir` flag.
- gotcha On macOS, the first run of the `kimi` command may experience a delay due to security checks. Adding your terminal application to 'System Settings → Privacy & Security → Developer Tools' can speed up subsequent launches.
- gotcha Empty model list during `/login` or `Invalid API key` errors often indicate an incorrect or expired API key, or network connection issues to the API service.
- gotcha When providing input in print/wire mode, common issues include JSON format errors, encoding problems (ensure UTF-8), and line ending inconsistencies (Windows users should use `\n` not `\r\n`).
- gotcha Performance bottlenecks have been observed with large repositories, where tool calls might take multiple seconds due to overheads like full file reads, total cache invalidation, and multiple large operations on every step.
Install
-
uv tool install kimi-cli python@3.13 -
pip install kimi-cli
Imports
- kimi_cli
kimi
Quickstart
# Install Kimi CLI (recommended with uv and Python 3.13)
uv tool install kimi-cli python@3.13
# Verify installation
kimi --help
# Start Kimi CLI in interactive mode
kimi
# Inside Kimi CLI, use /setup to configure (e.g., API key)
# /setup
# Or, use kimi ask for a single question directly from the shell
export MOONSHOT_API_KEY="$(os.environ.get('MOONSHOT_API_KEY', ''))" # Ensure API key is set for non-interactive use
kimi ask "Generate a Python function to calculate the factorial of a number."
# To start an interactive chat session:
kimi chat