How to install Kimi in VS Code — the Kimi Code extension, the CLI, and an API base-URL swap

There are three ways to install Kimi in VS Code, and the right one depends on whether you want a chat panel, a terminal agent, or to keep the editor setup you already have. The shortest route is the official Kimi Code extension from the Visual Studio Marketplace: install, sign in, pick a model, done in about two minutes. The second is the Kimi Code CLI, a terminal agent that also plugs into editors. The third — and the one most developers actually end up using — is changing one base URL in Cline, Roo Code, Kilo Code, Cursor or Claude Code so the agent you already trust runs on Kimi's models instead.

This guide covers all three with exact commands, the credentials you need first, the two API endpoints everyone mixes up, and the handful of errors that account for most failed setups. Windows, macOS and Linux are all covered. If you only want the fastest path, jump to the extension route. If you already run a coding agent, go straight to the base-URL swap.

Key takeaways

  • Official extension exists. Search "Kimi Code" in the VS Code Extensions panel — publisher must be moonshot-ai. Third-party lookalikes are on the Marketplace too.
  • Two endpoints, not one. OpenAI-compatible clients use https://api.moonshot.ai/v1; Claude Code and other Anthropic-protocol clients use https://api.moonshot.ai/anthropic. Mixing them up is the #1 cause of 404s.
  • The free chat tier doesn't cover this. Editor integration needs API credit or a Kimi Code subscription.
  • Region matters. api.moonshot.ai (international) and api.moonshot.cn (China) are separate platforms with non-interchangeable keys — the usual cause of a 401 on a brand-new key.
  • Windows CLI needs Git for Windows installed first; the CLI shells out through bundled Git Bash.
  • Model picking: kimi-k3 for general agentic work, kimi-k2.7-code for coding, -highspeed for roughly 5–6× faster output.

Three Ways to "Install" Kimi in Your Editor

Kimi is a hosted model from Moonshot AI, not a desktop app, so "installing" it always means installing a client that talks to Moonshot's servers. Pick the client that matches how you work:

Route What you get Best for
Kimi Code extensionChat + agent panel inside VS CodeFastest start. No config files.
Kimi Code CLITerminal agent that edits files, runs commandsAnyone already living in a terminal.
Base-URL swapKimi models inside Cline / Roo / Cursor / Claude CodeKeeping the workflow you already have.
Web chat (kimi.com)Browser chat, no editor accessTrying the model before paying anything.

New to the model itself? Start with what Kimi is and who builds it, or use it free in the browser before wiring anything into your editor.

Step 0 — Get Your Credentials First

All three routes need the same thing up front, and there are two ways to get it. They are not the same product and you only need one.

Option 1 — Pay-as-you-go API key. Create an account on the Kimi Open Platform, add credit, then generate a key under API Keys. The key is shown once; copy it immediately. A pay-as-you-go key with a zero balance returns errors even though the key itself is valid, so fund the account before you start debugging.

Option 2 — Kimi Code subscription. A monthly plan that bundles agent usage instead of billing per token. You sign in via OAuth from the CLI or extension and never paste a key. Kimi's consumer tiers run from $19 to $199 a month — full breakdown in our Chinese AI models pricing comparison.

The regional trap. Moonshot operates two separate platforms: the international one at api.moonshot.ai and the Chinese one at api.moonshot.cn. Keys created on one do not work on the other. If a brand-new key returns 401 Unauthorized, this is the first thing to check — before you touch any other setting.

Store the key as an environment variable rather than pasting it into a config file that might end up in Git:

# Windows PowerShell — current session
$env:MOONSHOT_API_KEY = "sk-..."

# Windows PowerShell — persistent (open a new terminal after)
setx MOONSHOT_API_KEY "sk-..."

# macOS / Linux
export MOONSHOT_API_KEY="sk-..."

The Two Endpoints That Decide Everything

Moonshot serves the same models over two different protocols, and choosing the wrong one produces confusing errors that look like authentication problems but aren't. This single table resolves most setup failures:

Base URL Protocol Clients that use it
https://api.moonshot.ai/v1OpenAI-compatibleCline, Roo Code, Kilo Code, Cursor, Continue, OpenAI SDK
https://api.moonshot.ai/anthropicAnthropic MessagesClaude Code and other Anthropic-protocol clients

Rule of thumb: if the tool asks for an "OpenAI-compatible" endpoint, use /v1. If it's Claude Code, the URL ends in /anthropic — not /v1, and not a CLI-only address.

