模型列表
返回当前 token 可用的模型集合。GET /v1/models 是单端点三协议:默认 OpenAI 兼容、带 Anthropic 头时返回 Anthropic 原生格式、带 Gemini key 时返回 Gemini 格式。配套的 GET /v1/models/{model_id} 用于按 ID 查询单个模型。
client.models.list() 以及探测单模型的 Gemini SDK 都能开箱即用。
鉴权
/v1/models 路由挂载与 /v1/messages 同一套 token 中间件。接受三种 header 形式;缺失或非法 token 返回 HTTP 401 + buzz_error 响应体。
| Header | 说明 |
|---|---|
Authorization: Bearer <KEY> | 推荐。命中 OpenAI 兼容响应分支。 |
Authorization: Bearer sk-<KEY> | sk- 前缀会在校验前被自动剥离。 |
x-api-key: <KEY> + anthropic-version: 2023-06-01 | 两个 header 同时设置时,命中 Anthropic 原生响应分支。 |
x-goog-api-key: <KEY> 或 ?key=<KEY> | Gemini 风格鉴权。仅在 /v1beta/models、/v1beta/openai/models 与 /v1/models/{id}(带模型 id)三类路径上有效。裸 /v1/models 必须使用 Authorization 或 x-api-key。 |
响应格式选择
BUZZ 检查请求头并派发到以下三个分支之一:
| 触发条件 | 响应格式 |
|---|---|
同时设置 x-api-key 和 anthropic-version | Anthropic 原生(data / first_id / has_more / last_id) |
设置 x-goog-api-key 或 query 中带 ?key=(仅在 /v1beta/models、/v1beta/openai/models 或 /v1/models/{id} 上) | Gemini 分支 |
默认(例如 Authorization: Bearer) | OpenAI 兼容(success / object / data) |
示例 — OpenAI 兼容(默认)
curl https://buzzai.cc/v1/models \
-H "Authorization: Bearer $BUZZ_API_KEY"from openai import OpenAI
client = OpenAI(
base_url="https://buzzai.cc/v1",
api_key="",
)
models = client.models.list()
for m in models.data:
print(m.id) import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://buzzai.cc/v1",
apiKey: process.env.BUZZ_API_KEY,
});
const models = await client.models.list();
for (const m of models.data) {
console.log(m.id);
}响应
{
"success": true,
"object": "list",
"data": [
{
"id": "claude-haiku-4-5-20251001",
"object": "model",
"created": 1626777600,
"owned_by": "anthropic",
"supported_endpoint_types": ["anthropic", "openai"]
},
{
"id": "claude-sonnet-4-6",
"object": "model",
"created": 1626777600,
"owned_by": "anthropic",
"supported_endpoint_types": ["anthropic", "openai"]
}
]
}
注:相对 OpenAI 标准,BUZZ 额外返回 success(顶层)和 supported_endpoint_types(每个模型)。宽松解析器会忽略,严格解析器可安全丢弃。
示例 — Anthropic 原生
同时发送 x-api-key 和 anthropic-version 即可拿到 Anthropic 风格响应 — 这正是 anthropic.Anthropic().models.list() 默认发出的请求。
curl https://buzzai.cc/v1/models \
-H "x-api-key: $BUZZ_API_KEY" \
-H "anthropic-version: 2023-06-01"from anthropic import Anthropic
client = Anthropic(
base_url="https://buzzai.cc",
api_key="",
)
page = client.models.list()
for m in page.data:
print(m.id, m.display_name) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://buzzai.cc",
apiKey: process.env.BUZZ_API_KEY,
});
const page = await client.models.list();
for (const m of page.data) {
console.log(m.id, m.display_name);
}响应
{
"data": [
{
"id": "claude-opus-4-7",
"type": "model",
"display_name": "claude-opus-4-7",
"created_at": "2021-07-20T00:00:00Z"
},
{
"id": "claude-sonnet-4-6",
"type": "model",
"display_name": "claude-sonnet-4-6",
"created_at": "2021-07-20T00:00:00Z"
}
],
"first_id": "claude-opus-4-7",
"has_more": false,
"last_id": "claude-sonnet-4-6"
}
Anthropic 分支与上游的差异
顶层四个 key(data / first_id / has_more / last_id)与 Anthropic 官方一致。每个模型对象做了精简:
| 字段 | BUZZ | Anthropic 上游 |
|---|---|---|
| id | 有 | 有 |
| type | 有(恒为 "model") | 有 |
| display_name | 有 — 直接复用 id | 有 — 人类可读名称 |
| created_at | 有 — 默认值 1626777600(2021-07-20) | 有 — 真实发布时间 |
| capabilities | 不返回 | 返回(batch / citations / thinking / effort) |
| max_input_tokens | 不返回 | 返回 |
| max_tokens | 不返回 | 返回 |
has_more 硬编码为 false,BUZZ 也不识别 after_id / before_id / limit query 参数 — 一次请求拿到 token 可见的全集。如果你需要 max tokens、capability 等更丰富的元数据,请直连 Anthropic 或在客户端硬编码。
示例 — Gemini 格式
当工具链以 Gemini key(x-goog-api-key 或 ?key=)发起请求时,响应使用 Gemini 风格包络。Gemini 风格的模型列表请使用 GET /v1beta/models;查询单个模型请使用 GET /v1/models/{id}。注意:裸 /v1/models 不接受 ?key= 或 x-goog-api-key,会返回 401。
curl "https://buzzai.cc/v1beta/models?key=$BUZZ_API_KEY"
{
"models": [
{"name": "...", "displayName": "...", "...": "..."}
],
"nextPageToken": null
}
常见模型 ID
实际返回的列表是动态的 — 取决于 token 所在 group、token 级模型限制以及 BUZZ 控制台启用的 channel。源码中没有静态全局模型列表。下表是 BUZZ 常见承载的 Claude 模型 ID,只要你的 token 有权限,任意一项都可以提交给 /v1/messages 或 /v1/chat/completions。
| Model ID | 家族 |
|---|---|
| claude-opus-4-7 | Opus 4.7(别名) |
| claude-opus-4-6 | Opus 4.6(别名) |
| claude-opus-4-5-20251101 | Opus 4.5(带日期) |
| claude-sonnet-4-6 | Sonnet 4.6(别名) |
| claude-sonnet-4-5-20250929 | Sonnet 4.5(带日期) |
| claude-haiku-4-5-20251001 | Haiku 4.5(带日期) |
推荐在启动时通过 GET /v1/models 拉取实时列表,不要把模型 ID 写死 — 你账号的 group 与 token 白名单决定了实际可选集合。
查询单个模型
配套路由按 ID 返回单模型元数据。鉴权方式与格式选择规则与列表端点完全一致。
路径参数
| 名称 | 类型 | 说明 |
|---|---|---|
| model_id | string | 模型标识符,如 claude-haiku-4-5-20251001。 |
示例
curl https://buzzai.cc/v1/models/claude-haiku-4-5-20251001 \
-H "Authorization: Bearer $BUZZ_API_KEY"from anthropic import Anthropic
client = Anthropic(
base_url="https://buzzai.cc",
api_key="",
)
model = client.models.retrieve("claude-haiku-4-5-20251001")
print(model.id, model.display_name) import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://buzzai.cc",
apiKey: process.env.BUZZ_API_KEY,
});
const model = await client.models.retrieve("claude-haiku-4-5-20251001");
console.log(model.id, model.display_name);备选列表路径
如果你不想依赖 header 派发,可以使用两条强制响应格式的专用路径:
| 路径 | 固定返回 |
|---|---|
GET /v1beta/openai/models | OpenAI 格式 |
GET /v1beta/models | Gemini 格式 |
以上路径同样使用 TokenAuth 中间件。Authorization: Bearer 与 x-api-key 在所有路径上均可使用。x-goog-api-key 与 ?key= 仅在 /v1beta/models、/v1beta/openai/models 与 /v1/models/{id} 上接受。
错误码
| HTTP | error.type | 典型场景 |
|---|---|---|
| 401 | buzz_error | Token 缺失或非法。响应体:{"error":{"type":"buzz_error","message":"Invalid token (request id: ...)"}} |
| 403 | permission_error | Token 权限不足、IP 不在允许列表 |
| 429 | rate_limit_error | 命中限流,遵守 retry-after |
| 500 | api_error | 内部错误,带退避重试 |
上游 Anthropic 的 DELETE /v1/models/{model_id} 路由在 BUZZ 上显式标记为未实现并返回 not-implemented — 模型生命周期由 BUZZ 管理后台统一管理,不允许通过 token 接口删除。
相关链接
POST /v1/messages— 把模型 ID 提交到 Anthropic 风格端点POST /v1/chat/completions— OpenAI 兼容路径- 鉴权指南
- 错误处理