Kimi Code
Use any APIKO chat model in Kimi Code
Overview
Kimi Code is Moonshot AI's coding agent for the terminal. It speaks the OpenAI Chat Completions API, so it can use every APIKO chat model: Claude, GPT, Gemini, DeepSeek, GLM, Kimi and Grok. On 2026-10-02 we ran Kimi Code 2.1.1 with the configuration on this page against 13 models from these families; each finished a task that used a shell command.
Set base_url to https://api.apiko.app/v1 and use the key in APIKO_API_KEY. The current Kimi chat models on APIKO are kimi-k3 and kimi-k3.1-pro, replacing the earlier Kimi K2 releases. On APIKO, Claude Code uses /v1/messages and only supports Claude models (see the Claude Code guide); use an OpenAI-compatible agent like Kimi Code to run Kimi models.
Step 1: Install Kimi Code
Skip this if typing kimi in a terminal already starts Kimi Code. Otherwise run the command for your system; it takes about a minute.
curl -fsSL https://code.kimi.com/kimi-code/install.sh | bashCheck it with kimi --version in a new terminal.
Step 2: Create an API key
An API key works like a password: it lets your tools use your APIKO balance. Open Dashboard → API Keys, click Create Key and copy the key (it starts with sk-). The full key is shown only once, so keep it somewhere safe.
Step 3: Save the key on your computer
Kimi Code reads the key from the APIKO_API_KEY environment variable, so the key never goes into its config file.
Open Terminal (press ⌘ + Space, type Terminal, press Enter), paste this line, replace paste-your-key-here with your key and press Enter:
echo 'export APIKO_API_KEY="paste-your-key-here"' >> ~/.zshrc && source ~/.zshrcTo check, open a new terminal and run:
[ -n "$APIKO_API_KEY" ] && echo "key is set"Step 4: Add APIKO to Kimi Code
Kimi Code keeps its settings in ~/.kimi-code/config.toml. This command opens the file and creates it if it doesn't exist:
mkdir -p ~/.kimi-code && touch ~/.kimi-code/config.toml && open -e ~/.kimi-code/config.tomlPaste these lines at the end of the file, then save and close it. If the file already has a line starting with default_model, delete that old line.
default_model = "apiko/deepseek-v4-pro"
[providers.apiko]
type = "openai"
base_url = "https://api.apiko.app/v1"
api_key_env = "APIKO_API_KEY"
[models."apiko/deepseek-v4-pro"]
provider = "apiko"
model = "deepseek-v4-pro"
max_context_size = 1000000- To use another model, replace
deepseek-v4-proin all three places with an id from the model list. max_context_sizeis the model's context window, shown on its model page.131072works if you are unsure.- To add more models, add another
[models."apiko/…"]block and switch withkimi -m apiko/<model>(replace<model>with the model id).
Step 5: Check the connection
Open a new terminal and run:
kimi provider listThe list should include apiko type=openai. Then run kimi and send a short message such as "hi". A reply means Kimi Code is using APIKO.
Web search with Kimi models
APIKO's /v1/chat/completions route does not run Moonshot's built-in server-side $web_search tool. To give Kimi Code or API calls to kimi-k3 and kimi-k3.1-pro access to web search, use one of these methods.
- Connect an
MCPserver that provides web search to your coding agent. - In your API client, define a search function in the standard OpenAI
toolsfield. Run the search when the model requests it, then send the results back in atoolmessage with the matchingtool_call_id.
Common errors
| Symptom | Cause and fix |
|---|---|
401 | APIKO_API_KEY isn't set in this terminal. Open a new terminal after Step 3, or check the key in API Keys. |
403 insufficient_user_quota | The balance is used up. Top up in Billing. |
404 model_not_found | The model id is wrong or the model was retired. Copy the id from the model list. |
kimi provider list doesn't show apiko | The lines weren't saved, or there are two default_model lines. Open the file again and check. |