Skip to content
| Marketplace
Sign in
Visual Studio Code>Programming Languages>Kimi Code Moonshot APINew to Visual Studio Code? Get it now.
Kimi Code Moonshot API

Kimi Code Moonshot API

mazen-alameh

|
1 install
| (0) | Free
Agentic coding assistant for VSCode powered by Moonshot's Kimi K2.6 API. Bring your own Moonshot API key from platform.moonshot.ai — pay-per-use, no subscription. Unofficial, not affiliated with Moonshot AI.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Kimi Code Moonshot API

An agentic coding assistant for VSCode powered by Moonshot's Kimi K2.6 API. Bring your own Moonshot API key from platform.moonshot.ai — pay-per-use, no subscription. Works as a self-contained sidebar; does not require GitHub Copilot.

Unofficial. Not affiliated with or endorsed by Moonshot AI. "Kimi" and "Moonshot" are trademarks of their respective owners.


Why this exists

The official Kimi Code extension requires a Kimi Code subscription and a separate OAuth login. If you already pay Moonshot per-token from platform.moonshot.ai and want to use that key directly inside VSCode — this is the gap-filler. Cursor doesn't accept the Moonshot endpoint either, so this extension is the most direct way to use Kimi K2.6 on Windows / macOS / Linux without changing IDEs.


Features

Chat that feels like Claude Code

  • Streaming responses from Kimi K2.6 (256K context window)
  • Full markdown rendering with headings, lists, tables, blockquotes
  • Syntax-highlighted code blocks for js, ts, jsx, tsx, py, sh/powershell, json, yaml, html, css, go, rs, sql — each block has a one-click Copy button
  • Per-message Copy buttons: ⧉ corner button on user messages, "⧉ Copy" pill below every completed Kimi response
  • Live token counter and cost estimate in the footer, plus your remaining Moonshot balance fetched from /v1/users/me/balance

Agent capabilities

  • Read-only tools: read_file, list_files (with glob name_pattern to find files by name), search_files (regex content search)
  • Write tools with diff approval: write_file, apply_diff (structured search/replace hunks). Every change is previewed in VSCode's native diff view before anything is written
  • Shell tool with command approval: execute_command. Approve once, Approve & remember (allowlists the exact command), or Reject

Approval modes (bottom of the chat)

  • Ask permission (default) — approve every write and command
  • Accept edits — auto-approve file edits; still ask for shell commands
  • Plan mode — read-only research mode; the write/shell tools are filtered out before being sent to Moonshot, and the system prompt switches to "describe the change instead of making it"
  • Bypass permissions — auto-approve everything (use only in trusted, sandboxed workspaces)

Input affordances

  • / slash commands with autocomplete:
    • /help — list commands
    • /new / /clear — start a fresh task
    • /model <id> — switch model (e.g. /model kimi-k2-turbo-preview)
    • /history — open the task history panel
  • @ file mentions — type @, get a workspace file dropdown, pick one, file content is inlined into the message Kimi sees
  • + attach button — open VSCode's native file picker. Picked files appear as removable chips above the input. Caps: 1 MB per file, 4 MB total per turn

Task history

  • Every conversation auto-saves to globalStorage as JSON
  • History button in the header lists tasks with relative timestamps; click to load, click ✕ to delete
  • Survives VSCode restarts; loaded tasks resume cleanly with full context

Privacy & safety

  • API key stored in the OS credential store (Windows Credential Manager / macOS Keychain / Linux libsecret) via VSCode's SecretStorage — never written to settings.json, never logged, scrubbed from any error messages
  • Workspace path safety on every tool: .. traversal and absolute paths to other roots are rejected
  • Tool output is wrapped in <tool_output> tags with closing-tag escaping; the system prompt forbids the model from acting on instructions found in file contents
  • Hard caps: agent turns (default 25), tokens per task (default 500K), file size (1 MB read), shell timeout (5 min)
  • No telemetry

Setup — step by step

Step 1: Get a Moonshot API key

  1. Sign up at platform.moonshot.ai
  2. Add some credit (the API is billed per-token; pricing at platform.moonshot.ai/docs/pricing)
  3. From the dashboard, create an API key. It looks like sk-.... Copy it somewhere safe.

Step 2: Install the extension

From the marketplace (once published):

  • Open the Extensions panel (Ctrl+Shift+X) and search for Kimi Code Moonshot API, or run ext install <publisher>.kimi-code-moonshot-api in the command palette.

From a local .vsix (during development or sideload):

  • In the Extensions panel, click the … menu → Install from VSIX… and pick the .vsix file, or
  • From a terminal: code --install-extension kimi-code-moonshot-api-<version>.vsix

Step 3: Open the Kimi sidebar

Click the Kimi icon in the activity bar (left edge of VSCode). The first time it opens, you'll see the Welcome to Kimi Code Moonshot API panel.

