Kimi Code CLI with QCode: Windows & macOS walkthrough, one screenshot per step
Follow 14 steps and 14 screenshots to install Kimi Code CLI 2.7.2 on Windows 11 or macOS with the official PowerShell script, put your QCode cr_ key setup into config.toml, and send prompts with kimi -p and the TUI.
Need an API key? Sign up →Endpoints & base URLs →
On This Page
- Download and install
- Follow the screenshots: Windows, one step at a time
- Open Windows PowerShell and run the install command
- Check that kimi is installed
- Set QCODE_API_KEY
- Confirm the config folder is .kimi-code
- Write the three providers into config.toml
- Check the config with kimi doctor
- Test one prompt with kimi -p before opening the UI
- Try the third alias with another prompt
- Enter the TUI and trust the current folder
- Confirm the model on the welcome screen
- Inspect the three providers with /provider
- View available models with /model
- Switch to gpt-6.2-sol and send "你好" (Hello)
- Check this request on probe.qcode.cc
- Verify it works
- Common errors
- FAQ
- Where is the config file actually stored?
- How do I make the API key persist across sessions?
- Startup immediately reports a provider is missing credentials?
- Does picking a model in /model change the default model?
- Why is the model name shown in the TUI different from the alias?
- What happens when my key expires?
- Connection overview
- Which protocol
- Other install methods (macOS / Linux and npm)
- Minimal config.toml
- Configure Claude (type = "anthropic")
- Configure GPT and Chinese models (type = "openai")
- Command-line verification
- Known limitations and troubleshooting
- Desktop and the CLI
- Older kimi-cli
- Related
Follow the 14 steps below to install Kimi Code CLI on Windows 11 or macOS and connect it to QCode, so it can answer your questions both from the command line and inside the terminal interface.
Short answer: In Windows PowerShell, paste irm https://code.kimi.com/kimi-code/install.ps1 | iex to install Kimi Code CLI 2.7.2, point the base_url of three providers in %USERPROFILE%\.kimi-code\config.toml at QCode with api_key_env = "QCODE_API_KEY" for the key, then type kimi to start chatting.
| Item | Fill in |
|---|---|
Endpoint address (Claude / anthropic) |
https://api.qcode.cc/api |
Endpoint address (OpenAI-compatible / openai_responses) |
https://api.qcode.cc/openai/v1 |
| Config file | %USERPROFILE%\.kimi-code\config.toml |
| Key environment variable | QCODE_API_KEY |
| Key format | cr_xxxxxxxx |
Checked on 2026-11-22 · Kimi Code CLI 2.7.2 · Windows 11
Kimi Code CLI is Moonshot AI's coding assistant that runs in the terminal. It divides model sources into several categories, and the two for "connecting Claude with an Anthropic API key" and "connecting third-party inference services via the OpenAI-compatible protocol" match the two endpoints QCode exposes — so a single QCode key lets you use Claude, GPT, and Chinese models in the same tool.
The entire process requires no Kimi account and no login: the key is read only from the environment variable specified by api_key_env. The one prerequisite on Windows that is easy to miss is Git for Windows — Kimi relies on its bundled Git Bash to run commands, and without it your first prompt fails right away, so this walkthrough puts it in the checklist before you start.
On a Mac? Run the same steps in Terminal. The screenshots show Windows PowerShell; on macOS, set a variable with
export NAME="value"instead of$env:NAME = "value", and read%USERPROFILE%\as~/in file paths.
- The PC or Mac runs Windows 10 / 11 (64-bit) or macOS and can open Windows PowerShell or
Windows 终端(Windows Terminal) - Git for Windows (with Git Bash) is already installed. If not, run
winget install --id Git.Git -ein Windows PowerShell first, and click是(Yes) if用户账户控制(User Account Control) prompts you - You have registered on QCode.cc and copied an API key starting with
cr_from the Dashboard. No account yet? Sign up for QCode first, choose a plan on the pricing page, then create a key in the Dashboard. - The PC can reach
code.kimi.com,qcode.cc,api.qcode.cc, andprobe.qcode.cc; if downloads fail, check the region notes under Download and install below - Set aside 15 uninterrupted minutes and do not close that PowerShell window partway through
Download and install¶
Kimi Code CLI has no installer package and no separate x64 / ARM64 builds to pick between: on Windows it is a single PowerShell command. The script resolves the latest version, downloads an archive of about 53 MB, verifies its checksum, and puts kimi on your user PATH.
The three sources you will use:
- Install script:
https://code.kimi.com/kimi-code/install.ps1(official, for Windows) - npm package:
@moonshot-ai/kimi-code, see https://www.npmjs.com/package/@moonshot-ai/kimi-code, requires Node.js 22.19.0 or later - Git for Windows: https://gitforwindows.org/, winget id is
Git.Git
Regional differences are mainly in download channels. Pick your region first:
Europe / Japan
- The official install script, npm, and winget all work directly:
winget install --id Git.Git -einstalls Git, andnpm install -g @moonshot-ai/kimi-codeinstalls the CLI. - You can also download the Git for Windows installer from gitforwindows.org.
- The install script goes through
code.kimi.com, which is normally reachable directly.
Mainland China
- The official install script goes through
code.kimi.com, which is normally reachable directly. To inspect what the script does first, open https://code.kimi.com/kimi-code/install.ps1 in a browser. - If the script will not open temporarily, switch to npm: run
node --versionfirst to confirm Node.js 22.19.0 or later, then runnpm install -g @moonshot-ai/kimi-code. - If the default npm registry is slow or drops connections, switch temporarily to a mirror:
npm config set registry https://registry.npmmirror.com. - Install Git for Windows from the official site, or download the same-version installer from a mirror; remember to open a new terminal window after installing.
Arab countries
- The channels are the same as Europe / Japan: the official install script, npm, winget, and gitforwindows.org all work.
- The install script goes through
code.kimi.com, which is normally reachable directly.
Russia / Iran
- If the official install script will not open, use npm instead:
npm install -g @moonshot-ai/kimi-code; if the default npm registry is slow, switch tohttps://registry.npmmirror.com. - Install Git for Windows from gitforwindows.org; if that fails, use a mirror for the same-version installer.
- Whichever route you take, confirm the command works at the end with
kimi --version.
Follow the screenshots: Windows, one step at a time¶
The 14 steps below each do one thing. Run all commands in the same Windows PowerShell window; the orange numbers on the screenshots match ①②③ in the text one to one — when you see a number, look at the same spot in the screenshot.
Open Windows PowerShell and run the install command¶
Click the Start menu, type Windows PowerShell or Windows 终端 (Windows Terminal), and open the window. Paste the line below and press Enter:
irm https://code.kimi.com/kimi-code/install.ps1 | iex
After you press Enter, the script resolves the latest version, downloads an archive of about 53 MB, and verifies the checksum; wait one or two minutes. The last three lines are the key ones: ① says it was installed to %USERPROFILE%\.kimi-code\bin\kimi.exe, ② says it was added to your user PATH, and ③ tells you to open a new terminal and run kimi --version.

