Skip to content

Using Kimi in OpenCode ​

OpenCode is a terminal-based coding agent. This guide shows how to forward OpenCode model requests to Kimi For Coding via built-in authentication, with K3.1 Pro models, K3, or K2.8 Preview providing the model inference.

Install OpenCode ​

The easiest way to install OpenCode is through the installation script:

bash
curl -fsSL https://opencode.ai/install | bash

Or install via npm:

bash
npm install -g opencode-ai

Configure API key ​

Run opencode auth login and select Kimi For Coding from the provider list:

bash
$ opencode auth login
┌  Add credentials
│
◆  Select provider
│  ● Kimi For Coding
│  ...
└

Enter your Kimi For Coding API Key:

bash
$ opencode auth login
┌  Add credentials
│
◇  Select provider
│  Kimi For Coding
│
◇  Enter your API key
│  _
└

API Keys can be created and managed in the Kimi Code Console (up to 5 keys; each key is shown only once at creation).

Launch and use ​

After configuring, start OpenCode:

bash
$ opencode

Type /models in a session:

bash
/models

Pick a model under the Kimi For Coding list.

Introducing the K3.1 Pro series

K3.1 Pro is now fully rolled out in Kimi Code. It is our most capable 3T-class model to date, with a 1-million-token context window and substantial improvements in coding, 3D creation, financial research, and other long-horizon agent capabilities.

We also launched K3.1 Pro Highspeed. With the same model quality, it delivers approximately 2–3× the speed of K3.1 Pro for more responsive interactions.

Note: K3.1 Pro models only support thinking mode, and requests with thinking disabled are rejected. Start a new session and use the Kimi Coding Plan's native API protocols for the most stable results; protocol conversion through proxy tools may cause behavior to vary.

Before you start, check your membership tier and what it entitles you to (see Membership Benefits for a comparison of the legacy and new plans) — calling models or context windows beyond your plan will fail with an error:

TierAvailable modelsContext window
Go (new plans)No coding quota—
Andante (legacy plans)K2.8 Preview1048576
Plus / ModeratoK3.1 Pro
K3
K3-256K
K2.8 Preview
K3.1 Pro: 262144
K3: 262144
K3-256K: 262144
K2.8 Preview: 1048576
Pro and above / Allegretto and aboveK3.1 Pro
K3.1 Pro Highspeed
K3
K3-256K
K2.8 Preview
K2.7 Code HighSpeed
K3.1 Pro: 1048576
K3.1 Pro Highspeed: 1048576
K3: 1048576
K3-256K: 262144
K2.8 Preview: 1048576
K2.7 Code HighSpeed: 262144

With K3.1 Pro, the K3 series, or K2.8 Preview selected, type /variants to switch the thinking effort:

bash
/variants

Thinking effort mapping

OpenCode offers the variants Default / low / high / max, mapped to the K3 series' actual effort levels as follows (full mapping table in Model configuration):

OpenCode variantK3 series actual effort
Defaulthigh (K3.1 Pro default) / high (K3 series default) / max (K2.8 Preview default)
lowlow
highhigh (recommended)
maxmax

K3.1 Pro models, the K3 series, and K2.8 Preview support low / high / max. Disabling thinking for K3.1 Pro returns 400; with thinking disabled, requests to the K3 series, K2.8 Preview, and K2.7 Code HighSpeed are served by K2.8 Preview without thinking. K2.7 Code HighSpeed does not require this setting.

See Model configuration for model capabilities and setup details.

Next steps ​