Try Kimi at kimi.com →

Kimi Code
Installation, Models & Coding Examples

Kimi Code is Moonshot AI's AI coding agent. It reads your project, edits code, runs commands and tests, and fixes what fails. This guide shows how to install it on macOS, Linux and Windows, which model to pick, which plan you need, and real examples to copy.

One-line install K3.1 Pro · up to 1M context CLI · Desktop · VS Code
~/my-app — kimi $ curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash ✓ kimi installed · checksum verified $ kimi Kimi Codemodel k3.1-pro · effort high › Add a kebab-case helper in src/utils with a unit test Read src/utils/index.ts Edit src/utils/kebab.ts +14 Edit src/utils/kebab.test.ts +22 Run npm test ✓ 12 passed · 0 failed Done. 2 files changed, tests pass.
OVERVIEW

What is Kimi Code?

Kimi Code is an AI agent for software development. Describe a task in plain words and it plans the steps, reads and edits files, runs shell commands and tests, searches and fetches web pages, then adjusts based on what happens. It is open source on GitHub and also powers Kimi Work.

6model IDs

From the K3.1 Pro flagship to fast K2.7 Code HighSpeed.

1Mtoken context

Holds a whole codebase on Pro / Allegretto plans and above.

4ways to use it

CLI, desktop app, VS Code, or inside other coding agents.

$19a month to start

Included in Kimi plans from Moderato (Plus).

What it can do

  • 1
    Write and change code: build features, fix bugs and finish refactors across many files.
  • 2
    Explain a project: explore an unfamiliar codebase and answer questions about how it works.
  • 3
    Automate chores: batch-edit files, run builds and tests, and chain scripts together.
  • 4
    Work in parallel: send built-in coder, explore and plan subagents off on focused jobs.
  • 5
    Watch videos: turn a screen recording or demo clip into working code.
  • 6
    Extend it: add MCP servers, Skills, plugins and lifecycle hooks.

Kimi Code at a glance

  • MakerMoonshot AI
  • Runs onmacOS, Linux, Windows
  • Default modelkimi-for-coding (K2.8 Preview)
  • Best modelk3.1-pro
  • Sign-inKimi account or API key
  • SafetyAsks before edits and commands
  • Data folder~/.kimi-code/
  • SourceOpen source on GitHub
CLIENTS

Four ways to use Kimi Code

They all share one Kimi account and one plan allowance, so you can switch between them freely.

Kimi Code CLI

The terminal agent. Fastest to install, works on macOS, Linux and Windows, and runs in scripts with kimi -p.

Install below ↓

Kimi Code Desktop

A desktop app for macOS (Apple silicon and Intel) and Windows, with a model picker in the Composer. Sign in with your Kimi account.

Kimi downloads →

VS Code extension

Install Kimi Code from the VS Code Marketplace and sign in from the sidebar. Choose the model from the input bar.

Editor setup ↓

Other coding agents

Use your Kimi Code plan in Claude Code, OpenCode, Codex or Hermes Agent, and in Zed or JetBrains through ACP.

Setup guides ↓
INSTALL

How to install the Kimi Code CLI

1. Run the installer

The official script needs no Node.js. It downloads the latest release, verifies the checksum and puts kimi on your PATH.

curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash

Windows needs Git for Windows first, because Kimi Code uses its Git Bash. For the best look, use a true-colour terminal such as Kitty or Ghostty.

2. Start it in your project

Open a new terminal, go to your project folder and run kimi.

Terminal
cd your-project kimi # open the interactive UI /login # first launch: Kimi Code OAuth or an API key kimi --version # check the install kimi upgrade # update to the latest version

To uninstall, delete the kimi file (script install) or run npm uninstall -g @moonshot-ai/kimi-code. Kimi Code keeps its data in ~/.kimi-code/, which you can move with KIMI_CODE_HOME.

FIRST RUN

First run and login

  1. 1

    Type /login

    On first launch Kimi Code asks you to choose a source. Kimi Code (OAuth) uses your Kimi plan: open the link on any device, sign in and enter the code shown. Kimi Platform API key uses a pay-as-you-go key from platform.kimi.ai.

    Kimi login guide →
  2. 2

    Let it learn your project

    Start with: "Take a look at this project's directory structure and briefly describe what each directory is for." Kimi Code reads and searches files on its own before it answers.

  3. 3

    Give it a real task

    Describe the change you want. It plans the steps, edits code, runs tests and reports what it did. It asks before it changes files or runs shell commands.

  4. 4

    Pick your model

    Type /model to switch, for example to k3.1-pro for hard problems. Start a new session after switching, because the old cache no longer applies.

MODELS

Kimi Code models