Done right you will see: the last three lines reporting the install path, that it was added to your user PATH, and a prompt to open a new terminal and run kimi --version.
Stuck? It says irm is not recognized as an internal or external command
You opened 命令提示符 (Command Prompt, CMD), which does not understand irm. Close that window, open Windows PowerShell or Windows 终端 (Windows Terminal) from the Start menu again, and paste the command once more. If the download drops midway, run the same command again and the script will start over.
Check that kimi is installed¶
Close the previous window and open a fresh Windows PowerShell — only a new window picks up the updated PATH. At ① type kimi --version and press Enter; ② outputs 2.7.2.

Done right you will see: a single line reading 2.7.2. The trailing version digits may differ, and seeing any version number means the command is ready.
Stuck? It says kimi is not found
The current window still has the old PATH. Close the window completely (do not just minimize it), open a new Windows PowerShell, and try again; if it still fails, go back to step 1 and run the install command again.
Set QCODE_API_KEY¶
At ① type the line below, replacing cr_xxxxxxxx with your own key, and press Enter:
$env:QCODE_API_KEY = "cr_xxxxxxxx"
When pressing Enter prints nothing and returns straight to the prompt, it worked. A variable set this way applies only to this window and disappears when the window closes, so run every remaining step in this same window.

Done right you will see: the next prompt line right after pressing Enter, with no error and without printing the key back out.
Need an API key?
If you do not have a QCode account yet, Sign up first. If you prefer to pay by usage, buy a Pay-as-you-go Pack first, then create the key in the Dashboard. Copy the whole string starting with cr_ and paste it back above. You can pay by credit/debit card (Visa / Mastercard), Apple Pay / Google Pay, or cryptocurrency — see Payment methods.
Confirm the config folder is .kimi-code¶
The install script has already created the config directory; this step just confirms its path. Run these two lines one after the other:
mkdir $HOME\.kimi-code -Force | Out-Null
Get-ChildItem $HOME\.kimi-code | Select-Object Name
In the listing, ① is bin and ② is region, confirming the config folder is %USERPROFILE%\.kimi-code. Note that it is .kimi-code, not .kimi from the older kimi-cli.

