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 Kimi K3 or Kimi K2.7 Code 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:

  • Kimi K3 (k3): The most capable flagship model
  • Kimi K3-256K (k3-256k): k3-256k is now available. Within 256k context, it delivers the same results. k3 (1M) consumes about twice as much quota as k3-256k. Ideal for everyday Q&A, code completion, routine feature development, and single-file or small-file edits — video input is not supported.
  • Kimi K2.7 Code (kimi-for-coding): A mature, stable coding model
  • Kimi For Coding HighSpeed (kimi-for-coding-highspeed): The high-speed version of K2.7 Code

Recommended model launch

k3-256k is now available. Within 256k context, it delivers the same results. k3 (1M) consumes about twice as much quota as k3-256k. Ideal for everyday Q&A, code completion, routine feature development, and single-file or small-file edits — video input is not supported. If switching from k3 (1M) to k3-256k, compress the context first before switching.

Before you start, check your membership tier and what it entitles you to — calling models or context windows beyond your plan will fail with an error:

TierAvailable modelsContext window
AndanteKimi K2.7 Code256K
ModeratoKimi K3
Kimi K3-256K
Kimi K2.7 Code
256K each
Allegretto and aboveKimi K3
Kimi K3-256K
Kimi K2.7 Code
Kimi For Coding HighSpeed
Kimi K3: up to 1M
Kimi K3-256K: 256K
Kimi K2.7 Code: 256K
Kimi For Coding HighSpeed: 256K

With K3 selected, type /variants to switch the thinking effort:

bash
/variants

Thinking effort mapping

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

OpenCode variantK3 actual effort
Defaulthigh (K3 default)
lowlow
highhigh (recommended)
maxmax

Kimi K3 supports low / high / max; Kimi K2.7 Code series does not require this setting.

See Model configuration for model capabilities and setup details.

Next steps