Which model should you pick?

  • ★
    Everyday coding: kimi-for-coding (K2.8 Preview). Close to K3, lighter on quota, on every plan.
  • ↑
    Hardest jobs: k3.1-pro for tricky bugs, big refactors and huge codebases.
  • ⚡
    Fast iteration: k3.1-pro-highspeed or kimi-for-coding-highspeed, at a higher quota cost.
  • ½
    Stretch your quota: k3-256k costs about half of k3 at 1M.

K3, K3.1 Pro and K2.8 Preview support low / high / max thinking effort. K3.1 Pro always thinks, so turning thinking off returns an error.

› /model ↑ ↓ to choose · Enter k3.1-pro K3.1 Pro ✓ selected k3.1-pro-highspeed K3.1 Pro Highspeed ✓ selected k3 K3 ✓ selected k3-256k K3 256K ✓ selected kimi-for-coding K2.8 Preview ✓ selected kimi-for-coding-highspeed K2.7 Code HighSpeed ✓ selected K3.1 ProFlagship · 1M · thinking always onPlus / Moderato+ K3.1 Pro Highspeed2–3× faster · about 2× quotaPro / Allegretto+ K3Previous flagship · up to 1MPlus / Moderato+ K3 256KHalf the quota of k3 (1M)Plus / Moderato+ K2.8 PreviewEfficient everyday coding · 1MAll Kimi Code plans K2.7 Code HighSpeed5–6× faster output · 256KPro / Allegretto+

Type /model to choose a model. Your plan decides which ones appear.

Model IDModelBest forContextSpeed and quotaPlan needed
k3.1-proK3.1 ProNewest flagship. Best for hard bugs, big refactors and long codebases.Up to 1MRegularPlus / Moderato and above
k3.1-pro-highspeedK3.1 Pro HighspeedSame as K3.1 Pro, about 2–3× faster output.Up to 1MAbout 2× quotaPro / Allegretto and above
k3K3Previous flagship with 2.8T parameters.Up to 1M1M uses about 2× the quota of k3-256kPlus / Moderato and above
k3-256kK3 256KK3 with a 256K context. Cheaper on quota. Images only, no video.256KAbout half of k3 (1M)Plus / Moderato and above
kimi-for-codingK2.8 PreviewClose to K3, thinks more efficiently. Great for everyday coding.Up to 1MRegularAll Kimi Code plans
kimi-for-coding-highspeedK2.7 Code HighSpeedK2.7 Code at about 5–6× the output speed. Thinking always on.256KAbout 3× quotaPro / Allegretto and above

Use the model ID exactly as shown. A mistyped ID silently falls back to K2.8 Preview without thinking. Source: Kimi Code model documentation. See also all Kimi models.

PLANS

Kimi Code plans and limits

Kimi Code isn't sold on its own. It comes with paid Kimi plans, which recently gained new names (shown in brackets). Kimi Code usage draws on your plan's allowance and has a rolling 5-hour limit.

PlanMonthlyKimi Code allowanceModelsContextHighSpeed
Adagio (free)$0Not included———
Moderato (Plus)$191×k3.1-pro, k3, k3-256k, kimi-for-coding256K for K3 modelsNo
Allegretto (Pro)$395×All six modelsUp to 1MYes
Allegro (Max)$9915×All six modelsUp to 1MYes
Vivace (Ultra)$19930×All six modelsUp to 1MYes

Allowance is shown relative to Moderato. Prices are in US dollars, and yearly billing costs less. Full details: Kimi AI pricing.

Using an API key instead? Third-party tools need a key from the Kimi Code Console (kimi.com/code/console). You can create up to 5 keys, and each is shown only once. Don't change your tool's User-Agent to get around limits, as Moonshot may suspend membership benefits.
COMMANDS

Commands and shortcuts

Slash commands

CommandWhat it does
/loginSign in with Kimi Code OAuth or a Kimi Platform API key
/modelSwitch model (start a new session afterwards)
/newStart a new session and clear the context
/sessionsBrowse and resume earlier sessions
/compactCompress the context to free up tokens
/forkCopy the session with its full history
/mcp-configAdd and sign in to MCP servers by chatting
/helpShow all commands and shortcuts
/logoutClear your saved credentials
/exitQuit Kimi Code

Keys and terminal commands

Key or commandWhat it does
Shift-TabTurn Plan mode on or off
EscStop the current output or close a popup
Ctrl-SSend a message while Kimi Code is still answering
Ctrl-OShow or hide tool output
Ctrl-C ×2Exit when idle
kimi -p "…"Run one task without the UI
kimi -cResume the previous session
kimi acpConnect Zed, JetBrains or another ACP editor
EXAMPLES

Kimi Code coding examples

Example: add a function with a test

This is the example from Kimi's own getting-started guide. Here is the session, and the kind of code it writes.

