Kimi Code Moonshot APIAn 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.
Why this existsThe 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. FeaturesChat that feels like Claude Code
Agent capabilities
Approval modes (bottom of the chat)
Input affordances
Task history
Privacy & safety
Setup — step by stepStep 1: Get a Moonshot API key
Step 2: Install the extensionFrom the marketplace (once published):
From a local
Step 3: Open the Kimi sidebarClick 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
The chat view replaces the welcome panel. Your key is now in the OS credential store.
Step 5: (Recommended) Open a workspace folderMany of the tools ( Step 6: Send your first messageType any question and hit Enter. You should see a streaming response. The token/cost/balance footer appears under the input. Using the new affordancesSlash commands (
|
| 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:
- An approval card appears:
Write file src/utils.ts (+5 −2) - Click View diff to inspect (left = current file, right = proposed change in VSCode's native diff view)
- Approve to apply, Reject to discard
- The tool result is fed back to the model so it knows whether the edit landed
Command approval
When Kimi proposes a shell command:
- The card shows the full command and
cwd - Approve runs once. Approve & remember also adds an exact-match regex to
kimi.autoApprove.commandsso identical future commands auto-approve. Reject cancels. - Output (stdout + stderr + exit code, truncated to ~16 KB) is returned to the model
- 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.