APIKO
Option 2 · Manual setup

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.

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

Check 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:

bash
echo 'export APIKO_API_KEY="paste-your-key-here"' >> ~/.zshrc && source ~/.zshrc

To check, open a new terminal and run:

bash
[ -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:

bash
mkdir -p ~/.kimi-code && touch ~/.kimi-code/config.toml && open -e ~/.kimi-code/config.toml

Paste 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.

toml
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-pro in all three places with an id from the model list.
  • max_context_size is the model's context window, shown on its model page. 131072 works if you are unsure.
  • To add more models, add another [models."apiko/…"] block and switch with kimi -m apiko/<model> (replace <model> with the model id).

Step 5: Check the connection

Open a new terminal and run:

bash
kimi provider list

The 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.

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 MCP server that provides web search to your coding agent.
  • In your API client, define a search function in the standard OpenAI tools field. Run the search when the model requests it, then send the results back in a tool message with the matching tool_call_id.

Common errors

SymptomCause and fix
401APIKO_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_quotaThe balance is used up. Top up in Billing.
404 model_not_foundThe model id is wrong or the model was retired. Copy the id from the model list.
kimi provider list doesn't show apikoThe lines weren't saved, or there are two default_model lines. Open the file again and check.