› Add a function in src/utils that converts any string to kebab-case, and add a unit test for it. ● Read src/utils/index.ts ● Write src/utils/kebab.ts ● Write src/utils/kebab.test.ts ● Run npm test (asks you first) ✓ 2 tests passed. Added kebabCase() and exported it from src/utils.

Example output. The exact code depends on your project and model.

Explore Explore Feature Feature Fix bug Fix bug Video → code Video → code › Explain this project's main directories › Add kebabCase() in src/utils with a test › npm test is failing. Find and fix the bug › Build this UI from the screen recording my-app/ ├─ src/← app code: routes, components │ └─ utils/← shared helpers ├─ tests/← unit and e2e tests ├─ scripts/← build and deploy scripts └─ package.json← deps and npm scripts src/utils/kebab.ts + export function kebabCase(s: string) { + return s + .replace(/([a-z])([A-Z])/g, '$1-$2') + .replace(/[\s_]+/g, '-') + .toLowerCase(); + } ✓ kebab.test.ts · 4 passed ✗ formatPrice › rounds to 2 decimals expected "19.99" · received "19.989" Read src/price.ts:12- return (n).toString();+ return n.toFixed(2); ✓ 48 passed · 0 failed <PricingCards><Card plan="Plus" /><Card plan="Pro" /></PricingCards>✓ matches the recording Drop in a screen recording or demo clip, and the agent watches it. $ kimi -p "..." runs one task in scripts and CI

Exploring a project, adding a feature, fixing a failing test and turning a video into code.

Prompts to copy into Kimi Code

Explore

Understand a new codebase

Take a look at this project's directory structure and briefly describe what each directory is for. Then explain how a request flows from the entry point to the database.

Feature

Add a feature with tests

Add a function in src/utils that converts any string to kebab-case, and add a unit test for it. Run the tests and tell me what you changed.

Fix

Fix a failing test

npm test is failing. Find the cause, fix the code rather than the test, run the full suite again and explain the bug in two sentences.

Refactor

Plan, then refactor

Plan first, don't edit yet: how would you split src/server.ts into smaller modules without changing behaviour? Wait for my approval before making changes.

Review

Review your changes

Review my uncommitted changes like a senior engineer. List bugs, security issues and missing tests, ordered by severity, with file and line numbers.

Video

Screen recording to code

Watch the attached screen recording and build this UI as a React component with Tailwind. Match the layout, spacing and hover states.

Run Kimi Code from scripts

Terminal
# Run one task without opening the UI kimi -p "Summarise what changed in the last 5 commits" # Resume the previous session kimi -c # Control this session from your phone (paid plans) kimi rc

Prompting tips for code

  1. Name the files, folders or functions involved.
  2. Say how to check the result, such as "run npm test".
  3. Use Plan mode (Shift-Tab) for big changes and approve the plan first.
  4. Ask it to explain changes, and review the diff before you commit.
  5. Use /compact or /new when a session gets long.
More Kimi prompts →
INTEGRATIONS

Use Kimi Code in VS Code, Zed, JetBrains and Claude Code

Claude Code with Kimi models

Create a key in the Kimi Code Console, set these variables, then run claude. This is the 256K setup. On Pro / Allegretto and above, use k3.1-pro[1m] and set both context values to 1048576.

export ANTHROPIC_BASE_URL=https://api.kimi.ai/coding/ export ANTHROPIC_API_KEY="YOUR_KIMI_CODE_KEY" export ANTHROPIC_MODEL="k3.1-pro" export ANTHROPIC_DEFAULT_FABLE_MODEL=$ANTHROPIC_MODEL export ANTHROPIC_DEFAULT_OPUS_MODEL=$ANTHROPIC_MODEL export ANTHROPIC_DEFAULT_SONNET_MODEL=$ANTHROPIC_MODEL export ANTHROPIC_DEFAULT_HAIKU_MODEL=$ANTHROPIC_MODEL export CLAUDE_CODE_SUBAGENT_MODEL=$ANTHROPIC_MODEL export CLAUDE_CODE_EFFORT_LEVEL=high export CLAUDE_CODE_AUTO_COMPACT_WINDOW=262144 export CLAUDE_CODE_MAX_CONTEXT_TOKENS=262144 claude

Run /status in Claude Code to check the base URL. Don't mix these variables with an env block in ~/.claude/settings.json.

Zed and JetBrains (ACP)

Log in to the CLI once, then point your editor at kimi acp. For Zed, add this and open a new chat in the Agent panel:

Zed settings.json
// ~/.config/zed/settings.json { "agent_servers": { "Kimi Code CLI": { "type": "custom", "command": "kimi", "args": ["acp"], "env": {} } } }

Base URLs for other tools

  • OpenAI-compatiblehttps://api.kimi.ai/coding/v1
  • Anthropic-compatiblehttps://api.kimi.ai/coding/
  • VS CodeKimi Code extension in the Marketplace
  • Also documentedOpenCode, Codex, Hermes Agent

These are the international endpoints. In third-party tools, set the context window to 1048576 to use the full 1M where your plan allows it.

TIPS

Tips for better results

Plan before big changes

Press Shift-Tab for Plan mode. Kimi Code reads and proposes a plan without editing anything until you agree.

New session after /model

Switching model or thinking effort clears the context cache. Start fresh with /new to avoid paying for the same tokens twice.

Save quota with k3-256k

k3 at 1M uses about twice the quota of k3-256k. Compact first if you move a long session down to 256K.

HighSpeed has limits

It only speeds up the model's replies. If most of the time goes on tests and builds, you'll see little difference.

Keep thinking on

K3.1 Pro rejects requests with thinking off. For K3 and K2.8 Preview, turning it off sends you to a non-thinking K2.8 Preview.

Add hooks and MCP

Use /mcp-config to connect tools by chatting, and lifecycle hooks to block risky commands or send notifications.

FIXES

Troubleshooting Kimi Code

kimi: command not found
  • Open a new terminal window so your PATH reloads.
  • Run kimi --version to check the install.
  • If you used npm, make sure your global npm bin folder is on your PATH.
Windows: shell or Git Bash errors
  • Install Git for Windows before the first launch. Kimi Code uses its Git Bash.
  • If Git Bash is in a custom location, set KIMI_SHELL_PATH to the full path of bash.exe.
The newest model isn't in /model
  • Run /logout, then /login again to refresh your model list.
  • Check your plan. K3.1 Pro Highspeed and kimi-for-coding-highspeed need Pro / Allegretto or above.
HighSpeed doesn't feel faster
  • Check the ID is exactly kimi-for-coding-highspeed. A typo silently falls back to a standard model.
  • HighSpeed only speeds up the model's replies. Running tests, scripts and file edits take the same time.
Error 400 with K3.1 Pro
  • K3.1 Pro only works with thinking on. Requests with thinking turned off are rejected.
  • In third-party tools, make sure thinking or reasoning is enabled.
Error 401 or usage limit reached
  • Your plan may not include that model. Upgrade, or switch to kimi-for-coding.
  • Kimi Code has a rolling 5-hour limit. Wait for it to reset, or buy Extra Usage.
  • Check the API key in your tool matches one from the Kimi Code Console.

More help: Kimi troubleshooting.

FAQ

Kimi Code FAQ

Kimi Code is Moonshot AI's AI coding agent. It reads and edits code, runs shell commands, searches files and fetches web pages, then decides its next step from the results. You can use it as a terminal CLI, a desktop app, a VS Code extension or inside other coding agents.

On macOS or Linux run curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash. On Windows install Git for Windows, then run irm https://code.kimi.com/kimi-code/install.ps1 | iex in PowerShell. You can also use npm install -g @moonshot-ai/kimi-code with Node.js 22.19.0 or later.

The Kimi Code CLI is free to install, but using it needs a paid Kimi plan, starting with Moderato (Plus) at $19 a month. Alternatively, you can sign in with a pay-as-you-go Kimi Platform API key.

Kimi Code offers six model IDs: k3.1-pro, k3.1-pro-highspeed, k3, k3-256k, kimi-for-coding (K2.8 Preview) and kimi-for-coding-highspeed (K2.7 Code HighSpeed). Type /model to switch.

kimi-for-coding runs K2.8 Preview, which is close to K3 in quality, thinks more efficiently and is available on every Kimi Code plan. k3.1-pro is the newest flagship, best for the hardest bugs and largest codebases, and needs Plus / Moderato or above.

Yes. Install the Kimi Code extension from the VS Code Marketplace. Zed and JetBrains connect to the CLI through the Agent Client Protocol by running kimi acp.

Yes. Create an API key in the Kimi Code Console, set ANTHROPIC_BASE_URL to https://api.kimi.ai/coding/ and set the model variables to a Kimi Code model ID such as k3.1-pro. Kimi Code also documents setups for OpenCode, Codex and Hermes Agent.

Read-only actions run automatically, but Kimi Code asks for your confirmation before it modifies files or runs shell commands. Plan mode (Shift-Tab) lets it plan without editing anything.

Kimi Code is a subscription coding agent that uses your Kimi membership quota and its own base URL, https://api.kimi.ai/coding/. The Kimi Platform API at platform.kimi.ai is pay-as-you-go by token, for building your own apps.

Kimi Code is for programmers and works in the terminal or code editor. Kimi Work is a desktop agent for everyday knowledge work such as reports, spreadsheets and slides, and its agent engine is built on Kimi Code.

Start coding with Kimi Code

Install in one line, sign in with /login, and give it your first task.