Kimi+ 会员限时特惠
Kimi K3 · 15 天免费体验
2.8T 前沿模型 · 100 万 token 上下文 · 深度研究
免费 ¥199 / 15 天
  • Kimi K3 无限畅聊:2.8T 参数前沿模型
  • 100 万 token 上下文,超长文档轻松解析
  • Deep Research 深度研究,多格式专业报告
  • Agent Swarm 智能体集群,并行处理任务
  • AI Slides · Sheets · Docs 咨询级办公产出
立即开启 15 天免费体验
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 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.

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 (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
K3-256K
K2.8 Preview
K3: 262144
K3-256K: 262144
K2.8 Preview: 1048576
Pro and above / Allegretto and aboveK3
K3-256K
K2.8 Preview
K2.7 Code HighSpeed
K3: 1048576
K3-256K: 262144
K2.8 Preview: 1048576
K2.7 Code HighSpeed: 262144

With K3 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 K3's actual effort levels as follows (full mapping table in Model configuration):

OpenCode variantK3 actual effort
Defaulthigh (K3) / max (K2.8 Preview)
lowlow
highhigh (recommended)
maxmax

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