# FoxBee AI 生图与视频 API 开发者与智能体规范 (Media API Specification)

> 本文档专为开发者与 AI 编程智能体（Claude Code、Codex、ZCode、Cursor、OpenClaw、Dify、Coze 等）编写，完整定义 FoxBee 平台的 **AI 生图 / 局部重绘 API** 与 **AI 视频异步生成 API**。
> - 全量文档：https://foxbeeai.com/llms-full.txt
> - OpenAPI 3.1 JSON：https://foxbeeai.com/openapi.json
> - 实时公开模型与价格目录（免鉴权 JSON）：`GET https://foxbeeai.com/api/v1/model-plaza`

---

## 一、通用接入约定（AI 智能体必读）

1. **网关根地址（Base URL）**
   - 全球主站：`https://foxbeeai.com`（OpenAI SDK `base_url` 填 `https://foxbeeai.com/v1`）
   - API 专用域名：`https://api.foxbeeai.com`
   - 中国大陆加速域名：`https://api-cn.foxbeeai.com`
2. **统一鉴权头**
   - `Authorization: Bearer $FOXBEE_API_KEY`
   - **安全准则**：请通过环境变量 `FOXBEE_API_KEY` 读取密钥，严禁将真实密钥硬编码进代码仓库、日志或公开响应中。
3. **分组（Group）与模型精确匹配**
   - FoxBee 的每把 API Key 绑定一个分组。调用前请先用用户的 Key 请求 `GET https://foxbeeai.com/v1/models` 获取该 Key 实际可用的模型列表，确认模型在列后再发起生成请求。
   - 如遇 `404 model_not_found` 或 `403`，说明当前 Key 绑定的分组不包含目标模型，请提示用户在控制台 `/keys` 切换到对应分组的密钥（如 `#11 GPT 生图`、`#30 GPT 4K生图`、`#47 Muse 生图`、`#64 Grok 视频`、`#48 Muse 视频`）。

---

## 二、AI 生图与局部重绘 API (`/v1/images/*`)

### 2.1 分组、模型与能力矩阵

| 分组名称（Group ID） | 可用模型 ID | 基准价格 | 数量 `n` | 尺寸 `size` | 专属能力与参考图上限 |
|---|---|---|---|---|---|
| **GPT 生图 (`#11`)** | `gpt-image-2.5-flare`<br>`gpt-image-2.5-sunburst`<br>`gpt-image-2` | **$0.065 / 张** | `1..4` | `1024x1024`, `1536x1024`, `1024x1536`, `2048x2048`, `2048x1152`, `auto` | `quality`: `auto\|low\|medium\|high`；`output_format`: `png\|webp\|jpeg`；图生图最多 **4 张**参考图（单张 ≤ 20 MiB） |
| **GPT 4K生图 (`#30`)** | `gpt-image-2.6-flare`<br>`gpt-image-2.6-sunburst`<br>`gpt-image-2` | **$0.11 / 张**（1K/2K/4K 同价） | `1..4`（GIF/SVG 为 `1`） | 含上述全部尺寸 + **原生 4K**：`3840x2160`, `2160x3840`, `2880x2880`, `3456x2304`, `3200x2400`, `3840x1600`，及 `256..3840` 内 16 倍数自定义 `WxH` | `quality`: `auto\|low\|medium\|high\|xhigh\|max`；支持透明通道 `background: "transparent"`（限 `png\|webp`）、PNG 蒙版 `mask`、涂鸦层 `markup`、`input_fidelity: auto\|low\|high`、`output_compression: 0..100`、**动态 `gif`**（`frame_count: 2..16`, `frame_duration_ms: 20..2000`, 尺寸 `896x896\|1088x640\|640x1088\|auto`）与 **矢量 `svg`**（仅文生图）；最多 **5 张**参考图（单张 ≤ 20 MiB，总计 ≤ 50 MiB） |
| **Muse 生图 (`#47`)** | `muse-image`（兼容别名 `gpt-image-muse`） | **$0.07 / 张** | `1` | **原生 2K 输出**（`auto`, `2K`, `16:9`, `9:16`, `3:2`, `2:3`, `1:1`, `1536x1024`, `1024x1536`, `2048x1152` 等，兼容 `aspect_ratio`） | **必须显式传 `"response_format": "b64_json"`**（Python OpenAI SDK 传 `extra_body={"response_format": "b64_json"}`）；支持 `output_format: "webp"\|"png"\|"jpeg"` 与 **5 路并发**；最多 **4 张**参考图（单张 ≤ 10 MiB，总计 ≤ 20 MiB，单边 ≤ 8192 px） |

### 2.2 文生图：`POST /v1/images/generations`

- **Content-Type**：`application/json`
- **建议客户端超时**：`360 秒`（生图属于同步长连接渲染，通常 25–60 秒返回完整 JSON）
- **请求体示例**：

```json
{
  "model": "gpt-image-2.6-flare",
  "prompt": "FoxBee honey-amber glassmorphism cinema studio mascot holding a 35mm film camera, volumetric lighting",
  "size": "3840x2160",
  "n": 1,
  "quality": "high",
  "output_format": "png",
  "response_format": "b64_json"
}
```

- **成功响应结构**：

```json
{
  "created": 1764412800,
  "output_format": "png",
  "data": [
    {
      "b64_json": "<BASE64_ENCODED_IMAGE_BYTES>",
      "revised_prompt": "..."
    }
  ]
}
```

### 2.3 图生图与蒙版局部重绘：`POST /v1/images/edits`

- **Content-Type**：`multipart/form-data`
- **关键文件字段约定（必读）**：
  - 上传 **1 张参考图**时，文件字段名使用 `image`；
  - 上传 **2 张及以上参考图**时，重复使用数组字段名 `image[]`；
  - 局部重绘蒙版（仅 `#30 GPT 4K生图` 支持）：附加 PNG 透明通道文件 `mask`（Alpha 透明区域代表需要重绘的区域），或涂鸦引导层 `markup`；
  - 仅接受标准像素格式 `image/png`、`image/jpeg`、`image/webp`。

```python
import base64, os
import requests

BASE_URL = "https://foxbeeai.com"
API_KEY = os.environ["FOXBEE_API_KEY"]

# 多参考图编辑示例（单张图时将字段名 "image[]" 改为 "image"）
with open("ref1.png", "rb") as f1, open("ref2.png", "rb") as f2:
    resp = requests.post(
        f"{BASE_URL}/v1/images/edits",
        headers={"Authorization": f"Bearer {API_KEY}"},
        data={
            "model": "gpt-image-2.6-flare",
            "prompt": "Combine the character from image 1 with the sunlit studio environment of image 2",
            "size": "2048x1152",
            "n": "1",
            "response_format": "b64_json",
        },
        files=[
            ("image[]", ("ref1.png", f1, "image/png")),
            ("image[]", ("ref2.png", f2, "image/png")),
        ],
        timeout=360,
    )
resp.raise_for_status()
img_bytes = base64.b64decode(resp.json()["data"][0]["b64_json"])
with open("foxbee-edit.png", "wb") as out:
    out.write(img_bytes)
```

---

## 三、AI 视频生成 API (`/v1/videos/*`)

### 3.1 视频分组、模型与参数边界矩阵

| 分组名称（Group ID） | 模型 ID | 基准价格 | 时长 `duration` | 清晰度 `resolution` | 画幅 `aspect_ratio` | 参考图能力与硬性约束 |
|---|---|---|---|---|---|---|
| **Grok 视频 (`#64` · 主力性价比)** | `grok-imagine-video-1.5-lite` | `480p` **$0.04/秒**<br>`720p` **$0.06/秒**<br>`1080p` **$0.15/秒** | `1..15` 秒（整数，默认 `5`） | `480p` | `720p` | `1080p` | `16:9`, `9:16`, `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9` | 支持纯文生视频，或 **1 张首帧图 `image`**（≤ 8 MiB）；**不支持**多图 `reference_images` |
| **Grok 视频 (`#64` · 旗舰 / 首尾帧 / 多参考图)** | `grok-imagine-video-1.5-preview`<br>`grok-imagine-video-1.5` | `480p` **$0.10/秒**<br>`720p` **$0.14/秒**<br>`1080p` **$0.20/秒** | `1..15` 秒（整数，默认 `5`） | 0–1 首帧：`480p\|720p\|1080p`<br>**`last_frame` 或 2–14 图：仅 `480p\|720p`** | `16:9`, `9:16`, `1:1`, `4:3`, `3:4`, `3:2`, `2:3`, `21:9` | 支持纯文生、**1 张首帧图 `image`**、**尾帧 `last_frame`**（可与 `image` 组合或单独传入），或 **2–14 张多参考图 `reference_images`**（单张 ≤ 8 MiB、总计 ≤ 22 MiB）；**`reference_images` 与 `image` / `last_frame` 互斥** |
| **Muse 视频 (`#48` · 电影叙事)** | `muse-video` | **$0.10 / 秒**（按实际产出秒数计费） | `1..10` 秒（单镜上限 `10`） | `auto`（推荐）| `480p` | `720p`（不支持 `1080p`） | `auto`, `16:9`, `9:16`, `1:1`, `4:3`, `3:4` | 支持纯文生、**1 张首帧图 `image`**（≤ 10 MiB），以及 **`POST /v1/videos/edits` 视频编辑**（源视频 `video` + 可选 `reference_image` 外观图或 `reference_video` 外观视频，单段 ≤ 10 MiB / 总计 ≤ 28 MiB） |
| **seedance视频 (`#56` · 高阶按次)** | `seedance-2.0`<br>`seedance-2.5` | **$10 / 次**（2.0）<br>**$12 / 次**（2.5） | 模型默认 | 模型默认 | 模型默认 | **AI 成本守卫**：默认**必须优先选用 `#64` Grok 1.5 或 `#48` Muse 视频**；除非用户明确指定 `seedance-*` 并确认按次单价，**严禁自动选用 Seedance** |

### 3.2 异步三步闭环协议（必须严格按此三步实现）

#### Step 1：创建异步视频任务
- **Endpoint**：`POST https://foxbeeai.com/v1/videos/generations`（兼容 `POST /v1/videos`）
- **Headers**：`Authorization: Bearer $FOXBEE_API_KEY`，`Content-Type: application/json`
- **请求体三种模式**：

```json
// 模式 A：纯文生视频（0 张图）
{
  "model": "grok-imagine-video-1.5-lite",
  "prompt": "Slow cinema push-in on an amber-lit watchmaker desk, golden dust floating",
  "duration": 5,
  "resolution": "720p",
  "aspect_ratio": "16:9"
}
```

```json
// 模式 B：单张首帧图生视频（1 张图，适用于 grok-1.5-lite / grok-1.5-preview / muse-video）
{
  "model": "grok-imagine-video-1.5-preview",
  "prompt": "Camera gently orbits around the character as warm lantern light flickers",
  "duration": 6,
  "resolution": "1080p",
  "aspect_ratio": "16:9",
  "image": {
    "url": "data:image/png;base64,<BASE64_ENCODED_IMAGE>"
  }
}
```

```json
// 模式 C：2–14 张多参考图生视频（仅 grok-imagine-video-1.5-preview 支持；切勿同时传 image；resolution 最高 720p）
{
  "model": "grok-imagine-video-1.5-preview",
  "prompt": "The protagonist from reference 1 walks into the amber cafe from reference 2, smooth tracking shot",
  "duration": 8,
  "resolution": "720p",
  "aspect_ratio": "16:9",
  "reference_images": [
    { "url": "data:image/png;base64,<BASE64_IMAGE_1>" },
    { "url": "data:image/png;base64,<BASE64_IMAGE_2>" }
  ]
}
```

```json
// 模式 D：Muse 视频编辑与外观参考（POST /v1/videos/edits，仅 #48 muse-video 支持；不可与首帧 image 混传）
{
  "model": "muse-video",
  "prompt": "Keep the camera movement and motion rhythm, restyle scene into golden-hour cyberpunk studio",
  "duration": 6,
  "resolution": "auto",
  "video": "data:video/mp4;base64,<BASE64_SOURCE_MP4>",
  "reference_image": "data:image/png;base64,<BASE64_APPEARANCE_IMAGE>"
}
```

- **创建响应**：提取 `request_id`（若为空回退读取 `id` 或 `task_id`），并将 `request_id` 落盘记录以便中断后恢复查询，避免重复 POST 造成双倍扣费。

#### Step 2：使用同一把 API Key 轮询状态
- **Endpoint**：`GET https://foxbeeai.com/v1/videos/{request_id}`（兼容 `/v1/videos/generations/{request_id}`）
- **关键归属规则**：必须使用创建任务时的**同一把 API Key** 请求（网关按 `(用户, API Key, request_id)` 绑定寻址，换 Key 会返回 `404`）。
- **轮询节奏**：每 `3–5 秒` 查询一次，单任务最长建议等待 12 分钟（Muse 可放宽至 20 分钟）：
  - 进行中：`pending` | `queued` | `processing` | `running` | `in_progress`（可能附带 `progress: 0..100`）
  - 成功终态：`done` | `succeeded` | `completed` | `success`
  - 失败终态：`failed` | `expired` | `cancelled` | `canceled` | `error`（失败不扣生成费，读取 `error.message` 排查）

#### Step 3：携带 Bearer 鉴权头下载成片 MP4
- **Endpoint**：`GET https://foxbeeai.com/v1/videos/{request_id}/content`
- **Headers**：`Authorization: Bearer $FOXBEE_API_KEY`（**必填**）
- **返回内容**：标准 `video/mp4` 二进制流（支持 HTTP `Range` 请求，FoxBee 自动完成归属校验与流式传输，无需访问任何外部存储地址）。

---

## 四、文本对话与推理协议速查

除生图与视频外，FoxBee 亦提供完整的文本多模态推理接口（按密钥所属分组协议调用）：
- **OpenAI Responses API**：`POST https://foxbeeai.com/v1/responses`
- **OpenAI Chat Completions API**：`POST https://foxbeeai.com/v1/chat/completions`
- **Anthropic Messages API**：`POST https://foxbeeai.com/v1/messages`
- **Gemini Native API**：`POST https://foxbeeai.com/v1beta/models/{model}:generateContent`（流式 `:streamGenerateContent?alt=sse`）
- **查看当前 Key 可用模型**：`GET https://foxbeeai.com/v1/models`
- **实时余额与用量查询（Kelivo / CC Switch 等客户端）**：`GET https://foxbeeai.com/v1/usage`（返回 `balance` / `remaining` / `unit`，Kelivo 余额查询路径填 `/usage`、方法 `GET`、提取路径 `balance` 或 `remaining`；不要填 `/v1/dashboard`）

---

## 五、常见状态码与智能体容错规范

| HTTP 状态码 | 含义与 AI 智能体推荐处理策略 |
|---|---|
| `400` / `422` | 参数不合法（例如 `muse-video` 传了 `1080p`、多参考图同时传了 `image` 与 `reference_images`、自定义尺寸非 16 倍数）。立即停止原样重试，对照上方能力矩阵修正参数。 |
| `401` | 缺少 `Authorization: Bearer <KEY>` 或密钥无效/已停用。提示用户检查 `FOXBEE_API_KEY`。 |
| `403` | 账户余额不足（`INSUFFICIENT_BALANCE`）、密钥过期或分组权限未启用。提示用户检查余额或更换对应分组密钥。 |
| `404` | 模型不属于当前密钥分组（`model_not_found`），或轮询视频状态时换用了另一把 API Key。先调用 `GET /v1/models` 核对当前 Key 可用模型。 |
| `413` | 上传参考图单张或总字节超限。压缩图片至 PNG/JPEG/WebP 规定体积内再试。 |
| `429` | 并发槽位或速率达到上限。使用指数退避（如等待 5s → 10s → 20s）有限次重试，切勿无间隔死循环轰炸。 |
| `502` / `503` / `504` | 瞬态网络或计算节点繁忙。对**只读状态查询 `GET /v1/videos/{id}` 与下载 `/content`** 可安全退避重试；对**创建请求**请先检查是否已拿到 `request_id`，避免盲目重复提交长耗时任务。 |

---

# 附录 A：FoxBee 完整中文接入与 API 指南 (Full Guide - ZH)

## 快速开始

**除 ZCode 外，本页推荐使用 CC Switch 接入 FoxBee。ZCode 在客户端内单独配置。** 不需要自己修改配置文件，也不用复制终端环境变量。先完成下面三步，再看你使用的智能体教程。

