A powerful terminal AI agent powered by Moonshot AI's Kimi K2 model. This CLI tool provides interactive chat with tool-calling capabilities and autonomous agent spawning.
- 🤖 Interactive Chat: Have conversations with the Kimi K2 model in your terminal
- 🔧 Tool Calling: Built-in tools for file operations, shell commands, and web scraping
- 🚀 Agent Spawning: Generate and run autonomous Python agents
- 📝 Rich Output: Beautiful markdown rendering and colored output
- 🔌 Extensible: Easy to add custom tools
- Clone the repository:
git clone <repository-url>
cd kimi-cli
- Install the package:
pip install -e .
- Set up your environment:
# Create a .env file with your Moonshot AI API key
echo "MOONSHOT_API_KEY=your_api_key_here" > .env
Get your API key from Moonshot AI Platform
Start an interactive chat session with tool-calling capabilities:
kimi chat
This will start a REPL where you can:
- Chat with the AI
- Use built-in tools (file operations, shell commands)
- Use custom tools from the
tools/
directory
Generate and run autonomous Python agents:
kimi agent "create a python script that downloads the top HN stories and saves them to hn_top.json"
This will:
- Generate a Python script based on your prompt
- Save it to a temporary file
- Execute it automatically
The CLI comes with several built-in tools:
shell(command)
: Run arbitrary shell commandsread_file(path)
: Read local fileswrite_file(path, content)
: Write content to fileslist_directory(path)
: List directory contents
Add custom tools by placing Python files in the tools/
directory. Each tool should expose:
name
: Tool namedescription
: Tool descriptionparameters
: JSON schema for parametersfunc
: The actual function
Example tool structure:
name = "my_tool"
description = "Description of what this tool does"
parameters = {
"type": "object",
"properties": {
"param1": {"type": "string", "description": "Parameter description"}
},
"required": ["param1"]
}
def func(param1: str) -> str:
# Tool implementation
return "result"
web_get
: Fetch raw HTML/text from URLsaria2_download
: Download files using aria2c (supports HTTP, FTP, SFTP, magnet links, torrents)
Environment variables:
MOONSHOT_API_KEY
: Your Moonshot AI API key (required)KIMI_MODEL
: Model to use (default:kimi-k2-0711-preview
)
This CLI uses Moonshot AI's models:
- kimi-k2-0711-preview: Mixture-of-Experts model with 128K context window, 1 trillion parameters (32B active per forward pass)
- moonshot-v1-8k: Standard LLM with 8K context window
- Python 3.9+
- Moonshot AI API key
- For aria2 tool: aria2c binary on PATH