Done right you will see: two lines under Name, bin and region, with no errors.
Write the three providers into config.toml¶
Open %USERPROFILE%\.kimi-code\config.toml in Notepad (记事本), paste the entire block below, and save:
# ~/.kimi-code/config.toml
default_model = "qcode-haiku"
[providers.qcode-anthropic]
type = "anthropic"
base_url = "https://api.qcode.cc/api"
api_key_env = "QCODE_API_KEY"
[providers.qcode-openai]
type = "openai"
base_url = "https://api.qcode.cc/openai/v1"
api_key_env = "QCODE_API_KEY"
[providers.qcode-responses]
type = "openai_responses"
base_url = "https://api.qcode.cc/openai/v1"
api_key_env = "QCODE_API_KEY"
[models.qcode-haiku]
provider = "qcode-anthropic"
model = "claude-haiku-5-5"
max_context_size = 200000
[models.qcode-dsflash]
provider = "qcode-openai"
model = "deepseek-v4-flash"
max_context_size = 128000
[models.qcode-gpt]
provider = "qcode-responses"
model = "gpt-6.2-sol"
max_context_size = 128000
Check against the screenshot: ① is default_model, which decides which alias is used when -m is omitted; ② ③ ④ are the base_url values of the three providers — Claude uses https://api.qcode.cc/api (②), OpenAI-compatible models use https://api.qcode.cc/openai/v1 (③), and Responses uses the same /openai/v1 (④). The file holds no key, only api_key_env = "QCODE_API_KEY", which the CLI reads on every request.

Done right you will see: default_model, three [providers.*] sections, and three [models.*] sections; one base_url ends with /api and the other with /openai/v1, with no trailing slashes.
Stuck? The file was saved as config.toml.txt
Notepad saves as .txt by default. Open the file in Notepad, click 文件 → 另存为 (File → Save As), change 保存类型 (Save as type) to 所有文件 (All Files), type config.toml as the file name, and save again. You can also enter %USERPROFILE%\.kimi-code in the File Explorer address bar and verify that the 类型 (Type) column shows TOML 文件 (TOML File).
Check the config with kimi doctor¶
Back in PowerShell, run kimi doctor and press Enter, then run kimi doctor config and press Enter. Both print OK config.toml first and end with ① ② All checked config files are valid.. The middle line SKIP tui.toml only means tui.toml does not exist yet so the UI uses built-in defaults, and has nothing to do with the API connection.

Done right you will see: both checks ending with All checked config files are valid., with no INVALID or specific error messages.
Test one prompt with kimi -p before opening the UI¶
At ① type the kimi -p line and press Enter:
kimi -p "Reply with exactly: OK"
kimi -p runs a single prompt non-interactively and exits when done. The CLI prints kimi version 2.7.2 first and then ② • OK. Seeing those two lines means the default model qcode-haiku is reaching QCode's Anthropic endpoint. The last line To resume this session: ... is the command to resume this session; you can ignore it for now.

Done right you will see: kimi version 2.7.2 on one line, followed by • OK — • is the prefix the CLI adds to assistant replies.
Stuck? It says Git Bash was not found on this Windows host
Kimi relies on Git Bash to run commands on Windows. Install Git for Windows first with winget install --id Git.Git -e, clicking 是 (Yes) on the 用户账户控制 (User Account Control) prompt; after installing, close this window, open a fresh Windows PowerShell, set QCODE_API_KEY again, and rerun this command. If Git is installed in a non-default folder, point KIMI_SHELL_PATH at your bash.exe.
Try the third alias with another prompt¶
At ① add -m qcode-gpt to the same command and press Enter:
kimi -p "Reply with exactly: OK" -m qcode-gpt
-m selects a model alias; omitting it uses default_model. ① is -m qcode-gpt on the command line, pointing to the Responses-protocol alias qcode-gpt (model gpt-6.2-sol); the reply is again ② • OK, confirming both the Anthropic and Responses endpoints work.

Done right you will see: -m qcode-gpt in your command, and • OK printed below it.
Enter the TUI and trust the current folder¶
Type kimi and press Enter to open the interactive UI. On your first launch it asks ① Trust this folder?, treating the current directory as the workspace and asking whether you trust it. Use ↑↓ to highlight ② Trust and continue and press Enter.