Route 1 — Install the Official Kimi Code Extension

This is the two-minute route and the one to recommend if you just want Kimi answering questions about the file you're looking at.

Step 1 — Find the right extension

Open VS Code, press Ctrl+Shift+X (Cmd+Shift+X on macOS) and search for Kimi Code. Before clicking Install, check that the publisher reads moonshot-ai. The Marketplace also hosts unaffiliated extensions with near-identical names that wrap the same API — they may work, but they're not maintained by Moonshot and you're handing them your API key.

Step 2 — Install and reload

Click Install, then reload the window when prompted. The Kimi panel appears in the sidebar.

Step 3 — Sign in

Open the panel and pick your access method: OAuth if you have a Kimi Code subscription, or paste the API key from Step 0 if you're on pay-as-you-go.

Step 4 — Pick a model

Select kimi-k3 for general work, or kimi-k2.7-code / kimi-k2.7-code-highspeed for coding-specific tasks. See the model table below for what actually differs between them.

Route 2 — Install the Kimi Code CLI

Kimi Code CLI is Moonshot's terminal agent — it reads and edits files, runs shell commands, searches your project and decides its next step from the results, in the same shape as Claude Code or Codex. It's MIT-licensed and written in TypeScript.

Windows prerequisite. Install Git for Windows before you run the installer. The CLI executes shell commands through a bundled Git Bash and won't start without it. If your Git Bash lives somewhere unusual, set KIMI_SHELL_PATH to the full path of bash.exe.

# Windows (PowerShell)
irm https://code.kimi.com/kimi-code/install.ps1 | iex

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

# Optional, Windows only: custom Git Bash location
setx KIMI_SHELL_PATH "C:\Program Files\Git\bin\bash.exe"

Then launch it and authenticate:

kimi

# inside the prompt:
/login

/login offers two paths — Kimi Code OAuth (subscription) or a Moonshot Open Platform API key. Pick whichever you set up in Step 0.

Editor integration: the CLI speaks ACP (Agent Client Protocol), which gives it native integration with Zed and JetBrains IDEs. For VS Code specifically, the supported path is the extension in Route 1 — so on VS Code the CLI is a companion, not an embedded agent. One naming note: the project began as kimi-cli and is being renamed to kimi-code, with the installer migrating existing config and sessions automatically. You'll see both names in the documentation for a while.

Route 3 — Point Your Existing Agent at Kimi

If you already run Cline, Roo Code, Kilo Code, Cursor or Continue, you don't need a new extension at all. Every one of them speaks the OpenAI protocol, so Kimi drops in with a base-URL change. This is the route that keeps your prompts, rules files and habits intact — it only swaps the brain.

Cline, Roo Code and Kilo Code

All three ship a native Moonshot provider, so there's no manual endpoint editing:

  1. Open the extension's settings (gear icon) → Providers / API Provider.
  2. Choose Moonshot AI.
  3. Select the region endpoint that matches your account: api.moonshot.ai (international) or api.moonshot.cn (China).
  4. Paste your API key.
  5. Pick the model: kimi-k2.7-code or kimi-k3.

If your version doesn't list Moonshot, choose OpenAI Compatible instead and enter base URL https://api.moonshot.ai/v1, your key, and the model ID by hand. One practical tip: turn the browser tool off in Cline and Roo when running these models — agent runs are noticeably cleaner without it.

Cursor

In Settings → Models, enable your own OpenAI API key, switch on Override base URL, set it to https://api.moonshot.ai/v1, paste the Moonshot key, and add a custom model with the exact ID (kimi-k3). Be aware the override is global: while it's active, Cursor's own hosted models routed through that setting stop working. Removing the override reverts it. If you're weighing Cursor against the alternatives more broadly, we compared them in Cursor vs GitHub Copilot.

Continue

Add a model block to ~/.continue/config.yaml using provider openai, apiBase: https://api.moonshot.ai/v1, your key, and model: kimi-k2.7-code. The same pattern works for any OpenAI-SDK-based tool — the API is a drop-in swap, which is exactly how the GLM-5.2 install routes work too.

How to Run Kimi Inside Claude Code

This one deserves its own section because it uses the other endpoint and a specific set of environment variables. Moonshot documents the configuration officially:

# Windows PowerShell
$env:ANTHROPIC_BASE_URL   = "https://api.moonshot.ai/anthropic"
$env:ANTHROPIC_AUTH_TOKEN = "sk-..."          # your Moonshot key
$env:ANTHROPIC_MODEL      = "kimi-k3[1m]"
$env:ANTHROPIC_DEFAULT_OPUS_MODEL   = "kimi-k3[1m]"
$env:ANTHROPIC_DEFAULT_SONNET_MODEL = "kimi-k3[1m]"
$env:ANTHROPIC_DEFAULT_HAIKU_MODEL  = "kimi-k3[1m]"
$env:CLAUDE_CODE_SUBAGENT_MODEL     = "kimi-k3[1m]"
claude

# macOS / Linux
export ANTHROPIC_BASE_URL="https://api.moonshot.ai/anthropic"
export ANTHROPIC_AUTH_TOKEN="sk-..."
export ANTHROPIC_MODEL="kimi-k3[1m]"

Three details that save an afternoon of debugging:

  • Restart is mandatory. Claude Code reads these at launch; changing them mid-session does nothing.
  • Verify with /status, which shows the active base URL and model.
  • Don't use /model. The menu doesn't list Kimi models — switching happens through the environment variables, not the picker.

One warning that isn't in the official docs: set these variables per-session, not persistently. If you run setx on Windows (or add the exports to your shell profile), you hijack every Claude Code session, including the ones you want running on Anthropic's models. The clean pattern is a small launcher script that sets the variables and runs claude, kept out of your default PATH. Our Claude Code + VS Code guide covers the stock setup this is diverging from.

Which Kimi Model Should You Pick?

Model IDs are not interchangeable, and two of them will refuse your request outright if the client disables thinking. Here's what actually differs:

Model ID Thinking Use it when
kimi-k3On by defaultDefault choice. Works with no extra configuration.
kimi-k2.7-codeRequiredCoding-specific work. Rejects requests with thinking off.
kimi-k2.7-code-highspeedRequiredSame model, roughly 5–6× faster output. Long agent loops.
kimi-k2.6OptionalYou need thinking off for latency-sensitive tasks.

The [1m] suffix seen in Claude Code configs (kimi-k3[1m]) selects the 1M-token context variant — the capability Kimi is genuinely differentiated on, and the reason it prices like a Western lab rather than a budget Chinese model.

What Does It Actually Cost?

Kimi's editor integration is not free. The free Adagio tier at kimi.com covers browser chat only; the moment you point an editor at the API, you're on either metered tokens or a subscription.

On the API, Kimi K3 costs $3 per million input tokens and $15 per million output — the same headline rate as Claude Sonnet 5, and a useful reminder that "Chinese model" no longer implies "cheap." Cached input drops to $0.30 per million, a flat 10× discount that matters a lot for agent loops that re-send the same project context on every turn. The coding-tuned kimi-k2.7-code is listed considerably cheaper than K3, at roughly $0.95 in / $4.00 out per million tokens.

On subscription, Kimi's consumer ladder runs $19 (Moderato), $39 (Allegretto), $99 (Allegro) and $199 (Vivace) per month, with annual billing shaving roughly 20% off each. Which model is cheaper for you depends entirely on volume — run your real numbers through our Token Calculator, and if you're stuck on the general question, API vs subscription: which is actually cheaper works through the break-even math.

Verify the Install in 30 Seconds

Before blaming the extension, prove the credentials work. A direct API call isolates the problem instantly:

curl https://api.moonshot.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MOONSHOT_API_KEY" \
  -d '{"model":"kimi-k3","messages":[{"role":"user","content":"ping"}]}'

If that returns a completion and your editor still doesn't work, the fault is in the client configuration — wrong base URL, wrong model ID, or a stale process that needs restarting. If it fails too, the problem is the key, the region or the account balance. Never debug both layers at once.

Common Errors and What They Actually Mean

Symptom Real cause
401 on a brand-new keyKey belongs to .cn but you're calling .ai (or the reverse).
404 in Claude CodeBase URL ends in /v1 instead of /anthropic.
Request rejected when thinking is offkimi-k2.7-code and -highspeed require it. Use kimi-k2.6 if you need it off.
CLI won't start on WindowsGit for Windows missing, or KIMI_SHELL_PATH pointing at the wrong bash.exe.
Still answering as the old modelClient wasn't restarted after the config change.
Valid key, still failingAccount balance is zero. Pay-as-you-go stops at $0.

Is Kimi Worth Installing Instead of What You Have?

Installing it is easy; the harder question is whether it earns the slot. Kimi's differentiator is the 1M-token context window and long-horizon agentic work — it holds together across long, messy agent runs where context normally decays. That's a real advantage for large-codebase refactors and multi-file work. What it is not is a discount play: at $3/$15 on K3, you're paying Western flagship rates, so "switch to save money" only holds if you move to the cheaper k2.7-code tier.

Before you rewire anything, it's worth reading how it stacks up against the tools it would replace: Kimi vs Claude covers the head-to-head most developers are actually deciding, and Kimi vs DeepSeek covers the open-weight alternative that costs a fraction as much.

The Bottom Line

Installing Kimi in VS Code takes two minutes and one decision. If you want a chat panel, install the moonshot-ai extension and sign in. If you live in the terminal, run the CLI installer — and on Windows, install Git for Windows first. If you already have an agent you like, don't install anything new: change one base URL to https://api.moonshot.ai/v1, or to https://api.moonshot.ai/anthropic if that agent is Claude Code. Fund the account, keep the region straight, restart the client, and it works. Everything else on the internet about this is a variation on those four steps. Not sure Kimi is the right model for what you're building? Pickurai's 6-question wizard points you to the right AI in about 30 seconds.

Frequently Asked Questions

Is there an official Kimi extension for VS Code?

Yes. Moonshot AI publishes a Kimi Code extension on the Visual Studio Marketplace under the publisher ID moonshot-ai. Install it from the Extensions panel, reload the window, then sign in with either a Kimi Code subscription (OAuth) or a Moonshot API key. Check the publisher before installing — several unaffiliated extensions use near-identical names.

What base URL do I use for the Kimi API?

It depends on the protocol your tool speaks. OpenAI-compatible clients — Cline, Roo Code, Kilo Code, Cursor, Continue, the OpenAI SDK — use https://api.moonshot.ai/v1. Claude Code and other Anthropic-protocol clients use https://api.moonshot.ai/anthropic. Getting this wrong is the most common setup failure: an Anthropic client pointed at /v1 returns 404s that look like broken auth.

Can I run Kimi inside Claude Code?

Yes. Set ANTHROPIC_BASE_URL to https://api.moonshot.ai/anthropic, ANTHROPIC_AUTH_TOKEN to your Moonshot key and ANTHROPIC_MODEL to a Kimi ID such as kimi-k3[1m], then restart Claude Code and confirm with /status. The /model menu doesn't list Kimi models, so switch via environment variables rather than the picker.

Why does my Kimi API key return a 401 error?

Almost always because the key belongs to the wrong platform. Moonshot runs two separate services — api.moonshot.ai (international) and api.moonshot.cn (China) — and keys are not interchangeable. The second most common cause is a zero account balance: pay-as-you-go keys stop working when credit runs out, even though the key itself is still valid.

Which Kimi model should I use for coding in VS Code?

Use kimi-k3 for general agentic work — thinking is on by default and it needs no extra configuration. Use kimi-k2.7-code for coding-specific tasks, or kimi-k2.7-code-highspeed for the same model at roughly 5–6× faster output. Both k2.7 variants require thinking to be enabled and reject requests that disable it; pick kimi-k2.6 if you need thinking off.

Do I need a paid plan to use Kimi in VS Code?

Yes — either API credit or a subscription. The free chat tier at kimi.com doesn't cover editor integrations. Pay-as-you-go bills per token (Kimi K3 is $3 per million input, $15 per million output), while the Kimi Code subscription bundles agent usage into a monthly fee, with consumer tiers from $19 to $199 a month.

Does the Kimi Code CLI work on Windows?

Yes, but install Git for Windows first — the CLI runs shell commands through a bundled Git Bash and fails to start without it. Install with irm https://code.kimi.com/kimi-code/install.ps1 | iex, and if your Git Bash is in a non-standard location, point KIMI_SHELL_PATH at the full path of bash.exe.

Setup steps, endpoints and model IDs verified 8 August 2026 against Moonshot's Kimi API Platform documentation, the MoonshotAI/kimi-code repository README, the Visual Studio Marketplace listing and Kilo Code's Moonshot provider docs. K3 API rates and subscription tiers match our own Chinese AI pricing tracker (verified 6 August 2026); the kimi-k2.7-code rate is a vendor-listed figure we have not independently reconciled. Model line-ups and prices change often — check the platform before committing spend.