Step 4: Configure your key + name

  1. Paste your Moonshot API key into the Moonshot API Key field (toggle "Show key" if you want to verify it)
  2. (Optional) Enter a display name — it's shown in the chat UI as your label, nothing more
  3. Click Save and start

The chat view replaces the welcome panel. Your key is now in the OS credential store.

If you ever want to change the key later, run Kimi: Set Moonshot API Key from the command palette (Ctrl+Shift+P), or click the ⚙ icon in the chat header.

Step 5: (Recommended) Open a workspace folder

Many of the tools (read_file, list_files, apply_diff, execute_command, @ mentions) need a workspace folder. Open one via File → Open Folder… before asking Kimi about a codebase.

Step 6: Send your first message

Type any question and hit Enter. You should see a streaming response. The token/cost/balance footer appears under the input.


Using the new affordances

Slash commands (/)

Type / at the start of an empty input. A dropdown appears. Use ↑/↓ to navigate, Tab/Enter to pick, Esc to dismiss.

Command What it does
/help Shows all commands as a markdown card
/new Starts a fresh task (current task is auto-saved)
/clear Same as /new
/model <id> Switches model. e.g. /model kimi-k2.6, /model kimi-k2-turbo-preview, /model kimi-k2-thinking
/history Loads the task list (also reachable via the History button)

Slash commands are handled locally — they don't consume tokens.

File mentions (@)

Type @ followed by part of a filename. A dropdown shows up to 10 matching workspace files. Pick one with Tab/Enter; the full workspace-relative path is inserted.

When you send the message, the content of every @-mentioned file is read fresh and inlined into the prompt, wrapped in an <attachment> tag so Kimi knows it's untrusted file data.

review @src/utils.ts and tell me if the error handling on line 14 is correct

File attachments (+ button)

Click the + button to the left of the input. Use VSCode's native file picker (multi-select supported). Files appear as chips above the input — click ✕ on a chip to remove.

Attachments are sent inline once with your next message, then cleared.

Caps: 1 MB per file, 4 MB total per turn (to keep token cost bounded).

Mode bar

Below the input, four chips control how approvals are handled:

Mode Writes (write_file, apply_diff) Shell (execute_command) Reads
Ask permission (default) Ask Ask Auto-approved
Accept edits Auto-approve Ask Auto-approved
Plan mode Tool disabled Tool disabled Auto-approved
Bypass permissions Auto-approve Auto-approve Auto-approved

In Plan mode, Kimi gets a system-prompt hint to describe what it would change rather than calling tools that don't exist. Switch back to Ask permission or Accept edits to actually make the changes.

Diff approval