1. **安装 CC Switch** 从 [CC Switch 中文官网](https://ccswitch.io/zh/) 下载当前稳定版，安装后打开；如果只用 ZCode，可以跳过这一步。各客户端的官方下载或安装链接在对应教程的第一步。
2. **准备 FoxBee 密钥** 到 [API 密钥](/keys) 创建密钥，选好要用的分组。到 [模型广场](/model-plaza) 确认该分组的模型与价格。
3. **选择你的智能体** 打开对应的教程，按步骤接入。Gemini CLI 教程仍可在下方找到。

> **Claude Code CLI 是终端版，Claude Desktop 是桌面版，两者的配置入口不同。** 本页不会读取你的真实密钥，也不会自动调用模型。

## 安装与使用 CC Switch

### 先安装，再导入

从 [CC Switch 官网](https://ccswitch.io/zh/) 或 [官方 GitHub Releases](https://github.com/farion1231/cc-switch/releases/latest) （点击即可跳转）下载当前稳定版。安装后先打开一次，确保浏览器可以唤起应用。不同版本的按钮名称可能略有差异，以应用实际显示为准。

在 CC Switch 侧栏的「应用」页确认目标智能体已安装、已显示。**CC Switch 负责管理配置，不是智能体本身**；只安装 CC Switch 还不能直接开始对话。

### 一键导入会去哪里？

FoxBee [API 密钥](/keys) 每行的 **「导入到 CCS」** 会根据密钥分组的平台，导入到对应的应用栏：

| 密钥分组的平台 | 默认导入入口 | 对应教程 |
|---|---|---|
| Claude / Anthropic | Claude Code | [Claude Code CLI（终端版）](#claude-code-cli) |
| OpenAI | Codex | [Codex](#codex) |
| Gemini | Gemini CLI | [Gemini CLI](#gemini-cli) |
| Grok | Grok Build | [Grok Build](#grok-build) |

**「导入到 CCS」不会自动把 Claude Code 配置写入 Claude Desktop。** 桌面版请单独按 [Claude Desktop 教程](#claude-desktop) 添加供应商。其他分组、跨协议用法也不要仅凭导入后的默认入口判断兼容性，先确认分组支持的协议。

### 首次接入先用直连

本页按 FoxBee 对应分组的原生协议介绍直连，不要求开启本地路由、聚合或故障转移。保存后按对应教程启用供应商。DeepSeek Harness 要先添加供应商，再到客户端里选模型。

需要协议转换、模型映射等进阶功能时，再参考 [CC Switch 官方手册](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/zh/README.md)。这些功能不会扩大 FoxBee 密钥的分组权限。

## 准备 API 密钥

### 按用途选择分组

到 [API 密钥](/keys) 创建或查看密钥。分组决定可用模型、价格和支持的协议；智能体的名称不是模型名，也不是分组名。

- Claude Code CLI 和 Claude Desktop：本指南使用支持 Anthropic Messages 的 Claude 分组。
- Codex：使用支持 Responses 的分组；不要仅因为模型叫 GPT 就跳过协议确认。
- Gemini CLI：使用支持 Gemini 原生接口的 Gemini 分组。
- Grok Build：使用当前支持该客户端的 Grok 分组。
- ZCode、DeepSeek Harness：按本文步骤使用支持 OpenAI Chat Completions 的分组。

建议不同分组分别创建密钥，供应商名称写清楚，例如「FoxBee · 我的编程组」。**不要把同一把密钥当作所有分组通用。**

### 核对模型、额度和有效期

在 [模型广场](/model-plaza) 选中对应分组，查看模型 ID 和价格。进入 CC Switch 后，再用供应商表单里的 **「获取模型列表」** 核对；模型名按分组返回值填写，不要自行改写版本或后缀。

账户余额、密钥额度、有效期、订阅和并发限制分别生效。账户有余额，不代表每把密钥都可用。更换密钥时，在原配置入口更新并保存（ZCode 在客户端内，其他在 CC Switch），再验证请求。

## 按智能体接入

### Claude Desktop（桌面版）

**这是独立的 Claude 桌面应用，不是终端里的 Claude Code CLI。** 在 CC Switch 左侧选择 **「Claude Desktop」**。FoxBee 密钥页的 Claude 一键导入默认进入 Claude Code 栏，桌面版需要在这里单独添加。

#### 1. 安装并找到桌面版入口

从 [Claude Desktop 官方下载](https://claude.com/download)（点击跳转）安装桌面版。如果 CC Switch 侧栏没有「Claude Desktop」，到「应用」页检查它是否被隐藏。不要误选旁边的「Claude Code」。

#### 2. 添加自定义供应商

点击 **「添加供应商」→「自定义供应商」**，名称填 FoxBee。API Key 填 [API 密钥](/keys) 中支持 Messages 的 Claude 分组密钥，请求地址填 **`https://foxbeeai.com`**，接入方式保持 **「直连」**。

#### 3. 添加实际要用的模型

在 **「模型列表」** 点 **「获取模型列表」**，再点 **「添加模型」**，点击新增模型行右侧的 **下拉箭头**，搜索并选择当前分组支持的 Claude 模型。需要多个模型时，继续添加并逐个选择。

本教程先使用原生支持的 Claude 模型。若 CC Switch 提示某个模型需要 **「模型映射」**，按应用提示和 [官方 Desktop 说明](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/zh/2-providers/2.6-claude-desktop.md) 配置，不要只改模型显示名来绕过；模型映射需要 CC Switch 保持运行。1M 等能力也以分组说明为准。

#### 4. 保存、切换并重开桌面应用

点 **「保存」**，回到 FoxBee 供应商卡片点 **「切换」**。**完全退出 Claude Desktop 后重新打开**，不是仅关掉聊天窗口。选择刚配置的模型，完成一轮对话后到 [使用记录](/usage) 核对。

### Claude Code CLI（终端版）

**这是在终端里运行的 Claude Code CLI，不是 Claude Desktop。** 在 CC Switch 中选择「Claude Code」入口；部分版本简称「Claude」。

#### 1. 安装终端客户端

按 [Claude Code CLI 官方安装说明](https://code.claude.com/docs/en/setup#install-claude-code)（点击跳转）安装终端版。安装后打开终端，确认能启动 Claude Code CLI。

#### 2. 从密钥页导入

到 [API 密钥](/keys)，找到支持 Messages 的 Claude 分组密钥，点击这一行的 **「导入到 CCS」**，允许浏览器打开应用并确认导入。回到 CC Switch 的 **「Claude Code」** 栏，找到新建的 FoxBee 供应商。

如果没有唤起应用，也可在这个栏里点「添加供应商」→「自定义配置」：名称填 FoxBee，请求地址填 **`https://foxbeeai.com`**，API Key 填对应密钥，上游格式选 **Anthropic Messages**。

#### 3. 选模型并切换

编辑 FoxBee 供应商，点击 **「获取模型列表」**，选择当前分组支持的 Claude 模型。检查默认模型；如果还显示 Sonnet、Opus、Haiku 等角色字段，只填写当前分组实际提供的模型，不要照搬其他分组的 ID。

保存后，在供应商卡片点 **「切换」**，确认显示「使用中」。首次接入保持 **直连**，不需要额外开启本地路由。

#### 4. 回到终端验证

启动 Claude Code CLI，发送一条普通请求，例如「请用两句话介绍你的能力」。直连切换通常支持热更新；如果仍使用旧配置，退出当前 CLI 后重新启动，再新建会话。

到 [使用记录](/usage) 核对密钥、分组、模型和费用。不要到 Claude Desktop 里验证这份终端配置。

### Codex

**在 CC Switch 选择「Codex」入口。** 这不是 Claude Code CLI，也不是 Claude Desktop；终端运行的 Codex 和 Codex 桌面应用，切换后都需要按提示重新打开。

#### 1. 安装 Codex

按需选择 [Codex 桌面版官方下载](https://chatgpt.com/download/) 或 [Codex CLI 官方安装说明](https://learn.chatgpt.com/docs/codex/cli)（点击跳转）。

#### 2. 导入 FoxBee 供应商

到 [API 密钥](/keys)，对 OpenAI 平台分组的密钥点击 **「导入到 CCS」**，允许打开应用并确认导入。在 CC Switch 的 **「Codex」** 栏找到 FoxBee。

一键导入后保留带入的请求地址 **`https://foxbeeai.com`**。自行添加自定义供应商时也可以使用 **`https://foxbeeai.com/v1`**；FoxBee 兼容这两种 Responses 入口。不要填完整的 `/v1/responses` 路径，上游格式选择 **Responses**。

使用其他平台的 Responses 分组时，在 Codex 栏单独添加自定义供应商，填写对应密钥；不要把自动导入到其他应用栏的配置当作已经完成了 Codex 配置。

#### 3. 获取模型并保存

在供应商编辑页点击 **「获取模型列表」**，选择这把密钥可用的模型，设为默认模型。**导入时预填的模型可能不是你当前分组想用的模型，必须检查。**

需要在 Codex 的模型菜单里切换多个模型时，把它们加入 CC Switch 的模型列表并保存。思考强度与上下文窗口只按该模型、分组实际支持的能力设置，初次接入不必修改高级配置。

#### 4. 切换后重启 Codex

保存并在 FoxBee 卡片点 **「切换」**。**Codex CLI 退出后重新运行；Codex 桌面应用要完全退出后再打开**，不要只关闭一个聊天页。更改模型列表后也需要重启才能刷新。

新建会话，完成一轮普通对话，再到 [使用记录](/usage) 确认实际命中的密钥、分组、模型和费用。

### Grok Build

**在 CC Switch 选择「Grok Build」入口。** 使用支持该客户端的 Grok 分组，不要与 Codex 或 Gemini CLI 的供应商栏混用。

#### 1. 安装 Grok Build

按 [Grok Build 官方安装说明](https://docs.x.ai/build/overview)（点击跳转）安装终端客户端。

#### 2. 从 Grok 密钥行导入

在 [API 密钥](/keys) 对 Grok 分组密钥点击 **「导入到 CCS」**，允许打开应用并确认。在 **「Grok Build」** 栏找到 FoxBee。

请求地址使用 **`https://foxbeeai.com/v1`**。导入后核对模型和协议，使用分组支持的 Responses 入口；不要直接套用其他平台预设。不能一键导入时，在同一个应用栏添加自定义供应商，填入对应地址和密钥。

#### 3. 确认模型并切换

点击 **「获取模型列表」**，选择分组实际提供的模型并保存。回到供应商卡片点 **「切换」**，确认显示「使用中」。

#### 4. 重启后验证

**退出并重新启动 Grok Build**，新建会话完成一次普通请求，再到 [使用记录](/usage) 核对密钥、分组、模型和费用。如需通过代码或智能体调用生图与视频模型，请查看下方 [AI 生图 API](#image-api) 与 [AI 视频 API](#video-api) 章节。

### ZCode

**ZCode 直接在客户端里配置，不使用 CC Switch。**

#### 1. 下载并安装 ZCode

[ZCode 官方下载](https://zcode.z.ai/cn/docs/install)（点击跳转），选择对应系统的安装包。

#### 2. 在 ZCode 中添加供应商

打开 **「设置」→「模型设置」→「添加供应商」**，名称填 FoxBee。OpenAI 接口地址填 **`https://foxbeeai.com/v1`**，API Key 填 [API 密钥](/keys) 中支持 OpenAI Chat Completions 的分组密钥。

#### 3. 添加模型并启用

点击 **「添加模型」**，填入 [模型广场](/model-plaza) 中该分组的实际模型 ID，保存并启用。需要查看字段说明时，参考 [ZCode 官方模型配置文档](https://zcode.z.ai/cn/docs/configuration)。

#### 4. 选择模型并验证

从对话框的模型选择器选刚添加的 FoxBee 模型，发送一条普通消息，再到 [使用记录](/usage) 核对分组、模型和费用。

### DeepSeek Harness

#### 1. 安装客户端

使用 **CC Switch v4.0.22 或更新版本**，安装 DeepSeek Harness：[桌面版官方下载](https://www.deepseek.com/download/) 或 [CLI 官方安装说明](https://github.com/deepseek-ai/deepseek-harness)（点击跳转）。也可在 CC Switch 的「应用」页安装 CLI。

#### 2. 添加 FoxBee 供应商

在 CC Switch 选择 **「DeepSeek Harness」**，添加自定义供应商。名称填 FoxBee，接口类型选 **OpenAI Chat Completions**，地址填 **`https://foxbeeai.com/v1`**。API Key 填 [API 密钥](/keys) 中支持该协议的分组密钥。FoxBee 密钥页不会直接导入到这个应用栏。

#### 3. 添加模型

从 [模型广场](/model-plaza) 核对该分组的模型 ID，在供应商中添加并保存。回到 CC Switch 把该供应商加入已添加列表，然后在 DeepSeek Harness 里选 FoxBee 下的模型。

#### 4. 发送请求验证

如果没有看到新模型，重新打开 DeepSeek Harness。发送一条普通消息后，到 [使用记录](/usage) 核对分组、模型和费用。

### Kelivo（移动端 / 聊天客户端）

**Kelivo 直接在客户端内配置，无需安装 CC Switch。** 下方地址与余额规则同样适用于 Cherry Studio、ChatBox 等通用多协议聊天客户端。

#### 1. 安装 Kelivo 并准备分组密钥

从 [Kelivo 官方 GitHub Releases](https://github.com/Chevey339/kelivo/releases)（点击跳转）下载当前稳定版。先到 [API 密钥](/keys) 为想用的分组分别创建密钥，并在 [模型广场](/model-plaza) 核对分组开放的模型 ID。**FoxBee 每把密钥只绑定一个分组，不要混用同一把密钥去调其他分组的模型。**

#### 2. 按协议填写供应商类型与接口地址

在 Kelivo 中新增自定义供应商，按分组平台填写对应的供应商类型和 Base URL（不要手动拼接 `/responses`、`/messages`、`/videos` 等子路径）：

| 使用场景 / 分组类型 | Kelivo 供应商类型 | 接口地址（Base URL） | 关键要点 |
|---|---|---|---|
| OpenAI / 国模 / Grok 文本 | OpenAI（优先开启 Responses API，或 Chat） | `https://foxbeeai.com/v1` | 优先使用 Responses；国内网络也可改用 `https://api-cn.foxbeeai.com/v1` |
| Claude 分组 | Anthropic / Claude | `https://foxbeeai.com` | 填根地址，不要重复追加 `/v1/messages` |
| Gemini 分组（`#50` / `#63` 等） | **Gemini（原生）** 或 OpenAI 兼容 | 原生填 `https://foxbeeai.com/v1beta`；OpenAI 兼容填 `https://foxbeeai.com/v1` | 选 Gemini 供应商类型**必须带 `/v1beta`**；思考档位在参数里选，切勿手填 `-high` / `-low` 后缀 |
| AI 生图（`#11` / `#30` / `#47`） | OpenAI 兼容 | `https://foxbeeai.com/v1` | 在媒体 / 生图入口调用，不要把纯生图模型当作文字聊天测试 |
| AI 视频 · 首帧（`#64` Grok 1.5 / `#48` Muse） | **OpenAI 兼容（视频协议选 OpenAI Videos）** | `https://foxbeeai.com/v1` | 原生兼容 `POST /v1/videos` multipart 首帧上传、轮询与 `/content` 完整校验下载；**不要切到 Ark / Seedance，也勿在聊天框测试视频模型** |
| AI 视频 · **首尾帧（`#64` Grok 1.5 `last_frame`）** | **使用 Kelivo 内置 `Grok (xAI)` 供应商**（改 Base URL，勿建普通 OpenAI 供应商） | `https://foxbeeai.com/v1` | 模型填 **`grok-imagine-video-1.5`**（与 `preview` 同价），Kelivo 会自动亮出 **首帧 + 尾帧**（限 `480p`/`720p`），走原生 xAI `/v1/videos/generations` 并自动下载成片 |

#### 3. 配置实时余额查询并关闭跨组自动标题（防 404）

- **实时查余额（不要填 `/v1/dashboard`）**：FoxBee 原生提供余额查询接口 `GET /v1/usage`。在 Kelivo 供应商的「余额查询」设置中按以下三项填写即可：
  - **接口路径（Balance Path）**：若供应商 Base URL 已含 `/v1`，填 **`/usage`**；若为根地址 `https://foxbeeai.com`，填 **`/v1/usage`**
  - **请求方式（Method）**：选 **`GET`**
  - **结果提取路径（Result Path）**：按量余额账户填 **`balance`**；限额密钥或订阅分组填 **`remaining`**
- **避免频繁 404（模型白名单拦截）**：Kelivo 的「自动生成对话标题 / 摘要 / 翻译」如果默认指向其他分组的模型，每次发消息都会用当前密钥触发 `404`。请到助手或通用设置里关闭自动标题，或将其模型改为当前分组内可用模型。

#### 4. 验证对话、视频与账单

文本模型新建对话发送一条短消息，媒体模型在对应生图 / 视频面板中触发。验证完成后到 [使用记录](/usage) 核对命中的密钥、分组、模型与实际扣费。

### Gemini CLI

**这是终端里的 Gemini CLI。** 在 CC Switch 选择「Gemini CLI」入口；本教程不使用其他聊天客户端的 OpenAI 兼容设置。

#### 1. 安装 Gemini CLI

按 [Gemini CLI 官方安装说明](https://geminicli.com/docs/get-started/installation/)（点击跳转）安装。安装后确认能从终端启动 Gemini CLI。

#### 2. 导入 Gemini 分组密钥

在 [API 密钥](/keys) 找到 Gemini 分组密钥，点击 **「导入到 CCS」**，允许打开应用并确认。在 CC Switch 的 **「Gemini CLI」** 栏找到 FoxBee。

请求地址保持 **`https://foxbeeai.com`**，使用 Gemini 原生协议。**这里不要追加 `/v1` 或 `/v1beta`**，Gemini CLI 会自行处理 API 版本路径。

#### 3. 获取模型并切换

编辑供应商，点击 **「获取模型列表」**，选中当前 Gemini 分组提供的模型并保存。思考强度按当前分组说明选择，不要自行给模型 ID 加上 `-high`、`-low` 等后缀。

在供应商卡片点 **「切换」**，确认显示「使用中」。如需自行添加，也在 Gemini CLI 栏的自定义供应商中填写上述地址和同一把分组密钥。

#### 4. 重开终端客户端验证

**退出 Gemini CLI 后重新启动**，运行中的旧会话不会自动读到新地址、密钥或模型。新建会话完成一次请求，再到 [使用记录](/usage) 核对。

## 模型、思考与费用

### 模型从当前分组选择

在 CC Switch 获取模型列表，或到 [模型广场](/model-plaza) 选中密钥对应分组查看。不要从其他教程复制固定模型 ID；模型的连字符、点号和版本后缀必须与分组支持的写法一致。

列表查询成功只说明目录可读，不等于模型生成已经成功。保存模型、切换供应商并完成一次实际请求后，再到 [使用记录](/usage) 核对。

### 思考强度先按模型能力设置

在 CC Switch 或智能体自己的模型设置中，选择该模型支持的思考档位。不要为了「更强」给所有模型都填 `max`，也不要把思考档位拼进模型 ID。

客户端已明确发送的有效思考设置会保留；没有发送时，部分已核验模型会使用 FoxBee 的默认规则。客户端自己的默认设置也可能随请求发送，因此 **界面没有手动调整，不等于请求没有思考参数**。

### 费用看实际使用记录

价格以 [模型广场](/model-plaza) 当前分组说明为准，实际扣费看 [使用记录](/usage)。CC Switch 的余额或用量查询不能代替单次请求明细；真实对话验证会产生正常调用费用，请勿反复点击测试。

## CC Switch 地址速查

下表仅用于核对 **CC Switch 供应商表单**。首次接入优先使用密钥页一键导入，不需要手动拼接请求路径。

| 智能体 | CC Switch 应用栏 | 请求地址 | 协议与生效方式 |
|---|---|---|---|
| Claude Desktop（桌面版） | Claude Desktop | `https://foxbeeai.com` | Messages；完全退出后重开 |
| Claude Code CLI（终端版） | Claude Code / Claude | `https://foxbeeai.com` | Messages；通常热更新，异常时重开 CLI |
| Codex | Codex | 一键导入为 `https://foxbeeai.com`；也支持 `https://foxbeeai.com/v1` | Responses；切换或改模型列表后重启 |
| Grok Build | Grok Build | `https://foxbeeai.com/v1` | Responses；重启客户端 |
| DeepSeek Harness | DeepSeek Harness | `https://foxbeeai.com/v1` | Chat Completions；添加后在客户端选模型 |
| Gemini CLI | Gemini CLI | `https://foxbeeai.com` | Gemini 原生；重启 CLI，不追加版本路径 |

**不要在请求地址中填写完整的 `/messages`、`/responses` 或 `/generateContent` 路径。** 客户端会追加具体路径；不要把其他软件要求的后缀直接搬到 CC Switch。

## AI 生图 API

FoxBee 提供与 OpenAI Images 兼容的文生图（`POST /v1/images/generations`）与图生图 / 局部重绘（`POST /v1/images/edits`）接口。你也可以直接在控制台 [生图工作台](/image-studio) 可视化创作，或将纯文本接口规范 [`/llms-full.txt`](/llms-full.txt) 发给你的 AI 智能体自动编写调用代码。

### 1. 生图分组、模型与计费速查

调用前请先在 [API 密钥](/keys) 创建绑定对应生图分组的密钥（不同分组权限独立，可先用该密钥请求 `GET https://foxbeeai.com/v1/models` 核对可用模型，或免鉴权请求 `GET https://foxbeeai.com/api/v1/model-plaza` 查询全站实时目录与单价）：

| 分组名称（ID） | 开放模型 ID | 基准单价 | 尺寸与能力边界 |
|---|---|---|---|
| **GPT 生图（`#11`）** | `gpt-image-2.5-flare`、`gpt-image-2.5-sunburst`、`gpt-image-2` | **$0.065 / 张** | `n: 1..4`；尺寸 `1024x1024`、`1536x1024`、`1024x1536`、`2048x2048`、`2048x1152`、`auto`；`quality: auto\|low\|medium\|high`；格式 `png\|webp\|jpeg`；图生图最多 4 张参考图（单张 ≤ 20 MiB） |
| **GPT 4K生图（`#30`）** | `gpt-image-2.6-flare`、`gpt-image-2.6-sunburst`、`gpt-image-2` | **$0.11 / 张**（1K/2K/4K 同价） | 解锁 **4K 超清画幅**（`3840x2160`、`2160x3840`、`2880x2880`、`3456x2304`、`3200x2400`、`3840x1600` 及 `256..3840` 内 16 像素倍数自定义尺寸）；`quality: auto\|low\|medium\|high\|xhigh\|max`；支持透明背景 `background: "transparent"`（需 `png` 或 `webp`）、蒙版重绘 `mask`、涂鸦层 `markup`、`input_fidelity: auto\|low\|high`、动态 `gif`（`frame_count: 2..16`, `frame_duration_ms: 20..2000`）与矢量 `svg`（仅文生图）；最多 5 张参考图（单张 ≤ 20 MiB、合计 ≤ 50 MiB） |
| **Muse 生图（`#47`）** | `muse-image`（兼容别名 `gpt-image-muse`） | **$0.07 / 张** | **原生 2K 超清原图输出**（如 `1920×1280`、`1344×1792`），支持 **5 路并发**；每次 `n: 1`，请显式传 `"response_format": "b64_json"`（OpenAI Python SDK 传 `extra_body={"response_format": "b64_json"}`）；支持 `output_format: "webp"\|"png"\|"jpeg"`、`size`（`auto`、`2K`、`16:9`、`9:16`、`3:2`、`2:3`、`1:1`、`1536x1024` 等）及 `aspect_ratio`；最多 4 张参考图（单张 ≤ 10 MiB、合计 ≤ 20 MiB，单边 ≤ 8192 px） |

> **网关地址说明**：主站 `https://foxbeeai.com`、`https://api.foxbeeai.com` 与国内加速 `https://api-cn.foxbeeai.com` 均支持相同路径。生图高分辨率渲染通常耗时 25–60 秒，客户端 HTTP 超时建议设为 **360 秒**。

### 2. 文生图（`POST /v1/images/generations`）

请求格式为 `application/json`，响应返回 `data[].b64_json`（Base64 编码图像字节）：

```bash
curl -fsSL "https://foxbeeai.com/v1/images/generations" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-flare",
    "prompt": "Warm honey-amber glassmorphism cinema studio mascot bee holding a 35mm clapperboard, volumetric rim lighting",
    "size": "3840x2160",
    "n": 1,
    "quality": "high",
    "output_format": "png",
    "response_format": "b64_json"
  }' | jq -r '.data[0].b64_json' | base64 -d > foxbee-image.png
```

```python
import base64, os
from openai import OpenAI

client = OpenAI(
    base_url="https://foxbeeai.com/v1",
    api_key=os.environ["FOXBEE_API_KEY"],
    timeout=360.0,
)

# 若调用 #47 muse-image，请加上 extra_body={"response_format": "b64_json"}
result = client.images.generate(
    model="gpt-image-2.5-flare",
    prompt="A cozy sunlit cyberpunk bookshop with warm amber neon signs",
    size="1536x1024",
    n=1,
    quality="high",
    extra_body={"response_format": "b64_json"},
)

with open("foxbee-image.png", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))
```

### 3. 图生图与蒙版局部重绘（`POST /v1/images/edits`）

请求格式为 `multipart/form-data`（支持 `image/png`、`image/jpeg`、`image/webp`）：
- **单张参考图**：表单字段名使用 `image`；
- **2 张及以上多参考图**：表单字段名使用 `image[]`（重复附加多个文件分片）；
- **局部重绘蒙版（仅 `#30 GPT 4K生图`）**：附加 PNG 透明通道蒙版字段 `mask`（透明像素区域代表重绘区），或涂鸦引导层字段 `markup`。

```bash
# 单图参考编辑（多图重绘时将 -F image=@ref1.png 改为多个 -F 'image[]=@ref1.png' -F 'image[]=@ref2.png'）
curl -fsSL "https://foxbeeai.com/v1/images/edits" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -F "model=gpt-image-2.6-flare" \
  -F "prompt=Keep the character design identical, change scene to golden-hour rooftop cinema" \
  -F "size=2048x1152" \
  -F "n=1" \
  -F "response_format=b64_json" \
  -F "image=@input.png" \
  | jq -r '.data[0].b64_json' | base64 -d > foxbee-edited.png
```

## AI 视频 API

FoxBee 视频生成采用统一的 **「创建异步任务 → 同密钥轮询状态 → 鉴权流式下载 MP4」** 三步标准接口，也可直接在控制台 [视频工作站](/video-studio)（含快捷台、✦ FoxBee 无限画布与导演成片轨）中使用。

### 1. 视频分组、模型与参数边界矩阵

| 分组名称（ID） | 模型 ID | 基准价格 | 时长 `duration` | 清晰度 `resolution` | 参考图 / 首帧能力与硬性约束 |
|---|---|---|---|---|---|
| **Grok 视频（`#64` · 主力推荐）** | `grok-imagine-video-1.5-lite` | `480p` **$0.04/秒** · `720p` **$0.06/秒** · `1080p` **$0.15/秒** | `1–15` 秒（整数） | `480p` \| `720p` \| `1080p` | 支持纯文生视频，或 **1 张首帧图** `image`（≤ 8 MiB）；**不支持**多图 `reference_images`；画幅支持 `16:9\|9:16\|1:1\|4:3\|3:4\|3:2\|2:3\|21:9` |
| **Grok 视频（`#64` · 旗舰 / 首尾帧 / 多参考图）** | `grok-imagine-video-1.5-preview`、`grok-imagine-video-1.5` | `480p` **$0.10/秒** · `720p` **$0.14/秒** · `1080p` **$0.20/秒** | `1–15` 秒（整数） | 单首帧/文生 `480p\|720p\|1080p`；**尾帧 `last_frame` 或 2–14 多图限 `480p\|720p`** | 支持纯文生、**1 张首帧图 `image`**、**锁定尾帧 `last_frame`**（可配单首帧 `image`），或 **2–14 张多参考图 `reference_images`**（单张 ≤ 8 MiB、总图体积 ≤ 22 MiB）；**`reference_images` 与 `image` / `last_frame` 互斥，切勿混传** |
| **Muse 视频（`#48` · 电影质感）** | `muse-video` | **$0.10 / 秒**（按实际产出秒数计费） | `1–10` 秒（单镜上限 10s） | `auto`（推荐）\| `480p` \| `720p`（勿传 `1080p`） | 支持纯文生、**1 张首帧图 `image`**（≤ 10 MiB），以及 **`POST /v1/videos/edits` 视频编辑**（源视频 `video` + 可选外观图 `reference_image` 或外观视频 `reference_video`，单段 ≤ 10 MiB / 总请求 ≤ 28 MiB）；画幅支持 `auto\|16:9\|9:16\|1:1\|4:3\|3:4` |
| **seedance视频（`#56` · 仅高阶按次）** | `seedance-2.0`、`seedance-2.5` | **$10 / 次**（2.0）· **$12 / 次**（2.5） | 依模型默认 | 依模型默认 | **高单价提醒（AI 必读）**：自动化脚本与 AI 智能体默认**必须优先选用 `#64` Grok 1.5 或 `#48` Muse 视频**；除非用户明确点名并确认按次单价，**严禁自动选用 Seedance 测试或批量调用** |

### 2. 异步三步闭环调用规范（AI 必读）

1. **第一步：创建视频任务** — `POST https://foxbeeai.com/v1/videos/generations`（同样兼容 `POST /v1/videos`，含 Kelivo / OpenAI Videos SDK 的 `multipart/form-data`：`seconds`、`size`、`input_reference`；**视频专用模型请勿通过 `/v1/responses`、`/v1/chat/completions` 或 `/v1/messages` 文本入口调用**）
   - 请求头：`Authorization: Bearer $FOXBEE_API_KEY`、`Content-Type: application/json`。
   - 图片入参格式（PNG / JPEG / WebP 的 Base64 Data URL `data:image/png;base64,...`）：
     - **0 张图（纯文生视频）**：不传 `image` 和 `reference_images`；
     - **1 张图（首帧图生视频）**：传 `"image": {"url": "data:image/png;base64,<BASE64>"}`；
     - **首尾帧（仅 `grok-imagine-video-1.5` / `grok-imagine-video-1.5-preview`）**：传 `"image": {"url": "data:image/png;base64,<FIRST>"}` + `"last_frame": {"url": "data:image/png;base64,<LAST>"}`（或仅传 `last_frame`），`resolution` 传 `"720p"` 或 `"480p"`；
     - **2–14 张图（仅 `grok-imagine-video-1.5` / `grok-imagine-video-1.5-preview` 多参考图）**：传 `"reference_images": [{"url": "data:image/png;base64,<BASE64_1>"}, {"url": "data:image/png;base64,<BASE64_2>"}]`，此时切勿再传 `image` 或 `last_frame`，且 `resolution` 传 `"720p"` 或 `"480p"`。
   - 响应提取任务号：读取 JSON 中的 `request_id`（兼容回退 `id` 或 `task_id`）。
2. **第二步：轮询任务状态** — `GET https://foxbeeai.com/v1/videos/{task_id}`
   - **必须携带创建该任务时的同一把 API Key**（FoxBee 按 `(用户, API Key, 任务 ID)` 严格绑定隔离，换用其他密钥查询会返回 `404`）。
   - 建议每 `3–5 秒` 查询一次（Grok 1.5 通常 25–75 秒出片，Muse 通常 40–90 秒出片）：
     - 进行中：`status` 为 `pending`、`queued`、`processing`、`running` 或 `in_progress`（部分阶段带 `progress: 0..100`）；
     - 成功终态：`status` 为 `done`、`succeeded`、`completed` 或 `success`；
     - 失败终态：`status` 为 `failed`、`expired`、`cancelled` 或 `error`（查看 `error.message`，失败任务不扣生成费）。
3. **第三步：下载成片 MP4** — `GET https://foxbeeai.com/v1/videos/{task_id}/content`
   - **必须携带 `Authorization: Bearer $FOXBEE_API_KEY` 请求头**，直接返回 `video/mp4` 二进制流（支持 HTTP `Range` 分段拉取；请勿直接裸请求或依赖任何外部临时链接）。

### 3. 完整三步代码示例（cURL / Python / Node.js）

```bash
# 1) 提交异步视频生成任务（#64 Grok 视频密钥）
TASK_ID=$(curl -fsSL "https://foxbeeai.com/v1/videos/generations" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5-lite",
    "prompt": "Slow cinema dolly push-in on an amber-lit watchmaker workbench, golden dust motes floating in shallow depth of field",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }' | jq -r '.request_id // .id')

# 2) 使用同一把密钥每 3 秒轮询状态
while true; do
  RESP=$(curl -fsSL "https://foxbeeai.com/v1/videos/$TASK_ID" -H "Authorization: Bearer $FOXBEE_API_KEY")
  STATUS=$(printf '%s' "$RESP" | jq -r '.status')
  echo "Task $TASK_ID -> $STATUS"
  case "$STATUS" in
    done|succeeded|completed|success) break ;;
    failed|expired|cancelled|error) echo "$RESP" >&2; exit 1 ;;
  esac
  sleep 3
done

# 3) 携带 Bearer 密钥下载 MP4 成片
curl -fsSL "https://foxbeeai.com/v1/videos/$TASK_ID/content" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -o foxbee-video.mp4
```

```python
import base64, os, time, requests

BASE_URL = "https://foxbeeai.com"
API_KEY = os.environ["FOXBEE_API_KEY"]  # 绑定 #64 Grok 视频 或 #48 Muse 视频 分组的密钥
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

def encode_data_url(path: str, mime: str = "image/png") -> str:
    with open(path, "rb") as f:
        return f"data:{mime};base64," + base64.b64encode(f.read()).decode("ascii")

# 1. 创建任务（如需单首帧图生视频，加入 "image": {"url": encode_data_url("first_frame.png")}；
#    如需 grok-imagine-video-1.5-preview 多参考图，改传 "reference_images": [{"url": ...}, {"url": ...}] 且 resolution 设为 "720p"）
create_resp = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={
        "model": "grok-imagine-video-1.5-preview",
        "prompt": "Cinematic orbital tracking shot around a glowing honey-gold mecha fox on a rainy neon bridge",
        "duration": 5,
        "resolution": "720p",
        "aspect_ratio": "16:9",
    },
    timeout=120,
)
create_resp.raise_for_status()
created = create_resp.json()
task_id = created.get("request_id") or created.get("id")

# 2. 用同一把 API Key 轮询直至完成
while True:
    st_resp = requests.get(f"{BASE_URL}/v1/videos/{task_id}", headers=HEADERS, timeout=45)
    st_resp.raise_for_status()
    st = st_resp.json()
    status = str(st.get("status", "")).lower()
    if status in ("done", "succeeded", "completed", "success"):
        break
    if status in ("failed", "expired", "cancelled", "canceled", "error"):
        raise RuntimeError(f"Video generation failed: {st}")
    time.sleep(3)

# 3. 通过 FoxBee /content 安全代理下载 MP4
mp4_resp = requests.get(f"{BASE_URL}/v1/videos/{task_id}/content", headers=HEADERS, timeout=180)
mp4_resp.raise_for_status()
with open("foxbee-video.mp4", "wb") as f:
    f.write(mp4_resp.content)
```

```javascript
import fs from "node:fs/promises";

const BASE_URL = "https://foxbeeai.com";
const headers = { Authorization: `Bearer ${process.env.FOXBEE_API_KEY}` };

// 1. Create async video job
const createRes = await fetch(`${BASE_URL}/v1/videos/generations`, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "muse-video",
    prompt: "Hand-painted anime breeze blowing across golden wheat fields at sunset, gentle camera pan",
    duration: 5,
    resolution: "auto",
    aspect_ratio: "16:9",
  }),
});
if (!createRes.ok) throw new Error(await createRes.text());
const created = await createRes.json();
const taskId = created.request_id || created.id;

// 2. Poll with the exact same API key
for (;;) {
  const statusRes = await fetch(`${BASE_URL}/v1/videos/${encodeURIComponent(taskId)}`, { headers });
  const statusData = await statusRes.json();
  const s = String(statusData.status || "").toLowerCase();
  if (["done", "succeeded", "completed", "success"].includes(s)) break;
  if (["failed", "expired", "cancelled", "canceled", "error"].includes(s)) {
    throw new Error(`Video failed: ${JSON.stringify(statusData)}`);
  }
  await new Promise((r) => setTimeout(r, 3500));
}

// 3. Download rendered MP4 stream
const mp4Res = await fetch(`${BASE_URL}/v1/videos/${encodeURIComponent(taskId)}/content`, { headers });
if (!mp4Res.ok) throw new Error(`Download failed: ${mp4Res.status}`);
await fs.writeFile("foxbee-video.mp4", Buffer.from(await mp4Res.arrayBuffer()));
```

## 连接问题排查

### 点击「导入到 CCS」没有反应

先手动打开 CC Switch，再点击一次。检查浏览器是否允许打开外部应用，以及系统是否关联了 `ccswitch://`。网页提示「未安装」不一定代表真的没装。

仍不能唤起时，留在 CC Switch 中，按上方对应智能体教程添加 **自定义供应商**，不用切换到手动编辑配置文件的流程。

### 配置好了，但还是走官方或旧供应商

ZCode 请在客户端内确认已启用 FoxBee 模型。其他客户端请确认在 **正确的应用栏** 添加了 FoxBee，已经保存，并在卡片点了「切换」。Claude Code CLI 和 Claude Desktop 的配置彼此独立。Codex、Gemini CLI、Claude Desktop、Grok Build 切换后需要重新打开客户端。

如果 CC Switch 提示环境变量冲突，按它的提示检查旧配置；不要同时保留两套相互覆盖的地址和密钥。

### 获取模型列表失败或为空

先确认地址、密钥、分组权限、有效期和客户端版本；更新 CC Switch 到当前稳定版后重试。列表为空时，不要随机填写其他分组的模型，带上密钥名称和错误内容联系支持。

### 请求报错怎么处理？

| 现象 | 先检查什么 |
|---|---|
| 400 / 404 | 选错协议、重复路径、模型 ID 或分组不匹配 |
| 401 | 密钥是否复制完整，是否已停用或更换 |
| 403 | 根据具体错误检查余额、有效期、分组、订阅或 IP 限制 |
| 429 | 并发、速率、密钥额度或订阅窗口；按提示等待，不要连续重试 |
| 502 / 503 / 504 | 上游异常或暂时过载；有限次退避重试，持续失败时联系支持 |

新建会话可以帮助排除旧上下文问题，但不保证解决上游故障。超时也不等于请求未执行，尤其不要反复提交长任务。

## 常见问题

### Claude Code CLI 和 Claude Desktop 能共用一份配置吗？

不能把它们当作同一个入口。终端版在 CC Switch 的「Claude Code」栏配置，桌面版在「Claude Desktop」栏配置；即使使用同一把有权限的密钥，也需要分别保存并切换。

### 必须开启 CC Switch 的本地路由吗？

本指南的原生协议直连不需要。需要跨协议转换、聚合或 Desktop 模型映射时，按 CC Switch 官方说明开启；使用这些模式时需要保持 CC Switch 运行。

### 在智能体里换过模型，为什么下次又变回去了？

当前会话的模型选择不一定会保存为供应商默认值。回到 CC Switch 编辑 FoxBee，把目标模型保存到供应商配置里，再切换并按要求重启客户端。

### 充值后为什么仍然不能调用？

账户余额、密钥额度、有效期、分组权限、订阅和速率限制相互独立。先看具体错误；充值不会自动解除所有限制。

### Kelivo 等聊天客户端怎么查余额，为什么偶尔报 404？

FoxBee 原生余额接口是 **`GET /v1/usage`**（不是 `/v1/dashboard`）。在 Kelivo 余额设置中，Base URL 含 `/v1` 时路径填 **`/usage`**、方式选 **`GET`**、提取字段填 **`balance`**（限额密钥或订阅组填 **`remaining`**）。若聊天时频繁出现 `404`，请优先检查客户端的「自动标题 / 摘要 / 翻译模型」是否选了当前密钥分组之外的模型，以及 Gemini 原生类型是否漏写了 `/v1beta`；详细对照见 [Kelivo 教程](#kelivo)。

## 密钥安全与支持

- 只在自己的设备和可信的 CC Switch 中填写密钥。导入链接包含密钥，不要转发，也不要在截图或公开代码中展示。
- 密钥泄露后立即在 [API 密钥](/keys) 停用并更换；不要把完整密钥发给客服。
- 联系侧栏客服时，提供客户端名称与版本、发生时间及所在时区、密钥名称、分组、模型 ID、请求 ID 和脱敏错误信息。

CC Switch 的操作名称与生效方式依据 [官方 v4.0.34 用户手册](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/zh/README.md) 核对。FoxBee 可用模型、权限与价格以工作台当前分组为准。

---

# Appendix B: FoxBee Complete Integration & API Guide (Full Guide - EN)

## Quick start

**Use CC Switch for the clients in this guide, except ZCode. Configure ZCode in the app itself.** You do not need to edit configuration files or paste environment variables into a terminal. Complete these three steps, then follow the tutorial for your agent.

1. **Install CC Switch** Download the current stable release from the [CC Switch website](https://ccswitch.io/) and open it. Skip this step if you only use ZCode. Each tutorial starts with the client’s official download or installation link.
2. **Prepare a FoxBee key** Create a key in [API Keys](/keys), choose its group, and check that group's models and prices in [Model Plaza](/model-plaza).
3. **Choose your agent** Open the tutorial for your client. The Gemini CLI tutorial is still available below.

> **Claude Code CLI runs in a terminal. Claude Desktop is the desktop application. They have separate configuration entries.** This page does not read your real key or call a model automatically.

## Install and use CC Switch

### Install before importing

Download the current stable version from the [CC Switch website](https://ccswitch.io/) or [official GitHub Releases](https://github.com/farion1231/cc-switch/releases/latest) (click either link). Open it once so your browser can launch the application. Button labels may vary slightly between versions.

On the CC Switch **Apps** page, check that your agent is installed and visible in the sidebar. **CC Switch manages configuration; it is not the agent itself.** Installing CC Switch alone does not install every client.

### Where does one-click import go?

The **Import to CCS** action on each [API Keys](/keys) row selects the application from that key's group platform:

| Group platform | Default import destination | Tutorial |
|---|---|---|
| Claude / Anthropic | Claude Code | [Claude Code CLI (terminal)](#claude-code-cli) |
| OpenAI | Codex | [Codex](#codex) |
| Gemini | Gemini CLI | [Gemini CLI](#gemini-cli) |
| Grok | Grok Build | [Grok Build](#grok-build) |

**Import to CCS does not automatically write a Claude Code configuration into Claude Desktop.** Follow the separate [Claude Desktop tutorial](#claude-desktop). For other groups or cross-protocol setups, confirm the group's supported protocol rather than assuming the default import destination guarantees compatibility.

### Start with direct connection

These tutorials use each FoxBee group's native protocol. You do not need local routing, aggregation, or failover for this setup. After saving a provider, activate it as described in the tutorial. For DeepSeek Harness, add the provider and select a model in the client.

For protocol conversion or model mapping, see the [official CC Switch manual](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/en/README.md). These features do not grant additional FoxBee group permissions.

## Prepare an API key

### Choose a group for your use

Create or view a key in [API Keys](/keys). Its group determines the available models, prices, and protocols. An agent name is not a model name or a group name.

- Claude Code CLI and Claude Desktop: these tutorials use a Claude group supporting Anthropic Messages.
- Codex: use a group supporting Responses; a GPT model name alone does not establish protocol compatibility.
- Gemini CLI: use a Gemini group supporting the native Gemini API.
- Grok Build: use a Grok group currently supporting this client.
- ZCode and DeepSeek Harness: use a group that supports OpenAI Chat Completions for the steps below.

Create separate keys for different groups and use recognizable provider names, such as FoxBee · My coding group. **Do not assume one key has access to every group.**

### Check models, quota, and expiry

Select the matching group in [Model Plaza](/model-plaza) to check model IDs and prices. In CC Switch, use **Fetch model list** in the provider form to verify availability. Keep the exact model ID returned for your group; do not invent version or capability suffixes.

Account balance, key quota, expiry, subscription windows, and concurrency limits apply independently. When replacing a key, update and save the provider in CC Switch, switch to it again, restart the client where required, and verify a request.

## Connect your agent

### Claude Desktop (desktop app)

**This is the standalone Claude desktop application, not Claude Code CLI in a terminal.** Select **Claude Desktop** in the CC Switch sidebar. The FoxBee Claude one-click import targets Claude Code by default; add a separate provider here.

#### 1. Install and find the desktop entry

Install Claude Desktop from the [official download page](https://claude.com/download). If its CC Switch sidebar entry is missing, check whether it is hidden on the Apps page. Do not select Claude Code instead.

#### 2. Add a custom provider

Choose **Add provider → Custom provider** and name it FoxBee. Enter a Claude group key supporting Messages from [API Keys](/keys), set the endpoint to **`https://foxbeeai.com`**, and keep the connection method at **Direct**.

#### 3. Add the models you will use

Under **Model list**, click **Fetch model list**, then **Add model**. Click the **dropdown arrow** on the new model row, search for a Claude model supported by your group, and select it. Repeat to add more models.

Start with natively supported Claude models. If CC Switch says a model needs **Model mapping**, follow its prompts and the [official Desktop guide](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/en/2-providers/2.6-claude-desktop.md) instead of merely renaming the model. Model mapping requires CC Switch to keep running. Features such as 1M context also depend on the group's stated support.

#### 4. Save, switch, and reopen the desktop app

Click **Save**, then **Switch** on the FoxBee provider card. **Completely quit and reopen Claude Desktop**, not just its chat window. Select the model you added, complete a conversation, and check [Usage](/usage).

### Claude Code CLI (terminal)

**This is Claude Code CLI running in a terminal, not Claude Desktop.** Select **Claude Code** in CC Switch; some versions shorten the label to Claude.

#### 1. Install the terminal client

Follow the [official Claude Code CLI installation instructions](https://code.claude.com/docs/en/setup#install-claude-code), then confirm that you can launch it from a terminal.

#### 2. Import your key

In [API Keys](/keys), find a Claude group key supporting Messages and click **Import to CCS** on its row. Allow the browser to open the application and confirm the import. Find the FoxBee provider under **Claude Code** in CC Switch.

If the browser cannot launch it, choose Add provider → Custom configuration in the same application entry. Use FoxBee as the name, **`https://foxbeeai.com`** as the endpoint, your group's API key, and **Anthropic Messages** as the upstream format.

#### 3. Select a model and switch

Edit the FoxBee provider, click **Fetch model list**, and select a Claude model supported by your group. Check the default model. If Sonnet, Opus, or Haiku role fields are shown, only assign models your group actually provides.

Save, then click **Switch** on the provider card and check that it shows In use. Start with **Direct** mode; local routing is not required.

#### 4. Verify in your terminal

Launch Claude Code CLI and send a normal request, such as “Introduce your capabilities in two sentences.” Direct switching usually supports hot reload. If old settings persist, exit the CLI, launch it again, and start a new session.

Check the key, group, model, and cost in [Usage](/usage). Do not use Claude Desktop to verify this terminal configuration.

### Codex

**Select Codex in CC Switch.** It is separate from Claude Code CLI and Claude Desktop. Both the terminal client and the Codex desktop application must be reopened as directed after switching.

#### 1. Install Codex

Choose the [official Codex desktop download](https://chatgpt.com/download/) or the [official Codex CLI installation instructions](https://learn.chatgpt.com/docs/codex/cli).

#### 2. Import the FoxBee provider

In [API Keys](/keys), click **Import to CCS** for a key in an OpenAI-platform group. Allow the application to open and confirm the import, then find FoxBee under **Codex** in CC Switch.

Keep the imported endpoint **`https://foxbeeai.com`**. When adding a custom provider, **`https://foxbeeai.com/v1`** is also supported; FoxBee accepts both Responses routes. Do not enter the full `/v1/responses` path. Select **Responses** as the upstream format.

For a Responses group on another platform, add a custom provider under Codex with that group's key. A provider automatically imported under a different application does not configure Codex for you.

#### 3. Fetch and save your models

Click **Fetch model list**, select a model available to this key, and set the default. **The prefilled import model may not be the one you want or have access to. Check it before continuing.**

To use several models from the Codex menu, add them to the provider's model list in CC Switch and save. Configure reasoning and context windows only according to the model and group's actual capabilities; advanced settings are not required for initial setup.

#### 4. Switch and restart Codex

Save and click **Switch** on the FoxBee card. **Exit and relaunch Codex CLI, or completely quit and reopen the Codex desktop application.** Closing one chat is not a full restart. Model-list changes also require a restart.

Start a new session, complete a normal conversation, and check the actual key, group, model, and cost in [Usage](/usage).

### Grok Build

**Select Grok Build in CC Switch.** Use a Grok group supporting this client. Do not configure it in the Codex or Gemini CLI provider list.

#### 1. Install Grok Build

Follow the [official Grok Build installation instructions](https://docs.x.ai/build/overview) for the terminal client.

#### 2. Import your Grok key

In [API Keys](/keys), click **Import to CCS** for a Grok group key, allow the application to open, and confirm. Find FoxBee under **Grok Build**.

Use **`https://foxbeeai.com/v1`** as the endpoint. Check the model and protocol after import and use the group's supported Responses entry rather than an unrelated platform preset. If one-click import is unavailable, add a custom provider in the same application entry with this endpoint and your group key.

#### 3. Confirm the model and switch

Click **Fetch model list**, select a model actually provided by the group, and save. Click **Switch** on the provider card and check that it shows In use.

#### 4. Restart and verify

**Exit and relaunch Grok Build**, complete a normal request in a new session, and verify the key, group, model, and cost in [Usage](/usage). For programmatic or AI-agent image and video generation, see [AI Image API](#image-api) and [AI Video API](#video-api) below.

### ZCode

**Set up ZCode in the app itself. It does not use CC Switch.**

#### 1. Download and install ZCode

Open the [official ZCode download page](https://zcode.z.ai/en/docs/install) and choose the installer for your system.

#### 2. Add a provider in ZCode

Go to **Settings → Model Settings → Add Provider** and name it FoxBee. Set the OpenAI base URL to **`https://foxbeeai.com/v1`**. Use an [API key](/keys) from a group that supports OpenAI Chat Completions.

#### 3. Add and enable a model

Select **Add Model** and enter the group's exact model ID from the [Model Plaza](/model-plaza). Save and enable it. For details on the fields, see the [official ZCode model setup docs](https://zcode.z.ai/en/docs/configuration).

#### 4. Select the model and test

Choose the FoxBee model in the chat model picker and send a short message. Check the group, model, and charge in [Usage](/usage).

### DeepSeek Harness

#### 1. Install the client

Use **CC Switch v4.0.22 or newer**. Choose the [official desktop download](https://www.deepseek.com/en/download/) or the [official CLI installation instructions](https://github.com/deepseek-ai/deepseek-harness). You can also install the CLI from the CC Switch Apps page.

#### 2. Add a FoxBee provider

In CC Switch, select **DeepSeek Harness** and add a custom provider. Name it FoxBee, select **OpenAI Chat Completions**, and set the endpoint to **`https://foxbeeai.com/v1`**. Use an [API key](/keys) from a group that supports this protocol. FoxBee does not import directly to this app entry.

#### 3. Add a model

Check the model ID for your group in the [Model Plaza](/model-plaza). Add the model to the provider and save it. Add the provider to the active list in CC Switch, then select a FoxBee model in DeepSeek Harness.

#### 4. Send a test request

Reopen DeepSeek Harness if the model does not appear. Send a short message, then check the group, model, and charge in [Usage](/usage).

### Kelivo (mobile & chat clients)

**Configure Kelivo directly inside the app—CC Switch is not required.** The endpoint and balance rules below also apply to Cherry Studio, ChatBox, and other multi-protocol chat clients.

#### 1. Install Kelivo and prepare group keys

Download the current release from [Kelivo official GitHub Releases](https://github.com/Chevey339/kelivo/releases). Create separate keys for each group in [API Keys](/keys) and check exact model IDs in [Model Plaza](/model-plaza). **Each FoxBee key is bound to one group; do not reuse a single key across unrelated groups.**

#### 2. Match provider type and base URL by protocol

Add a custom provider in Kelivo and match the provider type and base URL to your key's group (do not append `/responses`, `/messages`, or `/videos` manually):

| Group / Use case | Kelivo provider type | Base URL | Key notes |
|---|---|---|---|
| OpenAI / CN / Grok text | OpenAI (prefer Responses API, or Chat) | `https://foxbeeai.com/v1` | Prefer Responses when supported; `https://api-cn.foxbeeai.com/v1` is also available for mainland China acceleration |
| Claude groups | Anthropic / Claude | `https://foxbeeai.com` | Use the root URL without appending `/v1/messages` |
| Gemini groups (`#50`, `#63`, etc.) | **Gemini (native)** or OpenAI-compatible | Native: `https://foxbeeai.com/v1beta`; OpenAI-compatible: `https://foxbeeai.com/v1` | Native Gemini providers **must include `/v1beta`**; set reasoning via parameters instead of `-high` / `-low` suffixes |
| AI Images (`#11`, `#30`, `#47`) | OpenAI-compatible | `https://foxbeeai.com/v1` | Call from the image / media workflow rather than a plain text chat check |
| AI Videos · First frame (`#64` Grok 1.5, `#48` Muse) | **OpenAI-compatible (OpenAI Videos protocol)** | `https://foxbeeai.com/v1` | Supports `POST /v1/videos` multipart first-frame upload, status polling, and verified `/content` MP4 download; **do not switch to Ark / Seedance or run video-only models in a chat box** |
| AI Videos · **First + Last frame (`#64` Grok 1.5 `last_frame`)** | **Built-in `Grok (xAI)` provider in Kelivo** (edit its Base URL; do not use a generic OpenAI provider) | `https://foxbeeai.com/v1` | Select model **`grok-imagine-video-1.5`** (same tariff as `preview`) so Kelivo unlocks both **first frame + last frame** (`480p`/`720p`), submits native xAI `/v1/videos/generations`, and downloads MP4 automatically |

#### 3. Enable live balance checks and prevent 404s

- **Live balance query (do not use `/v1/dashboard`)**: FoxBee exposes `GET /v1/usage` natively. In Kelivo's balance settings:
  - **Balance Path**: enter **`/usage`** when the provider base URL ends in `/v1` (or **`/v1/usage`** when using the root URL `https://foxbeeai.com`)
  - **Method**: **`GET`**
  - **Result Path**: **`balance`** for wallet-balance keys, or **`remaining`** for quota-limited keys and subscription groups
- **Avoid repeated 404 (`model_not_allowed`) errors**: If Kelivo's automatic conversation title, summary, or translation model points to a model outside your current key's group, background requests will return `404`. Disable auto-titling or assign a model available in the same group.

#### 4. Verify chat, media, and billing

Send a short test message for text models, or run a media task from the dedicated image/video screen instead of testing video-only models in a chat window. Then confirm the key, group, model, and actual charge in [Usage](/usage).

### Gemini CLI

**This is Gemini CLI in a terminal.** Select **Gemini CLI** in CC Switch. Do not copy OpenAI-compatible settings from another chat client into this setup.

#### 1. Install Gemini CLI

Follow the [official Gemini CLI installation instructions](https://geminicli.com/docs/get-started/installation/), then confirm that you can launch it from a terminal.

#### 2. Import a Gemini group key

In [API Keys](/keys), click **Import to CCS** for your Gemini group key. Allow the application to open and confirm the import, then find FoxBee under **Gemini CLI**.

Keep the endpoint at **`https://foxbeeai.com`** and use the native Gemini protocol. **Do not append `/v1` or `/v1beta` here.** Gemini CLI handles the API version path itself.

#### 3. Fetch a model and switch

Edit the provider, click **Fetch model list**, select a model supplied by the current Gemini group, and save. Follow the group's current reasoning guidance. Do not append `-high` or `-low` to model IDs yourself.

Click **Switch** on the provider card and check that it shows In use. If you need to add it yourself, use the same endpoint and key in a custom provider under Gemini CLI.

#### 4. Relaunch and verify

**Exit and relaunch Gemini CLI.** An existing session does not automatically reload the new endpoint, key, or model. Make a request in a new session and check it in [Usage](/usage).

## Models, reasoning, and cost

### Choose models from your current group

Fetch the model list in CC Switch, or select your key's group in [Model Plaza](/model-plaza). Do not copy a fixed model ID from another tutorial. Dashes, dots, and version suffixes must match the group's supported spelling.

A successful model-list query only confirms directory access, not generation. Save a model, switch providers, and complete a real request before checking [Usage](/usage).

### Set reasoning for the model's capabilities

Choose a supported reasoning level in CC Switch or the agent's own model settings. Do not set every model to `max` or append reasoning levels to model IDs.

An explicitly supplied, valid client setting is preserved. When none is supplied, some verified models follow FoxBee defaults. Client defaults may be sent automatically, so **not changing a setting yourself does not mean the request contains no reasoning parameter**.

### Check actual usage for charges

See [Model Plaza](/model-plaza) for current group pricing and [Usage](/usage) for actual charges. CC Switch balance or usage queries do not replace per-request records. Real validation conversations incur normal model usage fees; avoid repeated testing.

## CC Switch endpoint reference

This table checks **CC Switch provider fields** only. Prefer one-click import when available; you do not need to construct API request paths.

| Agent | CC Switch entry | Endpoint | Protocol and activation |
|---|---|---|---|
| Claude Desktop (desktop app) | Claude Desktop | `https://foxbeeai.com` | Messages; completely quit and reopen |
| Claude Code CLI (terminal) | Claude Code / Claude | `https://foxbeeai.com` | Messages; usually hot reloads, relaunch if necessary |
| Codex | Codex | Imported as `https://foxbeeai.com`; `https://foxbeeai.com/v1` also works | Responses; restart after switching or changing the model list |
| Grok Build | Grok Build | `https://foxbeeai.com/v1` | Responses; restart the client |
| DeepSeek Harness | DeepSeek Harness | `https://foxbeeai.com/v1` | Chat Completions; add the provider, then select a model in the client |
| Gemini CLI | Gemini CLI | `https://foxbeeai.com` | Native Gemini; restart CLI, no version suffix |

**Do not enter complete `/messages`, `/responses`, or `/generateContent` paths.** Clients append their own paths; do not copy endpoint suffixes from unrelated applications into CC Switch.

## AI Image API

FoxBee exposes OpenAI-compatible text-to-image (`POST /v1/images/generations`) and image-to-image / inpainting (`POST /v1/images/edits`) endpoints. You can create visually in [Image Studio](/image-studio), or share [`/llms-full.txt`](/llms-full.txt) with your AI coding agent so it can call FoxBee image models directly.

### 1. Image groups, models, and pricing

Create an API key bound to the target image group in [API Keys](/keys). Each group unlocks its own model set—verify available models with `GET https://foxbeeai.com/v1/models` using that key, or query the public live catalog via `GET https://foxbeeai.com/api/v1/model-plaza`:

| Group (ID) | Model IDs | Base price | Sizes & capability limits |
|---|---|---|---|
| **GPT Image (`#11`)** | `gpt-image-2.5-flare`, `gpt-image-2.5-sunburst`, `gpt-image-2` | **$0.065 / image** | `n: 1..4`; sizes `1024x1024`, `1536x1024`, `1024x1536`, `2048x2048`, `2048x1152`, `auto`; `quality: auto\|low\|medium\|high`; `output_format: png\|webp\|jpeg`; up to 4 edit reference images (≤ 20 MiB each) |
| **GPT 4K Image (`#30`)** | `gpt-image-2.6-flare`, `gpt-image-2.6-sunburst`, `gpt-image-2` | **$0.11 / image** (flat across 1K/2K/4K) | Unlocks **native 4K sizes** (`3840x2160`, `2160x3840`, `2880x2880`, `3456x2304`, `3200x2400`, `3840x1600`, plus custom `WxH` in multiples of 16 within `256..3840`); `quality: auto\|low\|medium\|high\|xhigh\|max`; `background: "transparent"` (`png`/`webp`), PNG `mask` inpainting, `markup` sketch overlay, `input_fidelity: auto\|low\|high`, native animated `gif` (`frame_count: 2..16`, `frame_duration_ms: 20..2000`), and vector `svg` (generations only); up to 5 reference images (≤ 20 MiB each, ≤ 50 MiB total) |
| **Muse Image (`#47`)** | `muse-image` (alias `gpt-image-muse`) | **$0.07 / image** | **Native 2K original output** (e.g. `1920×1280`, `1344×1792`) with **5 concurrent lanes**; `n: 1`, pass `"response_format": "b64_json"` explicitly (`extra_body={"response_format": "b64_json"}` in OpenAI Python SDK); supports `output_format: "webp"\|"png"\|"jpeg"`, `size` (`auto`, `2K`, `16:9`, `9:16`, `3:2`, `2:3`, `1:1`, `1536x1024`, etc.) and `aspect_ratio`; up to 4 reference images (≤ 10 MiB each, ≤ 20 MiB total, max edge ≤ 8192 px) |

> **Gateway origins & timeouts**: `https://foxbeeai.com`, `https://api.foxbeeai.com`, and `https://api-cn.foxbeeai.com` serve identical routes. Image rendering typically takes 25–60s; configure a client timeout of **360 seconds**.

### 2. Text-to-image (`POST /v1/images/generations`)

Send `application/json` and decode `data[].b64_json` from the response:

```bash
curl -fsSL "https://foxbeeai.com/v1/images/generations" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2.6-flare",
    "prompt": "Warm honey-amber glassmorphism cinema studio mascot bee holding a 35mm clapperboard, volumetric rim lighting",
    "size": "3840x2160",
    "n": 1,
    "quality": "high",
    "output_format": "png",
    "response_format": "b64_json"
  }' | jq -r '.data[0].b64_json' | base64 -d > foxbee-image.png
```

```python
import base64, os
from openai import OpenAI

client = OpenAI(
    base_url="https://foxbeeai.com/v1",
    api_key=os.environ["FOXBEE_API_KEY"],
    timeout=360.0,
)

# Always include extra_body={"response_format": "b64_json"} so both GPT Image and Muse Image return Base64
result = client.images.generate(
    model="gpt-image-2.5-flare",
    prompt="A cozy sunlit cyberpunk bookshop with warm amber neon signs",
    size="1536x1024",
    n=1,
    quality="high",
    extra_body={"response_format": "b64_json"},
)

with open("foxbee-image.png", "wb") as f:
    f.write(base64.b64decode(result.data[0].b64_json))
```

### 3. Image editing & inpainting (`POST /v1/images/edits`)

Send `multipart/form-data` (`image/png`, `image/jpeg`, or `image/webp`):
- **Single reference image**: use field name `image`;
- **Multiple reference images (2+)**: repeat field name `image[]`;
- **Mask / markup (`#30 GPT 4K Image` only)**: attach a PNG alpha mask in `mask` (transparent pixels mark the region to repaint) or a sketch guide in `markup`.

```bash
curl -fsSL "https://foxbeeai.com/v1/images/edits" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -F "model=gpt-image-2.6-flare" \
  -F "prompt=Keep the character design identical, change scene to golden-hour rooftop cinema" \
  -F "size=2048x1152" \
  -F "n=1" \
  -F "response_format=b64_json" \
  -F "image=@input.png" \
  | jq -r '.data[0].b64_json' | base64 -d > foxbee-edited.png
```

## AI Video API

FoxBee video generation uses a unified **3-step asynchronous workflow (`Create → Poll with same key → Download MP4 stream`)**, also available interactively in [Video Studio](/video-studio) (Quick Studio, ✦ FoxBee Infinite Canvas, and Director's Cut Dock).

### 1. Video groups, models, and parameter matrix

| Group (ID) | Model ID | Base price | Duration `duration` | Resolution `resolution` | Reference image rules & constraints |
|---|---|---|---|---|---|
| **Grok Video (`#64` · Recommended)** | `grok-imagine-video-1.5-lite` | `480p` **$0.04/s** · `720p` **$0.06/s** · `1080p` **$0.15/s** | `1–15` s (integer) | `480p` \| `720p` \| `1080p` | Text-to-video or **1 opening frame** `image` (≤ 8 MiB); does **not** accept multi-image `reference_images`; `aspect_ratio`: `16:9\|9:16\|1:1\|4:3\|3:4\|3:2\|2:3\|21:9` |
| **Grok Video (`#64` · Pro / Last-Frame / Multi-Ref)** | `grok-imagine-video-1.5-preview`, `grok-imagine-video-1.5` | `480p` **$0.10/s** · `720p` **$0.14/s** · `1080p` **$0.20/s** | `1–15` s (integer) | `480p\|720p\|1080p` (0–1 opening frame); **`480p\|720p` with `last_frame` or 2–14 refs** | Text-to-video, **1 opening frame `image`**, **end frame `last_frame`** (optionally paired with `image`), OR **2–14 `reference_images`** (≤ 8 MiB each, ≤ 22 MiB total); **do not mix `reference_images` with `image` or `last_frame`** |
| **Muse Video (`#48` · Cinema)** | `muse-video` | **$0.10 / s** (billed by actual output seconds) | `1–10` s (10s single-shot cap) | `auto` (default) \| `480p` \| `720p` (no `1080p`) | Text-to-video, **1 opening frame `image`** (≤ 10 MiB), and **`POST /v1/videos/edits` video editing** (source `video` + optional appearance `reference_image` or `reference_video`, ≤ 10 MiB per file / ≤ 28 MiB total); `aspect_ratio`: `auto\|16:9\|9:16\|1:1\|4:3\|3:4` |
| **Seedance Video (`#56` · High-Cost API Only)** | `seedance-2.0`, `seedance-2.5` | **$10 / req** (2.0) · **$12 / req** (2.5) | Model default | Model default | **AI Agent Cost Guardrail**: Always default to `#64` Grok 1.5 or `#48` Muse Video. **Never auto-select Seedance for testing or batch runs** unless the user explicitly names `seedance-*` and confirms the per-request price |

### 2. Three-step async video protocol (Required for AI Agents)

1. **Step 1: Create video job** — `POST https://foxbeeai.com/v1/videos/generations` (`POST /v1/videos` is also accepted, including OpenAI Videos `multipart/form-data` with `seconds`, `size`, and `input_reference` used by Kelivo and OpenAI SDKs; **do not call video-only models on text endpoints `/v1/responses`, `/v1/chat/completions`, or `/v1/messages`**)
   - Headers: `Authorization: Bearer $FOXBEE_API_KEY`, `Content-Type: application/json`.
   - Image input encoding (Base64 Data URL `data:image/png;base64,...` for PNG / JPEG / WebP):
     - **0 images (text-to-video)**: omit both `image` and `reference_images`;
     - **1 image (image-to-video)**: pass `"image": {"url": "data:image/png;base64,<BASE64>"}`;
     - **First + last frame (`grok-imagine-video-1.5` / `grok-imagine-video-1.5-preview`)**: pass `"image": {"url": "data:image/png;base64,<FIRST>"}` and `"last_frame": {"url": "data:image/png;base64,<LAST>"}` (or `last_frame` alone) with `resolution` set to `"720p"` or `"480p"`;
     - **2–14 images (`grok-imagine-video-1.5` / `grok-imagine-video-1.5-preview` only)**: pass `"reference_images": [{"url": "data:image/png;base64,<BASE64_1>"}, ...]`, omit `image` and `last_frame`, and set `resolution` to `"720p"` or `"480p"`.
   - Extract task ID from `request_id` (falling back to `id` or `task_id`).
2. **Step 2: Poll job status** — `GET https://foxbeeai.com/v1/videos/{task_id}`
   - **Must use the exact same API key** that created the job (`(user, apiKey, requestId)` ownership isolation returns `404` for a different key).
   - Poll every `3–5 seconds`:
     - In progress: `pending`, `queued`, `processing`, `running`, `in_progress` (optional `progress: 0..100`);
     - Succeeded: `done`, `succeeded`, `completed`, `success`;
     - Terminal failure (not billed): `failed`, `expired`, `cancelled`, `error`.
3. **Step 3: Download MP4 stream** — `GET https://foxbeeai.com/v1/videos/{task_id}/content`
   - **Must send `Authorization: Bearer $FOXBEE_API_KEY`**. Streams `video/mp4` directly from FoxBee's authenticated content proxy (supports HTTP `Range`).

### 3. Complete 3-step code examples (cURL / Python / Node.js)

```bash
# 1) Submit async video task (#64 Grok Video key)
TASK_ID=$(curl -fsSL "https://foxbeeai.com/v1/videos/generations" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "grok-imagine-video-1.5-lite",
    "prompt": "Slow cinema dolly push-in on an amber-lit watchmaker workbench, golden dust motes floating in shallow depth of field",
    "duration": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9"
  }' | jq -r '.request_id // .id')

# 2) Poll every 3s with the same API key
while true; do
  RESP=$(curl -fsSL "https://foxbeeai.com/v1/videos/$TASK_ID" -H "Authorization: Bearer $FOXBEE_API_KEY")
  STATUS=$(printf '%s' "$RESP" | jq -r '.status')
  echo "Task $TASK_ID -> $STATUS"
  case "$STATUS" in
    done|succeeded|completed|success) break ;;
    failed|expired|cancelled|error) echo "$RESP" >&2; exit 1 ;;
  esac
  sleep 3
done

# 3) Download rendered MP4 via FoxBee content proxy
curl -fsSL "https://foxbeeai.com/v1/videos/$TASK_ID/content" \
  -H "Authorization: Bearer $FOXBEE_API_KEY" \
  -o foxbee-video.mp4
```

```python
import base64, os, time, requests

BASE_URL = "https://foxbeeai.com"
API_KEY = os.environ["FOXBEE_API_KEY"]  # Key bound to #64 Grok Video or #48 Muse Video
HEADERS = {"Authorization": f"Bearer {API_KEY}"}

def encode_data_url(path: str, mime: str = "image/png") -> str:
    with open(path, "rb") as f:
        return f"data:{mime};base64," + base64.b64encode(f.read()).decode("ascii")

# 1. Create job (add "image": {"url": encode_data_url("frame.png")} for 1-frame I2V,
#    or "reference_images": [{"url": ...}, {"url": ...}] with resolution="720p" on 1.5-preview)
create_resp = requests.post(
    f"{BASE_URL}/v1/videos/generations",
    headers={**HEADERS, "Content-Type": "application/json"},
    json={
        "model": "grok-imagine-video-1.5-preview",
        "prompt": "Cinematic orbital tracking shot around a glowing honey-gold mecha fox on a rainy neon bridge",
        "duration": 5,
        "resolution": "720p",
        "aspect_ratio": "16:9",
    },
    timeout=120,
)
create_resp.raise_for_status()
created = create_resp.json()
task_id = created.get("request_id") or created.get("id")

# 2. Poll with the same API key until done
while True:
    st_resp = requests.get(f"{BASE_URL}/v1/videos/{task_id}", headers=HEADERS, timeout=45)
    st_resp.raise_for_status()
    st = st_resp.json()
    status = str(st.get("status", "")).lower()
    if status in ("done", "succeeded", "completed", "success"):
        break
    if status in ("failed", "expired", "cancelled", "canceled", "error"):
        raise RuntimeError(f"Video generation failed: {st}")
    time.sleep(3)

# 3. Download MP4 via FoxBee content proxy
mp4_resp = requests.get(f"{BASE_URL}/v1/videos/{task_id}/content", headers=HEADERS, timeout=180)
mp4_resp.raise_for_status()
with open("foxbee-video.mp4", "wb") as f:
    f.write(mp4_resp.content)
```

```javascript
import fs from "node:fs/promises";

const BASE_URL = "https://foxbeeai.com";
const headers = { Authorization: `Bearer ${process.env.FOXBEE_API_KEY}` };

// 1. Create async video job
const createRes = await fetch(`${BASE_URL}/v1/videos/generations`, {
  method: "POST",
  headers: { ...headers, "Content-Type": "application/json" },
  body: JSON.stringify({
    model: "muse-video",
    prompt: "Hand-painted anime breeze blowing across golden wheat fields at sunset, gentle camera pan",
    duration: 5,
    resolution: "auto",
    aspect_ratio: "16:9",
  }),
});
if (!createRes.ok) throw new Error(await createRes.text());
const created = await createRes.json();
const taskId = created.request_id || created.id;

// 2. Poll with the exact same API key
for (;;) {
  const statusRes = await fetch(`${BASE_URL}/v1/videos/${encodeURIComponent(taskId)}`, { headers });
  const statusData = await statusRes.json();
  const s = String(statusData.status || "").toLowerCase();
  if (["done", "succeeded", "completed", "success"].includes(s)) break;
  if (["failed", "expired", "cancelled", "canceled", "error"].includes(s)) {
    throw new Error(`Video failed: ${JSON.stringify(statusData)}`);
  }
  await new Promise((r) => setTimeout(r, 3500));
}

// 3. Download rendered MP4 stream
const mp4Res = await fetch(`${BASE_URL}/v1/videos/${encodeURIComponent(taskId)}/content`, { headers });
if (!mp4Res.ok) throw new Error(`Download failed: ${mp4Res.status}`);
await fs.writeFile("foxbee-video.mp4", Buffer.from(await mp4Res.arrayBuffer()));
```

## Connection troubleshooting

### Import to CCS does nothing

Open CC Switch yourself, then try the action again. Check your browser's external-application permission and the system's `ccswitch://` association. A website message saying Not installed does not prove the application is missing.

If it still cannot open, add a **custom provider in CC Switch** using the matching tutorial above. You do not need to switch to manual configuration-file editing.

### The client still uses the official or previous provider

For ZCode, check that you enabled the FoxBee model in the app. For other clients, confirm that FoxBee was added under the **correct application entry**, saved, and activated with Switch. Claude Code CLI and Claude Desktop have independent configurations. Reopen Codex, Gemini CLI, Claude Desktop, and Grok Build after switching.

If CC Switch reports an environment-variable conflict, follow its prompts to check the old configuration. Avoid keeping conflicting endpoints and keys active at the same time.

### Fetching models fails or returns an empty list

Check the endpoint, key, group permissions, expiry, and client version. Update CC Switch to the current stable version and retry. Do not enter random models from another group if the list is empty; contact support with the key name and error details.

### What should I check for a failed request?

| Symptom | First checks |
|---|---|
| 400 / 404 | Protocol, repeated endpoint paths, model ID, and group compatibility |
| 401 | Whether the full key was copied, disabled, or replaced |
| 403 | Balance, expiry, group, subscription, or IP restrictions according to the specific error |
| 429 | Concurrency, rate, key quota, or subscription limits; wait as instructed instead of retrying continuously |
| 502 / 503 / 504 | Upstream errors or temporary overload; use bounded backoff and contact support if persistent |

A new session can help isolate stale context, but does not guarantee recovery from upstream errors. A timeout does not prove that a request was never executed, particularly for long-running work.

## FAQ

### Can Claude Code CLI and Claude Desktop share one configuration?

Treat them as separate entries. Configure the terminal client under Claude Code and the desktop app under Claude Desktop in CC Switch. Even when the same authorized key is used, save and switch each provider separately.

### Do I have to enable CC Switch local routing?

Not for the native direct connections in this guide. Follow the official instructions when you need protocol conversion, aggregation, or Desktop model mapping. Those modes require CC Switch to keep running.

### Why did my model selection revert later?

An in-session selection may not become the provider's default. Edit FoxBee in CC Switch, save the desired model, switch providers again, and restart the client where required.

### Why can I still not call models after topping up?

Account balance, key quota, expiry, group permissions, subscription windows, and rate limits are independent. Read the specific error; topping up does not remove every restriction.

### How do I query balance in Kelivo or other chat apps, and why do I see 404?

Use FoxBee's native **`GET /v1/usage`** endpoint (not `/v1/dashboard`). In Kelivo, set Balance Path to **`/usage`** (when base URL ends in `/v1`), Method to **`GET`**, and Result Path to **`balance`** (or **`remaining`** for quota-limited/subscription keys). For repeated `404` responses, check that auto-title/summary/translation models belong to the same group as the key and that native Gemini providers use `/v1beta`; see the [Kelivo tutorial](#kelivo).

## Key safety and support

- Enter keys only on your own device in a trusted CC Switch installation. Import links contain the key; do not share them or expose credentials in screenshots or public code.
- Disable and replace a leaked key in [API Keys](/keys) immediately. Do not send full keys to support.
- Use the sidebar support entry and provide the client name and version, time and timezone, key name, group, model ID, request ID, and redacted error details.

CC Switch labels and activation behavior were checked against the [official v4.0.34 manual](https://github.com/farion1231/cc-switch/blob/v4.0.34/docs/user-manual/en/README.md). FoxBee models, permissions, and pricing follow the current groups in the console.
