> ## Documentation Index
> Fetch the complete documentation index at: https://platform.kimi.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 OpenCode 中使用 Kimi 模型

> [OpenCode](https://opencode.ai/) 是一款编程 Agent 产品，界面、配置项和支持能力可能随 OpenCode 版本变化。本文以 Kimi API 的官方调用方式为基础，展示如何通过通过内置认证将 OpenCode 的模型请求转发到 Kimi API。

## 安装 OpenCode

通过安装脚本是最简单的安装 OpenCode 的方式。

```bash theme={null}
curl -fsSL https://opencode.ai/install | bash
```

您也可以通过 npm 安装：

```bash theme={null}
npm install -g opencode-ai
```

## 配置 API 密钥

运行 `opencode auth login` 并选择 **Moonshot AI**。

```bash theme={null}
$ opencode auth login
┌  添加凭证
│
◆  选择提供商
│  ● Moonshot AI
│  ...
└
```

输入您的 Moonshot AI API 密钥。

```bash theme={null}
$ opencode auth login
┌  添加凭证
│
◇  选择提供商
│  Moonshot AI
│
◇  输入您的 API 密钥
│  _
└
```

运行 `opencode` 启动 OpenCode。

```bash theme={null}
$ opencode
```

使用 `/models` 命令选择 Kimi K2.7 Code 模型。

```bash theme={null}
/models
```

如需更多信息，请访问 [opencode.ai/docs](https://opencode.ai/docs)