When Kimi proposes an edit:

  1. An approval card appears: Write file src/utils.ts (+5 −2)
  2. Click View diff to inspect (left = current file, right = proposed change in VSCode's native diff view)
  3. Approve to apply, Reject to discard
  4. The tool result is fed back to the model so it knows whether the edit landed

Command approval

When Kimi proposes a shell command:

  1. The card shows the full command and cwd
  2. Approve runs once. Approve & remember also adds an exact-match regex to kimi.autoApprove.commands so identical future commands auto-approve. Reject cancels.
  3. Output (stdout + stderr + exit code, truncated to ~16 KB) is returned to the model
  4. The Stop button on the input area kills any running command

Copy buttons

  • User messages show a small ⧉ button in the corner of the role label — copies your typed message
  • Completed assistant messages show a "⧉ Copy" pill at the bottom — copies the full markdown text
  • Code blocks inside any assistant message have their own per-block Copy button in the header
  • All buttons flash ✓ for ~1 second after a successful copy

Configuration

All settings are under kimi.* and editable via VSCode's Settings UI (Ctrl+,).

Setting Default What it does
kimi.displayName "" Your name (display only, shown in the chat header)
kimi.model kimi-k2.6 Moonshot model id. Allowed: kimi-k2.6, kimi-k2.5, kimi-k2-turbo-preview, kimi-k2-thinking
kimi.mode ask Approval mode: ask / accept_edits / plan / bypass. Also editable from the bottom-of-chat mode bar
kimi.maxTurns 25 Max agent turns per task before stopping
kimi.maxTaskTokens 500000 Max total tokens per task before stopping
kimi.autoApprove.read true Auto-approve read-only operations (file reads, list, search)
kimi.autoApprove.write false Auto-approve write_file / apply_diff. Same effect as Mode = "Accept edits"
kimi.autoApprove.commands [] Regex patterns for execute_command allowlist. "Approve & remember" appends ^<exact-command>$ here
kimi.pricing.inputPerMillion 0.6 USD per 1M input tokens — cost-estimate footer only. Update to match Moonshot's current pricing
kimi.pricing.outputPerMillion 2.5 USD per 1M output tokens

The kimi.pricing.* defaults are placeholders. Update them to match the rates listed at platform.moonshot.ai/docs/pricing for accurate cost estimates.


Commands (command palette)

Command What it does
Kimi: New Task Reveals the sidebar and starts a fresh task
Kimi: Set Moonshot API Key Prompt for your API key and store it in SecretStorage
Kimi: Clear Moonshot API Key Remove the saved key
Kimi: Clear Conversation History Clear the current in-memory conversation (saved tasks remain on disk)

Development

# Install (postinstall also runs `npm install` in webview-ui/)
npm install

# Build host + webview
npm run compile

# Watch mode (concurrent esbuild + vite)
npm run dev

Open the project folder in VSCode and press F5 to launch an Extension Development Host with the extension loaded. Iterating: edit, save, reload the dev host (Ctrl+R).

If F5 prompts about a debugger port being in use, press Esc — the extension still loads, you just won't have the debugger attached.

To produce a sideloadable .vsix:

npm install -g @vscode/vsce
npm run compile
npx @vscode/vsce package
# Outputs kimi-code-moonshot-api-<version>.vsix in the repo root.

See PUBLISHING.md for the full marketplace publish flow (publisher setup, PAT, vsce publish) and SMOKE_TEST.md for the pre-release verification checklist.

Repo layout

src/                          extension host (TypeScript)
  extension.ts                activation
  config.ts                   constants (base URL, model, command ids)
  secrets.ts                  SecretStorage wrapper + key redaction
  api/
    moonshotClient.ts         OpenAI SDK pointed at api.moonshot.ai
    balance.ts                Moonshot user balance fetch
  agent/
    agentLoop.ts              ReAct loop: stream chat, dispatch tools
    systemPrompt.ts           system prompt (markdown style + safety rules)
    pathSafety.ts             reject paths outside the workspace
    diffProvider.ts           kimi-pending: scheme for diff-view content
    approval.ts               diff summary helpers
    modes.ts                  ApprovalMode + auto-decide + tool filtering
    slashCommands.ts          slash command registry
    attachmentStore.ts        + button + @ mention attachments
    tools/                    read_file, list_files, search_files,
                              write_file, apply_diff, execute_command
  persistence/taskStore.ts    JSON-per-task in globalStorageUri
  webview/
    provider.ts               sidebar host + agent orchestration
    messages.ts               host↔webview discriminated union
webview-ui/                   React app (Vite)
  src/
    App.tsx, store.ts, vscodeApi.ts, styles.css
    components/
      Chat.tsx, MessageBubble.tsx, MarkdownView.tsx, CodeBlock.tsx
      InputBox.tsx, SlashMenu.tsx, MentionMenu.tsx, AttachmentChips.tsx
      ModeBar.tsx, CopyButton.tsx
      ToolUseCard.tsx, ApprovalCard.tsx
      SettingsPanel.tsx, HistoryPanel.tsx

Troubleshooting

"No Moonshot API key set." — Open the Kimi sidebar, paste your key, or run Kimi: Set Moonshot API Key.

400 thinking is allowed but reasoning-content is missing in assistant tool at index N — This was a bug fixed in 0.8.x; if you see it on a fresh build, you're on an outdated bundle. Run npm run compile and reload the dev host.

Empty token / balance footer. — The footer only appears once Moonshot's API returns a usage block (after the first turn) and a balance from /v1/users/me/balance. If your account doesn't return either field, the footer stays hidden — the rest of the extension still works.

apply_diff keeps saying "search text not found". — The model's hunks must match the current file content exactly (whitespace-sensitive). Ask Kimi to re-read the file before re-trying.

Command times out. — Default is 5 minutes. Pass timeout_seconds in your prompt (e.g. "run X with a 20-minute timeout") or raise it for that turn.

Agent stops with "Reached the agent turn limit". — Send a follow-up message; the conversation continues from where it left off. To raise the cap, edit kimi.maxTurns.

Pricing footer is wrong. — Moonshot pricing changes; the defaults ($0.6 / $2.5 per 1M tokens) are placeholders. Set kimi.pricing.inputPerMillion / kimi.pricing.outputPerMillion to current rates.

@ autocomplete shows nothing. — Open a workspace folder (File → Open Folder). Mentions search files via vscode.workspace.findFiles, which needs a workspace.

Task history is empty after rename. — globalStorage is keyed by extension id. Renaming the package gave the extension a new id, so old tasks live under the previous id. Either revert the package name temporarily to recover them, or accept the fresh slate.


License

MIT — see LICENSE.


Disclaimer

Unofficial. This extension is not affiliated with or endorsed by Moonshot AI. "Kimi" and "Moonshot" are trademarks of their respective owners. The extension exists to let users who already pay Moonshot per-token use that API key inside VSCode without additional subscriptions.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft