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 or K2.8 Preview providing the model inference.
Install OpenCode
The easiest way to install OpenCode is through the installation script:
curl -fsSL https://opencode.ai/install | bashOr install via npm:
npm install -g opencode-aiConfigure API key
Run opencode auth login and select Kimi For Coding from the provider list:
$ opencode auth login
┌ Add credentials
│
◆ Select provider
│ ● Kimi For Coding
│ ...
└Enter your Kimi For Coding API Key:
$ 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:
$ opencodeType /models in a session:
/modelsPick a model under the Kimi For Coding list.
Recommended model launch
K2.8 Preview is now fully rolled out in Kimi Code — kimi-for-coding is upgraded in place with no configuration changes: performance close to K3, with low / high / max thinking effort levels and up to 1M context. See What's New.
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:
| Tier | Available models | Context window |
|---|---|---|
| Andante | K2.8 Preview | Up to 1M |
| Moderato | K3 K3-256K K2.8 Preview | K3: 256K K3-256K: 256K K2.8 Preview: up to 1M |
| Allegretto and above | K3 K3-256K K2.8 Preview K2.7 Code HighSpeed | K3: up to 1M K3-256K: 256K K2.8 Preview: up to 1M K2.7 Code HighSpeed: 256K |
With K3 or K2.8 Preview selected, type /variants to switch the thinking effort:
/variantsThinking 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 variant | K3 actual effort |
|---|---|
Default | high (K3) / max (K2.8 Preview) |
low | low |
high | high (recommended) |
max | max |
Both K3 and K2.8 Preview support low / high / max; K2.7 Code HighSpeed does not require this setting.
See Model configuration for model capabilities and setup details.
Next steps
- Model configuration — Compare the models and see the full effort mapping table
- Membership Benefits — Confirm which models are available for your plan