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

# 在 OpenCode 中使用 LithosAI

> 通过 OpenAI Chat Completions API，将 OpenCode 直接接入 LithosAI。

## 开始之前

安装 OpenCode CLI，在 [API Key](https://console.lithosai.cloud/keys?lang=zh) 页面创建 key，并在 [模型](https://console.lithosai.cloud/models?lang=zh) 页面选好模型。

<Steps>
  <Step title="设置 API key">
    把 key 设为环境变量：

    ```bash theme={null}
    export LITHOSAI_API_KEY="your-key"
    ```
  </Step>

  <Step title="配置 LithosAI">
    把以下配置合并到 `~/.config/opencode/opencode.json`，保留已有的 provider。示例包含 Kimi K3 fast、Kimi K3 ultra 和 DeepSeek V4.1 Flash fast。按所用模型设置 token 上限。

    <Accordion title="OpenCode 配置">
      ```json ~/.config/opencode/opencode.json theme={null}
      {
        "$schema": "https://opencode.ai/config.json",
        "model": "lithosai/moonshotai/Kimi-K3-fast",
        "provider": {
          "lithosai": {
            "npm": "@ai-sdk/openai-compatible",
            "name": "LithosAI",
            "options": {
              "baseURL": "https://api.lithosai.cloud/v1",
              "apiKey": "{env:LITHOSAI_API_KEY}"
            },
            "models": {
              "moonshotai/Kimi-K3-fast": {
                "name": "moonshotai/Kimi-K3-fast",
                "reasoning": true,
                "limit": {
                  "context": 32768,
                  "output": 4096
                },
                "options": { "reasoningEffort": "high" },
                "variants": {
                  "low": { "reasoningEffort": "low" },
                  "high": { "reasoningEffort": "high" },
                  "max": { "reasoningEffort": "max" },
                  "minimal": { "disabled": true },
                  "medium": { "disabled": true },
                  "xhigh": { "disabled": true }
                }
              },
              "moonshotai/Kimi-K3-ultra": {
                "name": "moonshotai/Kimi-K3-ultra",
                "reasoning": true,
                "limit": {
                  "context": 32768,
                  "output": 4096
                },
                "options": { "reasoningEffort": "high" },
                "variants": {
                  "low": { "reasoningEffort": "low" },
                  "high": { "reasoningEffort": "high" },
                  "max": { "reasoningEffort": "max" },
                  "minimal": { "disabled": true },
                  "medium": { "disabled": true },
                  "xhigh": { "disabled": true }
                }
              },
              "deepseek-ai/DeepSeek-V4.1-Flash-fast": {
                "name": "deepseek-ai/DeepSeek-V4.1-Flash-fast",
                "reasoning": true,
                "limit": {
                  "context": 32768,
                  "output": 4096
                },
                "options": { "reasoningEffort": "high" },
                "variants": {
                  "low": { "reasoningEffort": "low" },
                  "high": { "reasoningEffort": "high" },
                  "max": { "reasoningEffort": "max" },
                  "minimal": { "disabled": true },
                  "medium": { "disabled": true },
                  "xhigh": { "disabled": true }
                }
              }
            }
          }
        }
      }
      ```
    </Accordion>

    要使用其他模型或速度档位，复制 `provider.lithosai.models` 下的一个条目，按照[模型目录](https://console.lithosai.cloud/models?lang=zh)修改它的键名和 `name`。再按该模型调整 token 上限和支持的推理强度，然后重新打开 OpenCode。
  </Step>

  <Step title="开始对话">
    运行 `opencode` 开始对话。
  </Step>
</Steps>

## 模型与推理强度

* **模型与速度档位**：在当前对话中用 `/models` 切换。
* **推理强度**：用 `/variants` 选择 **low**、**high** 或 **max**，默认为 **high**。

所有 Agent 通用的问题见[常见问题](/zh/agent-integrations#常见问题)。

## 参考资料

* [OpenCode 文档](https://opencode.ai/docs/)
* [LithosAI 模型](https://console.lithosai.cloud/models?lang=zh)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.