> ## 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.

# 在 VS Code 中使用 LithosAI

> 通过 Custom Endpoint 模型，把 VS Code 内置的 Chat 接入 LithosAI。

<Note>
  本指南配置的是 VS Code 内置的 Chat。Agent 扩展有各自的 provider 设置：如果你在 VS Code 里用的是 Kilo Code，请看 [Kilo Code 指南](/zh/agent-integrations/kilo-code)。
</Note>

## 开始之前

安装 VS Code 1.122 或更高版本，在 [API Key](https://console.lithosai.cloud/keys?lang=zh) 页面创建 key，并在 [模型](https://console.lithosai.cloud/models?lang=zh) 页面选择模型。

<Steps>
  <Step title="添加 Custom Endpoint">
    在 Chat 视图中打开模型选择器（**Models**），点击 **+**；也可以在命令面板中运行 **Chat: Manage Language Models**。随后会打开 **Language Models** 编辑器。

    选择 **Add Models → Custom Endpoint**。VS Code 会依次让你填写：

    | 提示 | 值 |
    | - | - |
    | Group Name | `LithosAI` |
    | API Key | 你的 LithosAI API key |
    | API Type | **Chat Completions** |
  </Step>

  <Step title="配置模型">
    VS Code 会打开 `chatLanguageModels.json`，里面已经有一个 `LithosAI` 条目和一个空模型。`name`、`vendor`、`apiKey` 和 `apiType` 保持 VS Code 写入的值：`apiKey` 指向你刚才填写的 key，key 本身保存在 VS Code 的密钥存储中。把 `models` 下的空模型替换成下面的条目，然后保存。

    下面的条目以 `moonshotai/Kimi-K3-fast` 为例。

    <Accordion title="VS Code 模型条目">
      ```json theme={null}
      {
        "id": "moonshotai/Kimi-K3-fast",
        "name": "moonshotai/Kimi-K3-fast",
        "url": "https://api.lithosai.cloud/v1/chat/completions",
        "toolCalling": true,
        "vision": false,
        "maxInputTokens": 1015808,
        "maxOutputTokens": 32768,
        "thinking": true,
        "supportsReasoningEffort": ["low", "high", "max"],
        "reasoningEffortFormat": "chat-completions"
      }
      ```
    </Accordion>

    `url` 要填完整的 Chat Completions 接口地址，不是 base URL。VS Code 把 `maxInputTokens` 与 `maxOutputTokens` 之和当作上下文窗口，所以 `maxInputTokens` 应设为模型的上下文窗口减去 `maxOutputTokens`。

    要添加其他模型或速度档位，复制 `models` 下的条目，再按 [模型列表](https://console.lithosai.cloud/models?lang=zh) 修改 `id`、`name` 和 token 上限。
  </Step>

  <Step title="开始对话">
    在 Chat 视图中选择 **New Chat**（`+`），把 **Session Target** 设为 **Local**，然后在模型选择器中选择你的 LithosAI 模型。在 Agent 选择器中选择 **Agent**，模型就可以编辑文件和调用工具。
  </Step>
</Steps>

## 模型与推理强度

* **模型和速度档位：** 使用 Chat 视图中的模型选择器。
* **推理强度：** 在模型选择器中点击 LithosAI 模型旁边的 **>**，打开 **Thinking Effort**，然后选择 **low**、**high** 或 **max**。VS Code 会按会话记住所选的强度。

## 不登录 GitHub 使用 VS Code

用 LithosAI 模型进行 Chat 和 Agent 会话，不需要登录 GitHub，也不需要 Copilot 订阅。不登录 GitHub 时，VS Code 没有可用于后台任务（例如生成对话标题和 commit message）的模型，会在 Chat 视图中弹出 **Set BYOK utility models** 提示。设置 utility model 是可选的。如需启用这些任务，打开设置，在 `chat.utilityModel` 和 `chat.utilitySmallModel` 中选择你的 LithosAI 模型。VS Code 建议 `chat.utilitySmallModel` 用快速、便宜的模型。每个后台任务都是一次单独的 LithosAI 请求。

行内建议（代码补全）和语义搜索仍然需要 GitHub 账号。

## 限制

* **Copilot** 会话目标和 **Agents** 窗口默认不显示 LithosAI 模型。要在这两处使用，需开启 `chat.agentHost.byokModels.enabled`，VS Code 把它标为实验功能。
* 使用 Copilot Business 或 Enterprise 时，管理员可以关闭 **Bring Your Own Language Model Key in VS Code** 策略，关闭后就无法添加 LithosAI 模型。

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

## 参考资料

* [VS Code 语言模型文档](https://code.visualstudio.com/docs/agent-customization/language-models)
* [VS Code Agent harness（Agent 运行框架）文档](https://code.visualstudio.com/docs/agents/run/agent-harnesses)
* [LithosAI 模型](https://console.lithosai.cloud/models?lang=zh)


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