Done right you will see: this prompt disappears and Kimi's welcome screen opens; running kimi in the same folder later will not ask again.
Stuck? You chose Exit by mistake
Run kimi again, highlight Trust and continue with ↑↓, and press Enter. To work in a different folder, cd to your project directory first and then run kimi; changing folders will ask once for the new directory.
Confirm the model on the welcome screen¶
The welcome screen shows session details: ① is the current directory (Directory), and ② is Model: claude-haiku-5-5, the same model shown in the bottom status bar. It displays the actual model ID rather than the config alias qcode-haiku.

Done right you will see: claude-haiku-5-5 next to Model and in the bottom status bar, and an input box ready for typing.
Inspect the three providers with /provider¶
Type /provider in the input box and press Enter. In the list, ① qcode-anthropic, ② qcode-openai, and ③ qcode-responses are the three providers you wrote into config.toml, each with its base_url underneath. The active one carries ← current; press Esc when finished to close the list.

Done right you will see: three names starting with qcode-, followed underneath by https://api.qcode.cc/api and two lines of https://api.qcode.cc/openai/v1.
View available models with /model¶
Type /model and press Enter. ① is the top row of provider tabs (All, qcode-anthropic, qcode-openai, qcode-responses); ② is the three model rows: claude-haiku-5-5 (qcode-anthropic), deepseek-v4-flash (qcode-openai), and gpt-6.2-sol (qcode-responses). The menu displays the model ID plus provider name rather than the alias from [models.*].

Done right you will see: three model rows, each with its provider name in parentheses, plus a Thinking (←→ to switch) line at the bottom.
Switch to gpt-6.2-sol and send "你好" (Hello)¶
In the /model menu, press ↓ twice to highlight gpt-6.2-sol and press Enter; the interface prints ① Switched to gpt-6.2-sol with thinking off.. Next, type ② 你好 (Hello) in the input box and press Enter; the model replies ③ 你好!有什么我可以帮你的吗? ("Hello! How can I help you?"), and the bottom status bar updates to gpt-6.2-sol.

Done right you will see: the notice Switched to gpt-6.2-sol with thinking off. first, followed by a complete reply from the model.
Stuck? No reply arrives, or an error appears
Press Esc to return to the input box and check base_url in config.toml: Claude must be https://api.qcode.cc/api, while GPT and Chinese models must be https://api.qcode.cc/openai/v1 — do not append /v1/messages, /chat/completions, or a trailing slash. Also verify that the window where you set QCODE_API_KEY is still open — closing it clears the variable. After editing the file, restart kimi or run /reload inside the session.
Check this request on probe.qcode.cc¶
Open a new browser tab, go to probe.qcode.cc, paste the same API key, and click 查询 (Query). The page lists requests from the last 7 days with columns 时间 (Time), 状态 (Status), 连接 (Connect), 首字 (TTFB), 总耗时 (Total time), 响应大小 (Response size), and 输出速率 (Output speed). ① boxes the top two rows: the row with status 200 and a response size of about 180 KB corresponds to the 你好 (Hello) message you just sent in the TUI, matching the timestamp of the reply. This page logs network metrics only, with no model name or token count columns.

