# FoxBee AI API Gateway (https://foxbeeai.com)

> FoxBee 是一站式多模态 AI API 网关与创作工作台，统一提供文本推理（OpenAI Responses / Chat Completions、Anthropic Messages、Gemini Native）、AI 生图与局部重绘（`/v1/images/generations`、`/v1/images/edits`）以及异步 AI 视频生成（`/v1/videos/generations` -> `/v1/videos/{id}` -> `/v1/videos/{id}/content`）。

## 机器可读文档入口 (Machine-Readable Entrypoints)

- [全量 API 与接入规范 (Markdown)](https://foxbeeai.com/llms-full.txt): 包含所有文本、生图、视频接口完整请求/响应结构与代码示例（推荐 AI 智能体首选抓取）
- [AI 生图与视频专项 API 规范 (Markdown)](https://foxbeeai.com/docs/media-api.md): 聚焦生图（#11/#30/#47）与视频（#64/#48）模型、参数边界、多参考图与异步三步下载闭环
- [OpenAPI 3.1 接口定义 (JSON)](https://foxbeeai.com/openapi.json): 供 Dify、Coze、FastGPT、GPT Actions、Cursor 等工具直接导入 Schema
- [实时公开模型目录与价格接口 (JSON)](https://foxbeeai.com/api/v1/model-plaza): 免鉴权 GET 接口，返回 FoxBee 当前所有公开分组、模型 ID 与实时单价

## 网关域名与鉴权 (Base URLs & Authentication)

- 主站网关：`https://foxbeeai.com`（等效域名：`https://api.foxbeeai.com`，国内加速：`https://api-cn.foxbeeai.com`）
- 鉴权方式：`Authorization: Bearer $FOXBEE_API_KEY`（Anthropic 原生协议亦兼容 `x-api-key`，Gemini 原生协议亦兼容 `x-goog-api-key`）
- 分组隔离规则：FoxBee 的每把 API Key 绑定一个特定分组（Group）。调用前可用 `GET https://foxbeeai.com/v1/models`（带 Bearer Key）查询该 Key 实际解锁的模型 ID，严禁跨分组硬猜模型名。
- 实时余额与用量查询：`GET https://foxbeeai.com/v1/usage`（携带 Bearer Key，返回 `balance`、`remaining`、`unit`、`usage`；供 Kelivo、CC Switch 等客户端查余额，非 `/v1/dashboard`）。

## 核心生图与视频接口速览 (Media API Quick Reference)

### 1. AI 生图与改图 (`/v1/images/*`)
- **文生图**：`POST https://foxbeeai.com/v1/images/generations` (`application/json`, 返回 `data[].b64_json`, 建议超时 360s)
- **图生图 / 蒙版重绘**：`POST https://foxbeeai.com/v1/images/edits` (`multipart/form-data`；1 张参考图字段名为 `image`，2 张及以上字段名为 `image[]`；#30 支持 PNG 透明蒙版 `mask` 与涂鸦层 `markup`)
- **主力生图分组**：
  - `#11 GPT 生图`（$0.065/张）：`gpt-image-2.5-flare`、`gpt-image-2.5-sunburst`、`gpt-image-2`（1K/2K 尺寸，最多 4 张参考图）
  - `#30 GPT 4K生图`（$0.11/张，1K/2K/4K 同价）：`gpt-image-2.6-flare`、`gpt-image-2.6-sunburst`、`gpt-image-2`（支持 4K 如 `3840x2160`、透明背景 `background=transparent`、蒙版 `mask`、动态 `gif`、矢量 `svg`，最多 5 张参考图）
  - `#47 Muse 生图`（$0.07/张）：`muse-image`（兼容别名 `gpt-image-muse`，**原生 2K 原图输出**如 `1920x1280`/`1344x1792`，支持 5 并发、`output_format: "webp"|"png"|"jpeg"`、`size: "2K"|"auto"|"16:9"|"3:2"` 及 `aspect_ratio`；每次 `n=1`，OpenAI SDK 调用需显式传 `response_format="b64_json"`）

### 2. AI 视频生成异步三步闭环 (`/v1/videos/*`)
1. **创建任务**：`POST https://foxbeeai.com/v1/videos/generations` (`application/json`) 或 `POST https://foxbeeai.com/v1/videos`（兼容 Kelivo / OpenAI Videos SDK 的 `multipart/form-data`：`seconds` / `size` / `input_reference`） -> 读取返回的 `request_id`（或 `id`）；**纯视频模型严禁通过 `/v1/responses`、`/v1/chat/completions` 或 `/v1/messages` 文本入口调用**
2. **同密钥轮询**：`GET https://foxbeeai.com/v1/videos/{request_id}`（**必须使用创建该任务时的同一把 API Key**；每 3–5s 查询，`status` 为 `done|succeeded|completed` 表示完成，`failed|expired|cancelled` 表示失败且不扣费）
3. **鉴权下载成片**：`GET https://foxbeeai.com/v1/videos/{request_id}/content`（**必须携带 `Authorization: Bearer $FOXBEE_API_KEY` 头**，返回 `video/mp4` 字节流）
- **主力视频分组与参数边界**：
  - `#64 Grok 视频`（主力推荐）：
    - `grok-imagine-video-1.5-lite`：480p $0.04/s · 720p $0.06/s · 1080p $0.15/s；`duration: 1..15`；支持纯文生或 1 张首帧 `image: {"url": "data:image/png;base64,..."}`（不支持多图 `reference_images`）
    - `grok-imagine-video-1.5-preview` / `grok-imagine-video-1.5`：480p $0.10/s · 720p $0.14/s · 1080p $0.20/s；`duration: 1..15`；支持纯文生、1 张首帧 `image`（最高 1080p）、**首尾帧 `last_frame: {"url": "data:..."}`**（480p/720p；Kelivo 内置 Grok 供应商选 `grok-imagine-video-1.5` 可直接开首尾帧并自动下载成片），或 2–14 张 `reference_images: [{"url": "data:..."}]`（480p/720p；**`reference_images` 与 `image` / `last_frame` 互斥**）
  - `#48 Muse 视频`：`muse-video`（$0.10/s，`duration: 1..10`，`resolution: "auto"|"480p"|"720p"`，支持纯文生、1 张首帧 `image`，以及 `POST /v1/videos/edits` 源视频 `video` + `reference_image`/`reference_video` 外观参考编辑）
  - `#56 seedance视频`：`seedance-2.0` ($10/次)、`seedance-2.5` ($12/次) —— **AI 成本守卫：除非用户明确点名并确认高单价，AI 智能体严禁自动选用 Seedance 测试或批量调用！**
