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

# Continue CLI 安装、API Key、Base URL 与自定义模型配置

> 安装 Continue CLI，配置 BetterToken Base URL 和 API Key，选择兼容的提供商模型并排查常见错误。

要在 Continue CLI 中使用 BetterToken，请准备 API Key，填写下表中的 Base URL，并从模型广场选择当前可用的 Model ID。

## 重点信息

| 字段       | 填写内容                                                               |
| -------- | ------------------------------------------------------------------ |
| API Key  | BetterToken API Key                                                |
| Base URL | `https://www.bettertoken.ai/v1`                                    |
| Model    | 从<a href={"https://bettertoken.ai/pricing"}>模型广场</a>复制的当前 Model ID |

## 准备工作

* 已安装该工具的当前版本
* BetterToken API Key：<a href={"https://bettertoken.ai/register"}>注册并获取</a>
* 从<a href={"https://bettertoken.ai/pricing"}>模型广场</a>复制的 Model ID

### 工具特定要求

* 已安装 Node.js 20 或更高版本（仅使用 npm 安装时需要）

## 安装

### 安装 Continue CLI

<Tabs>
  <Tab title="macOS / Linux">
    ```bash theme={null}
    curl -fsSL https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.sh | bash
    ```
  </Tab>

  <Tab title="Windows PowerShell">
    ```powershell theme={null}
    irm https://raw.githubusercontent.com/continuedev/continue/main/extensions/cli/scripts/install.ps1 | iex
    ```
  </Tab>

  <Tab title="npm（跨平台）">
    ```bash theme={null}
    npm install -g @continuedev/cli
    ```
  </Tab>
</Tabs>

安装完成后，运行以下命令确认 `cn` 可用：

```bash theme={null}
cn --version
```

## 手动配置

| 字段       | 填写内容                                                               |
| -------- | ------------------------------------------------------------------ |
| API Key  | BetterToken API Key                                                |
| Base URL | `https://www.bettertoken.ai/v1`                                    |
| Model    | 从<a href={"https://bettertoken.ai/pricing"}>模型广场</a>复制的当前 Model ID |

### 配置 API Key 和 Base URL

<Steps>
  <Step title="设置 API Key 环境变量">
    <Tabs>
      <Tab title="macOS / Linux">
        在启动 Continue CLI 的同一个终端中运行：

        ```bash theme={null}
        export BETTERTOKEN_API_KEY="YOUR_API_KEY"
        ```
      </Tab>

      <Tab title="Windows PowerShell">
        在启动 Continue CLI 的同一个 PowerShell 窗口中运行：

        ```powershell theme={null}
        $env:BETTERTOKEN_API_KEY = "YOUR_API_KEY"
        ```
      </Tab>
    </Tabs>

    将 `YOUR_API_KEY` 替换为你的 BetterToken API Key。不要把 API Key 提交到 Git 仓库或写入共享配置文件。
  </Step>

  <Step title="创建 config.yaml">
    在用户目录创建或编辑以下文件：

    * macOS / Linux：`~/.continue/config.yaml`
    * Windows：`%USERPROFILE%\.continue\config.yaml`

    写入以下配置：

    ```yaml theme={null}
    name: BetterToken
    version: 0.0.1
    schema: v1

    models:
      - name: BetterToken GPT
        provider: openai
        model: YOUR_MODEL_ID
        apiBase: "https://www.bettertoken.ai/v1"
        apiKey: ${{ secrets.BETTERTOKEN_API_KEY }}
        useResponsesApi: false
    ```

    `YOUR_MODEL_ID` 只是示例。请改为模型广场中当前可用的 **受支持提供商的模型 ID**。
  </Step>

  <Step title="启动 Continue CLI">
    <Tabs>
      <Tab title="macOS / Linux">
        ```bash theme={null}
        cn --config ~/.continue/config.yaml
        ```
      </Tab>

      <Tab title="Windows PowerShell">
        ```powershell theme={null}
        cn --config "$env:USERPROFILE\.continue\config.yaml"
        ```
      </Tab>
    </Tabs>

    也可以先进入你的项目目录，再运行上面的命令。配置加载后，直接在 Continue CLI 中输入任务即可。
  </Step>
</Steps>

## 验证连接

发送一条简短测试消息。工具正常返回内容，并且没有认证或 Model ID 错误，就说明连接成功。修改配置后请完全退出并重新启动工具。

## 切换模型

打开模型选择器，或修改配置中的 `Model` 字段。请填写<a href={"https://bettertoken.ai/pricing"}>模型广场</a>中的完整 Model ID，然后重新启动当前会话。

修改 `config.yaml` 中的 `model` 后，结束当前 `cn` 会话并重新运行启动命令。模型 ID 必须来自当前配置使用的接口。

如果你想仅为一个项目使用单独配置，可以在项目目录保存配置文件，并显式指定路径：

```bash theme={null}
cn --config ./continue-bettertoken.yaml
```

## 常见错误

| 现象                                | 处理方式                                                                           |
| --------------------------------- | ------------------------------------------------------------------------------ |
| `401`、`Unauthorized` 或 API Key 错误 | 确认 `BETTERTOKEN_API_KEY` 已在当前终端设置，并且使用的是 BetterToken API Key。                  |
| `model not found` 或模型不可用          | 从模型广场重新复制当前可用的 **受支持提供商的模型 ID**，不要填写 Claude 提供商模型。                             |
| 仍使用旧配置                            | 使用 `cn --config` 明确指定文件路径；检查文件名为 `config.yaml`。                                |
| 请求地址错误或 `404`                     | 确认 `apiBase` 是 `https://www.bettertoken.ai/v1`，不要填入 `/chat/completions` 或模型名称。 |
| 配置中的密钥变量未解析                       | 在启动 `cn` 的同一个终端中设置 `BETTERTOKEN_API_KEY`，然后重新运行启动命令。                           |

### 配置 FAQ

**Continue CLI 应该使用哪个 Base URL？**

填写 `https://www.bettertoken.ai/v1`。这是 BetterToken 的 OpenAI-compatible Base URL。

**可以使用 BetterToken API Key 吗？**

可以。`provider: openai` 配合 `useResponsesApi: false` 会使用 OpenAI-compatible Chat Completions。API Key 与 Model ID 都从 BetterToken 获取。

**如何查看或切换已保存的配置？**

在 Continue CLI 会话中输入 `/config`，即可查看并选择本地配置。

## 进阶配置

### 支持的提供商

| 提供商    | 状态   |
| ------ | ---- |
| Claude | 暂不支持 |
| GPT    | 手动配置 |
| Kimi   | 手动配置 |
| GLM    | 手动配置 |

<Note>状态仅针对本页介绍的 BetterToken 接入方式。</Note>

<Accordion title="配置方式说明">
  * **手动配置**：填写 API Key、Base URL 和 Model。
  * **不支持**：当前没有经过验证的直接配置方式。
</Accordion>

### 相关指南

* [Aider 自定义模型配置](/zh/ai-tools/aider)
* [Codex CLI 自定义 provider 配置](/zh/ai-tools/codex)
* [Cursor 自定义 API、Base URL 和 API Key 配置](/zh/ai-tools/cursor)
* [Cline 配置 OpenAI-compatible API](/zh/ai-tools/cline)

## 技术说明

<Accordion title="协议、endpoint 与 provider 内部字段">
  本页使用 `provider: openai`、`apiBase: "https://www.bettertoken.ai/v1"` 和 `useResponsesApi: false`。Continue 会自行请求 Chat Completions，因此不要在 `apiBase` 后附加 `/chat/completions`。
</Accordion>