Done right you will see: a status 200 request at the top of the table whose timestamp matches when you sent 你好 (Hello) and whose response size is around 180 KB.
Verify it works¶
When all three of these match, the setup is complete:
- Both
kimi doctorandkimi doctor configend withAll checked config files are valid.; kimi -p "Reply with exactly: OK"outputs• OK, and the same command with-m qcode-gptalso outputs• OK;/providerinside the TUI shows all threeqcode-*providers, and sending a prompt receives a normal reply.
All done¶
This Windows PC now has Kimi Code CLI installed and connected to QCode: from now on, open Windows PowerShell, set QCODE_API_KEY, and type kimi to start using it. From here you can:
- Endpoints & API Paths
- Tool Compatibility
- Chinese Models
- OpenCode Setup
- Next: compare the plans on the pricing page and pick the one that fits long-term use
- Go back to your Dashboard to check usage and balance
Common errors¶
| Error message | Why | What to do |
|---|---|---|
error: failed to run prompt: Git Bash was not found on this Windows host. Install Git for Windows from https://gitforwindows.org/ or set KIMI_SHELL_PATH to a bash.exe. |
Git for Windows is not installed on Windows, so Kimi cannot find Git Bash to run commands | Install Git with winget install --id Git.Git -e, close and reopen the terminal, set QCODE_API_KEY again, and rerun kimi -p; if Git is in a non-default directory, point KIMI_SHELL_PATH to bash.exe |
SKIP tui.toml |
No tui.toml file exists yet, so UI settings use built-in defaults — unrelated to the API connection |
No action needed; create %USERPROFILE%\.kimi-code\tui.toml only if you want to customize the UI |
Trust this folder? |
Running kimi in a folder for the first time asks whether to trust it; without other output on screen it is easy to think it hung and close the window |
Run kimi again, highlight Trust and continue with ↑↓, and press Enter; to use a different folder, cd there first and then launch kimi |
FAQ¶
Where is the config file actually stored?¶
On Windows it is %USERPROFILE%\.kimi-code\config.toml, i.e. C:\Users\<username>\.kimi-code\config.toml; on macOS / Linux it is ~/.kimi-code/config.toml. Note the folder name is .kimi-code — the earlier Python-based kimi-cli used ~/.kimi, and the two formats are incompatible. To move from the old version, run kimi migrate.
How do I make the API key persist across sessions?¶
$env:QCODE_API_KEY = "cr_xxxxxxxx" from step 3 applies only to the current window. To have it available in every new window, set a user-level environment variable:
[System.Environment]::SetEnvironmentVariable("QCODE_API_KEY", "cr_xxxxxxxx", [System.EnvironmentVariableTarget]::User)
Close and reopen the terminal after running it. You can also replace api_key_env = "QCODE_API_KEY" in config.toml with api_key = "cr_xxxxxxxx" — only one of the two may be set, and api_key writes the key in plain text into the file.
Startup immediately reports a provider is missing credentials?¶
The CLI looks only at api_key or api_key_env (mutually exclusive — set only one), and then at keys under the [providers.<name>.env] subtable; if all are missing, startup fails. The most reliable approach is api_key_env = "QCODE_API_KEY" as shown on this page, with the variable set before launch. Note that export QCODE_API_KEY=... is bash syntax — in PowerShell use $env:QCODE_API_KEY = "...".
Does picking a model in /model change the default model?¶
Yes. Pressing Enter in the /model menu writes your choice back to default_model in config.toml and appends [thinking] enabled = false. To switch models for the current session only without editing the file, press Alt+S in the menu.
Why is the model name shown in the TUI different from the alias?¶
That is expected. The TUI displays the underlying model ID, such as claude-haiku-5-5, while qcode-haiku is just the alias you chose in config.toml. Use the alias for default_model and -m; the UI shows the real model ID.
What happens when my key expires?¶
Two cases:
- A personal plan key cannot be renewed when it expires — reopen a plan and switch to a new key;
- For a pay-as-you-go pack, buying another pack after the key expires restores the same key automatically.
After switching keys, update QCODE_API_KEY (or api_key in config.toml) and restart kimi.
Connection overview¶
| Item | Details |
|---|---|
| Models you can use | Claude ✅ (type = "anthropic") · GPT ✅ (type = "openai" or type = "openai_responses") · Chinese models ✅ (type = "openai") · Gemini ❌ (QCode does not currently offer the Gemini family — please use Claude, GPT, or Chinese models) |
| Protocol & Base URL | Anthropic Messages: https://api.qcode.cc/api · OpenAI Chat Completions: https://api.qcode.cc/openai/v1 · OpenAI Responses: https://api.qcode.cc/openai/v1 |
| Config location | %USERPROFILE%\.kimi-code\config.toml (~/.kimi-code/config.toml on macOS / Linux) — one [providers.<name>] table per protocol, one [models.<alias>] entry per model |
| Kimi account login | Not needed: only the config file is written; never run kimi login |
| Windows prerequisite | Git for Windows (with Git Bash); if Git is installed elsewhere, point KIMI_SHELL_PATH to bash.exe |
| Official docs | Providers and models · Environment variables · Config overrides · GitHub |
The official docs divide model sources into three categories: one-click login to the Kimi Code managed service, connecting Claude with an Anthropic API key, and connecting third-party inference services via the OpenAI-compatible protocol. The last two match QCode's two endpoints, so one QCode key covers Claude, GPT, and Chinese models in the same tool. This page covers the CLI; Kimi Code Desktop shares some local configuration with it — see Desktop and the CLI below.
Which protocol¶
The type field in [providers.<name>] chooses the protocol implementation. The official reference lists six values — kimi, anthropic, openai, openai_responses, google-genai, vertexai — and QCode's three protocols map directly to three of them:
| Models you want | type |
base_url |
|---|---|---|
claude-opus-5-5, claude-haiku-5-5 |
anthropic |
https://api.qcode.cc/api |
gpt-6.2-sol, gpt-6.2-astra, and Chinese families |
openai |
https://api.qcode.cc/openai/v1 |
gpt-6.2-sol via the Responses protocol |
openai_responses |
https://api.qcode.cc/openai/v1 |
🔴 Do not point Claude models at the OpenAI-compatible endpoint. QCode serves the Claude family only on the Anthropic Messages endpoint; sending claude-* to https://api.qcode.cc/openai/v1 will be rejected. The two endpoints are not interchangeable — see Endpoints & API Paths.
Write the Base URL exactly as shown above: stop at /api or /openai/v1, do not append /v1/messages or /chat/completions, and do not leave a trailing slash.
Two other ingress points:
asia.qcode.ccandus.qcode.ccare the same service asapi.qcode.ccand use the same key, just in different regions. To use one, replace only the hostname inbase_urland keep the path unchanged — for examplehttps://asia.qcode.cc/apiorhttps://us.qcode.cc/apifor Claude, andhttps://asia.qcode.cc/openai/v1for OpenAI-compatible models.
Other install methods (macOS / Linux and npm)¶
On Windows, follow the 14 steps above. macOS / Linux use a separate official script, and all three routes verify with kimi --version:
# macOS / Linux
curl -fsSL https://code.kimi.com/kimi-code/install.sh | bash
# Windows (PowerShell)
irm https://code.kimi.com/kimi-code/install.ps1 | iex
# npm — check your runtime first with node --version
npm install -g @moonshot-ai/kimi-code
The npm route requires Node.js 22.19.0 or later, and permissions for a global install depend on where Node.js is installed. The script automatically downloads the latest release, verifies the checksum, and places the kimi executable on your PATH. Once installed, enter your project directory and start it:
kimi --version
cd your-project
kimi
The config format on macOS / Linux is identical to Windows, except the file path is ~/.kimi-code/config.toml and the key is exported with export QCODE_API_KEY=cr_xxxxxxxx.
Minimal config.toml¶
The file below is the exact one used in step 5: one provider per protocol, each with one model alias. api_key_env tells the CLI to read the key from QCODE_API_KEY on every request so no key is stored in the file; you may pick any variable name.
# ~/.kimi-code/config.toml
default_model = "qcode-haiku"
[providers.qcode-anthropic]
type = "anthropic"
base_url = "https://api.qcode.cc/api"
api_key_env = "QCODE_API_KEY"
[providers.qcode-openai]
type = "openai"
base_url = "https://api.qcode.cc/openai/v1"
api_key_env = "QCODE_API_KEY"
[providers.qcode-responses]
type = "openai_responses"
base_url = "https://api.qcode.cc/openai/v1"
api_key_env = "QCODE_API_KEY"
[models.qcode-haiku]
provider = "qcode-anthropic"
model = "claude-haiku-5-5"
max_context_size = 200000
[models.qcode-dsflash]
provider = "qcode-openai"
model = "deepseek-v4-flash"
max_context_size = 128000
[models.qcode-gpt]
provider = "qcode-responses"
model = "gpt-6.2-sol"
max_context_size = 128000
max_context_size is required (at least 1 token). The numbers above are placeholders — fill in the context length documented for each model; it does not affect whether requests succeed, only the CLI's local context estimate.
After setting the key, send one prompt per alias without opening the TUI:
export QCODE_API_KEY=cr_xxxxxxxx # On Windows PowerShell use $env:QCODE_API_KEY = "cr_xxxxxxxx"
kimi -p "Reply with exactly: OK"
kimi -p "Reply with exactly: OK" -m qcode-dsflash
kimi -p "Reply with exactly: OK" -m qcode-gpt
kimi -p runs a single prompt non-interactively and prints the answer; -m selects a model alias, and omitting it uses default_model. All three lines print • OK (the CLI prefixes assistant replies with •). The sections below explain each field and how to add models; their snippets reuse the three provider names qcode-anthropic, qcode-openai, and qcode-responses, extending this file rather than replacing it.
Configure Claude (type = "anthropic")¶
Credentials are read only from the config file and never fall back to shell environment variables automatically: running export KIMI_API_KEY in the terminal does not give any provider a key. Either put the key in the file, or use api_key_env to name a variable that the CLI reads on every request.
In the minimal file, the Claude section is [providers.qcode-anthropic] plus the qcode-haiku alias. To add another Claude model, add another alias pointing to the same provider; to make it the default, point default_model at it:
[models."claude-opus-5-5"]
provider = "qcode-anthropic"
model = "claude-opus-5-5"
max_context_size = 262144
To test a model temporarily without editing the config file, use the KIMI_MODEL_* variables: when KIMI_MODEL_NAME is set, the CLI synthesizes a temporary provider in memory and writes nothing back to config.toml. KIMI_MODEL_NAME and KIMI_MODEL_API_KEY are required; KIMI_MODEL_PROVIDER_TYPE (kimi, anthropic, openai, or openai_responses, default kimi), KIMI_MODEL_BASE_URL, and KIMI_MODEL_MAX_CONTEXT_SIZE are optional. Passing -m <alias> at startup still has the highest priority.
export KIMI_MODEL_NAME=claude-opus-5-5
export KIMI_MODEL_API_KEY=cr_xxxxxxxx
export KIMI_MODEL_PROVIDER_TYPE=anthropic
export KIMI_MODEL_BASE_URL=https://api.qcode.cc/api
export KIMI_MODEL_MAX_CONTEXT_SIZE=262144
kimi
qcode-anthropic is just the provider name you pick; every [models.<alias>] points back to it through the required provider field. If you prefer not to use an environment variable, replace api_key_env with api_key = "cr_xxxxxxxx"; the official docs note this stores the key as plain text in the config file, and api_key and api_key_env are mutually exclusive — set only one.
| Field | Table | What goes in it |
|---|---|---|
type |
providers | anthropic, documented as "For connecting to the Claude API" |
base_url |
providers | https://api.qcode.cc/api; if omitted, falls back to the Anthropic SDK default |
api_key / api_key_env |
providers | The key itself, or the name of the environment variable holding it (set only one) |
custom_headers |
providers | Optional extra HTTP headers attached to each request |
provider |
models | Required — the provider name defined above |
model |
models | Required — the model ID sent to the server, e.g. claude-opus-5-5 |
max_context_size |
models | Required, at least 1 token — the numbers in the examples are placeholders; use the context length documented for that model |
max_output_size |
models | Optional, maps to max_tokens; currently read only by the anthropic provider |
Capabilities: Standard Claude model names automatically enable vision, tool use, and Thinking; model names not built into the CLI need
capabilitiesdeclared explicitly on[models.<alias>](thinking,image_in,tool_use, etc.), and those tags are additive only.
Configure GPT and Chinese models (type = "openai")¶
Same file, the other endpoint. The openai type is documented as "For connecting to the OpenAI Chat Completions protocol, as well as any third-party service compatible with that protocol" — its built-in default is https://api.openai.com/v1, so you must override base_url to point it at QCode.
The minimal file already defines [providers.qcode-openai] and the qcode-dsflash alias. To add more GPT or Chinese models, attach more aliases to that provider:
[models."gpt-6.2-sol"]
provider = "qcode-openai"
model = "gpt-6.2-sol"
max_context_size = 262144
[models."deepseek-v4-flash"]
provider = "qcode-openai"
model = "deepseek-v4-flash"
max_context_size = 262144
[models."qwen3.8-max"]
provider = "qcode-openai"
model = "qwen3.8-max"
max_context_size = 262144
- Quote aliases containing a dot.
gpt-6.2-solandqwen3.8-maxmust be written[models."qwen3.8-max"]; without quotes, TOML treats the dot as a nested table separator. Field names themselves are always snake_case (default_model,max_context_size). - The
max_context_sizevalues above are placeholders for a required field — use each model's own documented context length. Billing is per token; see qcode.cc/en/models for per-model pricing. - All three providers can coexist in one config file. Select a model for a single session with
-m <alias>(applies to that launch only), or switch inside the TUI with/model.default_modelmust be an alias defined undermodels. - Reasoning output: the CLI handles the
reasoning_contentfield andreasoning_effortinjection automatically for third-party reasoning models; if your gateway uses a non-standard field name, override it withreasoning_keyon the model alias. - Responses protocol. The official docs describe
openai_responsesas OpenAI's newer Responses interface, always streaming, with "Configuration is the same asopenai". Thus[providers.qcode-responses]uses the samebase_url = "https://api.qcode.cc/openai/v1", andgpt-6.2-solresponds normally on this endpoint. Add more GPT models as additional aliases on this provider. Chinese model families are not served on Responses, so keep them onqcode-openai. - For more available IDs on this endpoint, see Chinese Models.
claude-*models are not available here.
Command-line verification¶
Validate the config files before starting the TUI:
kimi doctor
kimi doctor config
kimi doctor checks config.toml and tui.toml without launching the TUI or modifying files; it exits 0 when all checked files are valid or skipped, and 1 if any file is missing or invalid. kimi doctor config checks config.toml only. Neither command probes whether endpoints respond.
Next, inspect what the CLI actually registered:
kimi provider list
Then open the TUI and type /provider for the interactive provider manager: ↑↓ moves the cursor, D deletes the current provider (with a [y/N] prompt), and pressing Enter on [ Add New Platform ] adds a new one. Managed accounts signed in via /login do not appear here. kimi provider is the non-interactive equivalent for scripts and CI.
Finally, test the endpoint directly (substitute your own key):
KEY="cr_xxxxxxxx"
curl -X POST https://api.qcode.cc/api/v1/messages \
-H "x-api-key: $KEY" \
-H "anthropic-version: 2023-06-01" \
-H "content-type: application/json" \
-d '{"model":"claude-opus-5-5","max_tokens":32,
"messages":[{"role":"user","content":"ping"}]}'
This curl command verifies the key and Anthropic endpoint outside the tool: returning JSON with content confirms both work; if it errors, read the JSON error body — a wrong path, an invalid key, and a model not offered on this endpoint produce distinct error messages.
Known limitations and troubleshooting¶
| Symptom | What the official docs say | What to do |
|---|---|---|
| Startup fails saying a provider lacks credentials | Priority is api_key or api_key_env (set only one), then keys in the [providers.<name>.env] subtable; if all are missing, startup fails with an error |
Conventional keys for anthropic are ANTHROPIC_API_KEY and ANTHROPIC_BASE_URL inside [providers.qcode-anthropic.env] — these are config-file keys, not shell lookups. During a /models refresh, any provider whose variable is unset or empty reports its own error without affecting other providers |
export ANTHROPIC_API_KEY=… seems to have no effect |
Shell variables are not a general fallback; the only two explicit channels that read from the shell are a provider's api_key_env and KIMI_MODEL_* |
Use api_key_env. Setting KIMI_MODEL_NAME creates a temporary provider in memory that vanishes on restart |
| Editing the file has no effect | Startup options override the config file for that session only, and the file is read at startup | Restart kimi, or run /reload inside the session to apply the latest config.toml |
| Config error or model not found when a dotted alias is unquoted | default_model must be an alias defined in models; an unquoted dotted alias is parsed as a nested table |
Quote the alias: [models."qwen3.8-max"] |
| 404 or path error | The official docs do not specify path-joining behavior for third-party gateways | Stop base_url at /api (Claude) or /openai/v1 (GPT, Chinese models), with no trailing slash and no manual API path |
Claude rejected on the openai provider |
— | QCode does not offer the Claude family on that endpoint; switch back to type = "anthropic" |
| Different projects need different endpoints | Currently there is only a single user-level config file and no project-level config mechanism; the file is always named config.toml |
Point KIMI_CODE_HOME to a per-project data directory before launching |
kimi doctor warns Unknown top-level key ignored by the v2 engine: auto_session_title. |
The config-files page lists auto_session_title as a top-level field |
Just a warning: the current version ignores this key and still treats the config as valid; delete that line |
Outside the tool itself, keep in mind:
- Login:
kimi loginand/loginare for signing in to the Kimi Code managed service; neither is needed for the QCode setup on this page. - Gemini: Kimi Code includes a
google-genaitype for connecting directly to the Google Gemini API, but QCode does not currently offer the Gemini family — please use Claude, GPT, or Chinese models. - luna models: QCode does not currently offer
gpt-6-lunaorgpt-5.6-luna; use another GPT model such asgpt-6.2-sol,gpt-6.2-astra, orgpt-6.2-sol. max_output_sizeis read only by theanthropicprovider, so setting an output cap on anopenaialias has no effect.- For choosing models by task, see Model Selection; if an error falls outside this tool, follow Troubleshooting.
Desktop and the CLI¶
Kimi Code Desktop and the CLI share local configuration. The desktop docs state that both can be installed on the same machine and share part of their local configuration — such as account, model, provider, and plugin settings — and list ~/.kimi-code/ as the location for "Configuration, account credentials, sessions, and logs (shared with the CLI)"; the exact shared scope follows each product's settings and config files. This page covers the config.toml route only and omits desktop UI setup steps because the official pages do not document field-level desktop configuration.
Older kimi-cli¶
The earlier Python-based kimi-cli used ~/.kimi/config.toml. The official "What's new" page notes that Kimi Code CLI switched to ~/.kimi-code/config.toml with an incompatible format; kimi migrate migrates existing kimi-cli configs, sessions, and MCP declarations in one step. Guides written for the old format do not apply to the tables above.
Related¶
- Endpoints & API Paths — protocol-to-model-family mapping
- Tool Compatibility — which tools use which endpoints
- Chinese Models — IDs and paths for the OpenAI endpoint
- Model Selection — picking the right model for the task
- OpenCode Setup — another terminal agent on the same two endpoints
- MiniMax Code Setup — desktop app and
mcodeCLI
Get started with QCode
One API key for Claude Code, Codex and more — billed per token, per-model prices on qcode.cc/models