Kimi Code CLI: install, sign-in, plans and Claude Code setup
Kimi Code is Moonshot's coding plan and its terminal agent: install (2.8.1), sign-in over SSH, plans, models, headless -p, and Kimi's models in Claude Code.
“Kimi Code” is two things from Moonshot AI: the coding allowance inside a paid Kimi membership (from Plus up), and Kimi Code CLI, the MIT-licensed terminal agent that uses it. Install the CLI with curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash (a standalone binary, no Node.js) or npm install -g @moonshot-ai/kimi-code on Node.js 22.19+; it is 2.8.1 as of November 30, 2026, and the command is kimi. Sign in with kimi login, a device code you approve on any phone or laptop, so it works over SSH. The old Python Kimi CLI was archived on September 23, 2026 and will stop working. The catch: one-shot kimi -p runs edit files and run shell commands without asking. Kimi’s models also run inside Claude Code through Moonshot’s Anthropic-compatible endpoint.
What “Kimi Code” names
Moonshot uses the name for a subscription benefit and for a family of tools. Its membership help page defines the first: “Kimi Code is the developer-focused AI coding service within Kimi membership benefits.” The tools draw on it: “Requests from the CLI, VS Code, Desktop, and third-party tools all count toward that quota.”
| Name you will meet | What it is |
|---|---|
Kimi Code (the plan) | The coding quota in Kimi Plus, Pro, Max and Ultra memberships, shared by every tool you sign in |
Kimi Code CLI | The terminal agent, @moonshot-ai/kimi-code, command kimi, repository MoonshotAI/kimi-code, MIT |
Kimi Code Desktop, Kimi Code for VS Code | The same agent as an app and an editor extension |
Kimi CLI (Python) | The predecessor, kimi-cli on PyPI (last version 1.52.0), archived and read-only |
kimi-code on PyPI | A legacy alias of the Python kimi-cli, not the new agent |
That last row catches people: pip install kimi-code or uv tool install kimi-code gets you the archived Python tool. The current agent comes from the installer or npm.
Install Kimi Code CLI
# macOS and Linux: downloads a standalone binary, checks its SHA-256
curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
# Windows PowerShell (install Git for Windows first)
irm https://code.kimi.com/kimi-code/install.ps1 | iex
# npm, any OS with Node.js 22.19.0 or later
npm install -g @moonshot-ai/kimi-code
kimi --versionCopiedA piped installer runs whatever the URL serves at that moment, so read it first if that matters to you. The Linux and macOS script (served from cdn.kimi.com) supports x86_64 and arm64, refuses Alpine and other musl systems, needs no sudo, and puts the binary at ~/.kimi-code/bin/kimi (KIMI_INSTALL_DIR changes that). It also appends a PATH line to your .bashrc, .zshrc or fish config unless KIMI_NO_MODIFY_PATH is set, and pins a release if you set KIMI_VERSION. Open a new shell afterwards. The npm package’s engines field asks for >=22.19.0; if a global install fails on permissions, the npm install -g guide covers the fixes.
kimi upgrade updates in place (-y skips the question). By default the CLI also installs updates on its own in the background (auto_install under [upgrade] in ~/.kimi-code/tui.toml); KIMI_CODE_NO_AUTO_UPDATE=1 turns off the check, the background install and the prompt, which is what you want on a machine whose versions you pin. Releases are frequent: 2.7.1 through 2.8.1 shipped between November 20 and 26, with 2.9.0 canaries out since.
Coming from the Python Kimi CLI
The kimi-cli repository was archived on September 23, 2026, and its README is blunt: “Existing installations are no longer supported and will stop working.” Kimi Code CLI uses the same kimi command, and on first run it finds your ~/.kimi/ folder and offers to bring it over (or run kimi migrate). Config, MCP servers, input history and sessions move; your sign-in, MCP authorizations and plugins do not, so run /login again. The old folder is left untouched. Then remove the old tool, for example uv tool uninstall kimi-cli or brew uninstall kimi-cli. The Linux and macOS installer deals with the clash itself where it can: an old Python kimi launcher it finds on your PATH in a folder you can write to is renamed to kimi-legacy, and any further copies are deleted.
Signing in, on a server over SSH included
/login inside the agent offers two choices: Kimi Code (OAuth), for a membership, and a Kimi Platform API key from platform.kimi.ai (or platform.kimi.com in China), billed per token. The membership sign-in is a device-code flow; the docs’ instruction is to “open the link on any device, sign in, and enter the code to authorize.” Nothing has to reach the server, so it works in a plain SSH session, and kimi login runs the same flow without opening the interface. The result is kept under ~/.kimi-code/credentials/, a folder only your user can read (mode 0700, files 0600).
One behaviour differs from most agents: Kimi Code CLI does not read API keys from your shell. In the environment variable reference, “Running export KIMI_API_KEY=xxx in the terminal does not give any provider its key.” A key goes in ~/.kimi-code/config.toml, either as api_key, which the docs note is stored in plain text, or as api_key_env, which names a variable the agent reads on each request. The second keeps the key out of the config file:
# bash: the key is read without echo and saved to a file only you can read
mkdir -p ~/.kimi-code
read -rsp 'Kimi Platform API key: ' k; echo
(umask 077; printf 'export KIMI_API_KEY=%s\n' "$k" > ~/.kimi-code/kimi-key.env); unset k
# then, before starting kimi:
. ~/.kimi-code/kimi-key.envCopiedand in ~/.kimi-code/config.toml, assembled from the fields the configuration reference documents (no page of Kimi’s shows this exact combination):
default_model = "k3.1-pro"
[providers.kimi]
type = "kimi"
base_url = "https://api.moonshot.ai/v1"
api_key_env = "KIMI_API_KEY"
[models."k3.1-pro"]
provider = "kimi"
model = "kimi-k3.1-pro"
max_context_size = 1048576Copiedkimi doctor config checks the file without changing it. The CLI recognises a model’s abilities from its name; the reference says a model it does not cover needs capabilities declared on its [models] entry, so if requests to K3.1 Pro come back rejected for thinking being off, that is the field to look at. The same file takes Anthropic, OpenAI, Bedrock and Google providers (types anthropic, openai, openai_responses, bedrock, google-genai, vertexai), so the agent is not tied to Kimi’s models. To keep a session alive after you disconnect, start it inside tmux.
Kimi Code plans
Kimi Code comes with Kimi’s paid memberships, Plus, Pro, Max and Ultra, priced on Kimi’s own site. The coding quota draws on the membership’s monthly credit pool: when that runs out, the quota is “frozen until the monthly quota resets or you upgrade.” Kimi’s help pages give no request counts per plan. Every signed-in device and every Kimi Code API key shares the one quota.
Read the community guidelines before automating anything:
Kimi Code subscriptions are for interactive use only.CopiedThey name “scripted batch execution or data annotation pipelines” as going beyond normal use, forbid sharing access through a reverse proxy, and list “limiting concurrent access” among the responses. Scheduled jobs belong on a Kimi Platform key, billed per token at the rates on the platform’s pricing page; there, kimi-k3.1-pro and kimi-k3 also take batch requests at 60% of the standard price.
Models
The membership exposes these model IDs, per the model configuration page:
| Model ID | Context | Plan |
|---|---|---|
k3.1-pro | 256K, or 1M from Pro | Plus and up |
k3 | 256K, or 1M from Pro | Plus and up |
k3-256k | 256K, no video input | Plus and up |
kimi-for-coding | 1M; this ID is K2.8 Preview | Plus and up |
k3.1-pro-highspeed | Up to 1M; about 2–3× the speed at 2× the quota | Pro and up |
kimi-for-coding-highspeed | 256K; K2.7 Code, about 6× the speed at 3× the quota | Pro and up |
Two caveats from the same page matter in any client. K3.1 Pro “only support[s] thinking mode”: a request with thinking off is rejected with a 400. And “A mistyped model ID falls back to K2.8 Preview without thinking”, with no error, so a typo quietly gives you a different model. A 403 usually means your plan lacks the model or the context size you asked for. Switching model or effort mid-session throws away the context cache, which costs a fresh prefill. On the pay-as-you-go platform the IDs carry a kimi- prefix (kimi-k3.1-pro, kimi-k3), and the K2 models are closed to new users since October 31, 2026 and retire at the end of December.
Where it keeps its files
| Path | What it holds |
|---|---|
~/.kimi-code/config.toml | Providers, models, default_model, permission rules |
~/.kimi-code/tui.toml | Interface preferences |
~/.kimi-code/credentials/ | Sign-in credentials, one file per provider; MCP tokens under mcp/ |
~/.kimi-code/AGENTS.md | Your instructions for every project, Kimi only |
~/.agents/AGENTS.md | Instructions shared with other agents |
~/.kimi-code/mcp.json | Your MCP servers, merged with a project’s .kimi-code/mcp.json |
~/.kimi-code/sessions/ | Session history, per workspace |
~/.kimi-code/logs/kimi-code.log | The diagnostic log |
~/.kimi-code/bin/kimi | The binary, if the installer put it there; the folder also caches the rg and fd tools the agent downloads |
KIMI_CODE_HOME moves all of it. In a repository the agent reads the project’s AGENTS.md (more on that file in what AGENTS.md is). KIMI_DISABLE_TELEMETRY=1 turns off its anonymous telemetry.
Headless runs: -p approves everything
Interactively the default is Always Ask: reads run on their own, edits and commands wait for you. /yolo (or --yolo) switches to Ask When Needed, which runs routine edits and commands but still asks before touching things like .env files or SSH keys. /auto (or --auto) is Never Ask, where “every tool approval is handled automatically, including sensitive files”, and commands such as rm -rf run without interruption. The docs’ warning for the middle mode: “Use it only in trusted working directories.”
The one-shot mode is the part to read twice. From the command reference:
--prompt cannot be used with --yolo, --auto, or --plan — non-interactive mode uses auto permission by defaultCopiedSo every kimi -p run uses the same auto permission as Never Ask, and there is no flag to make it ask: in the reference’s words, “Regular file operations and shell commands are allowed automatically.” The only brake is the deny rules in your config.toml, which “still apply”. Whatever the prompt leads the model to do, edit, delete or run, it does without asking you. Run it as an ordinary user, never as root, in a directory you can afford to lose or have committed to git.
kimi -p "Run the tests and summarize failures"
kimi -p "Review the last commit" --output-format stream-json
kimi -c -p "Now fix the first failure" # continue the latest session hereCopiedExit code 0 is success, 1 covers bad arguments, an error, or “model authentication not ready”, and 4 means another process holds the session you named with -c or -S. For anything on a timer, sign in with a Platform key rather than the membership, for the guideline above.
Kimi’s models in Claude Code
Moonshot documents two routes, one per way of paying, and they differ in host, variable and model names:
| With a Kimi membership | With a Kimi Platform key | |
|---|---|---|
Key from | The Kimi Code Console | platform.kimi.ai |
ANTHROPIC_BASE_URL | https://api.kimi.ai/coding/ | https://api.moonshot.ai/anthropic |
Key variable | ANTHROPIC_API_KEY | ANTHROPIC_AUTH_TOKEN |
Model | k3.1-pro or k3.1-pro[1m] | kimi-k3[1m] |
Effort | high | max |
Moonshot’s guide | Kimi Code docs | Platform docs |
Both put the model into every slot Claude Code has, so nothing falls back to a Claude model name. The membership route in ~/.claude/settings.json, from Moonshot’s page, 256K variant:
{
"env": {
"ANTHROPIC_BASE_URL": "https://api.kimi.ai/coding/",
"ANTHROPIC_API_KEY": "<your Kimi Code API key>",
"ANTHROPIC_MODEL": "k3.1-pro",
"ANTHROPIC_DEFAULT_FABLE_MODEL": "k3.1-pro",
"ANTHROPIC_DEFAULT_OPUS_MODEL": "k3.1-pro",
"ANTHROPIC_DEFAULT_SONNET_MODEL": "k3.1-pro",
"ANTHROPIC_DEFAULT_HAIKU_MODEL": "k3.1-pro",
"CLAUDE_CODE_SUBAGENT_MODEL": "k3.1-pro",
"CLAUDE_CODE_EFFORT_LEVEL": "high",
"CLAUDE_CODE_AUTO_COMPACT_WINDOW": "262144",
"CLAUDE_CODE_MAX_CONTEXT_TOKENS": "262144"
}
}CopiedFor 1M context (Pro and up) use k3.1-pro[1m] and 1048576. The key sits in that file in plain text, so keep it out of git and run chmod 600 ~/.claude/settings.json. Moonshot’s caveats, from both pages:
- The
envblock overrides the same variables exported in your shell, so a staleANTHROPIC_*value in either place wins over what you meant. Clear old ones fromsettings.json,.bashrcand.zshrcfirst. - “Configuring only some of the variables makes the corresponding scenarios fail silently”, so set every slot.
/statusshould show the Kimi base URL; the model can still display under a Claude name.- Moonshot recommends its native endpoints over a translating proxy, which “may cause behavior to vary”.
- The membership’s interactive-only rule applies here too, and Claude Code’s requests draw on the same quota as Kimi’s own tools.
The Claude Code environment variables guide explains what each of these slots controls, and Claude Code Router is the option if you want to switch between several providers rather than hard-wire one. Z.ai’s plan for its GLM models connects to Claude Code through the same variables; its prices and setup are in the GLM Coding Plan.
Other agents
The membership also serves an OpenAI-compatible endpoint, https://api.kimi.ai/coding/v1 (api.kimi.com in China), and Moonshot’s docs carry setup pages for OpenCode, Codex and Hermes Agent beside the Claude Code one; the guidelines name OpenClaw among compatible tools as well. Kimi Code CLI can also pull in recent Claude Code and Codex sessions with kimi import-sessions, and serves editors that speak the Agent Client Protocol through kimi acp. For how it sits among the other terminal agents, including Qwen Code, Alibaba’s counterpart, see the Claude Code alternatives guide.