Gateway 接口
完整 Gateway API 参考(自动生成)
GET Prometheus 指标
GET /metrics
Prometheus 文本格式指标端点。需开启 METRICS_ENABLED;可选 METRICS_TOKEN 鉴权。 可用平面:gateway;单体 app.main 含 all。
返回示例
200 Response
"string"401 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 指标文本 | string |
| 401 | Unauthorized | 令牌无效 | ErrorDetail |
| 404 | Not Found | 指标未启用 | ErrorDetail |
POST OpenAI 对话补全
POST /v1/chat/completions
OpenAI 兼容 Chat Completions 端点。支持同步与 SSE 流式(stream=true)。按渠道类型自动转换上游协议。 可用平面:gateway;单体 app.main 含 all。
Body 请求参数
{
"model": "gpt-4",
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false,
"temperature": 0.7,
"max_tokens": 1024
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | ChatCompletionRequest | 是 | none |
返回示例
200 Response
{
"id": "string",
"object": "chat.completion",
"created": 0,
"model": "string",
"choices": [
{}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功(非流式返回 OpenAI JSON;流式返回 text/event-stream) | OpenAIChatCompletionResponse |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 200
OpenAI Chat Completions 标准响应
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » id | string | false | none | none | |
| » object | string | false | none | none | |
| » created | integer | false | none | none | |
| » model | string | false | none | none | |
| » choices | [object] | false | none | none | |
| » usage | object | false | none | none | |
| »» prompt_tokens | integer | false | none | none | |
| »» completion_tokens | integer | false | none | none | |
| »» total_tokens | integer | false | none | none |
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
POST Claude Messages API
POST /v1/messages
Anthropic Messages API 兼容端点,按渠道路由并在需要时做协议转换。 可用平面:gateway;单体 app.main 含 all。
Body 请求参数
{
"model": "claude-3-5-sonnet-20241022",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": "Hello!"
}
],
"stream": false
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | ClaudeMessageRequest | 是 | none |
返回示例
200 Response
{}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | Inline |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
返回数据结构
状态码 200
Anthropic Messages 响应或 SSE 流
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
POST Gemini 生成内容
POST /v1beta/models/{model}:generateContent
Google Gemini generateContent 兼容端点。查询参数 stream=true 或请求体 stream 字段可开启流式。 可用平面:gateway;单体 app.main 含 all。
Body 请求参数
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "Hello!"
}
]
}
]
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| model | path | string | 是 | 模型 slug,如 gemini-1.5-pro |
| stream | query | boolean | 否 | 是否流式返回 |
| body | body | GeminiGenerateContentRequest | 是 | none |
返回示例
200 Response
{}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | Inline |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
返回数据结构
状态码 200
Gemini 响应或 SSE 流
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
POST OpenAI Embeddings
POST /v1/embeddings
OpenAI 兼容向量嵌入端点(OpenAI/custom 渠道)。Bearer sk-xxx。
Body 请求参数
{
"model": "text-embedding-3-small",
"input": "The food was delicious."
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | EmbeddingRequest | 是 | none |
返回示例
402 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | None |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 404 | Not Found | 模型不存在 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 404
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
POST OpenAI 图像生成
POST /v1/images/generations
OpenAI 兼容 images/generations(OpenAI/custom 渠道)。
Body 请求参数
{
"model": "dall-e-3",
"prompt": "A cute cat on grass",
"n": 1,
"size": "1024x1024"
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | ImageGenerationRequest | 是 | none |
返回示例
402 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | None |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 404 | Not Found | 模型不存在 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 404
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
POST 异步视频生成(New API 兼容)
POST /v1/video/generations
OpenAI / New API 兼容异步视频任务创建(openai / custom 渠道)。
返回 \{ task_id, status \},使用 GET /v1/video/generations/\{task_id\} 轮询;状态通常为 queued / in_progress / completed / failed。
计费:创建时按 duration(秒,默认 5)预扣;轮询不计费。
Body 请求参数
{
"model": "doubao-seedance-2-0-fast-260128",
"prompt": "一只猫在草地上奔跑",
"duration": 5
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | VideoGenerationRequest | 是 | none |
返回示例
200 Response
{
"task_id": "string",
"status": "queued",
"_gateway": {}
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 任务已创建 | VideoGenerationCreateResponse |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 404 | Not Found | 模型不存在 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » task_id | string | false | none | none | |
| » status | string | false | none | none | |
| » _gateway | object | false | none | 网关附加字段:request_id、cost、latency_ms |
枚举值
| 属性 | 值 |
|---|---|
| status | queued |
| status | in_progress |
| status | completed |
| status | failed |
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 404
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
GET 查询视频生成任务
GET /v1/video/generations/{task_id}
轮询 New API / OpenAI 兼容视频任务状态。可选 query model 用于指定上游渠道路由。
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| task_id | path | string | 是 | 创建接口返回的任务 ID |
| model | query | string | 否 | 可选模型 slug,用于路由到对应渠道 |
返回示例
200 Response
{
"task_id": "string",
"status": "queued",
"video_url": "string",
"error": {}
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 任务状态 | VideoGenerationTaskResponse |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
POST Seedance 2.0 视频任务创建
POST /seedance/api/v3/contents/generations/tasks
字节 Seedance 2.0(豆包)原生视频 API 透传。需配置 type=seedance 渠道。
常用模型:doubao-seedance-2-0-260128、doubao-seedance-2-0-fast-260128。
请求体顶层需包含 model;content 为内容数组(非嵌套在 metadata 内)。duration 为整数 4–15 秒。
成功状态为 succeeded(非 completed),视频 URL 通常在 content.video_url。
Body 请求参数
{
"model": "doubao-seedance-2-0-fast-260128",
"content": [
{
"type": "text",
"text": "一只猫在草地上奔跑"
}
],
"duration": 5,
"ratio": "16:9",
"resolution": "720p"
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | SeedanceVideoTaskRequest | 是 | none |
返回示例
200 Response
{
"id": "string",
"status": "queued",
"content": {
"video_url": "string"
},
"error": {},
"_gateway": {}
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 任务已创建 | SeedanceVideoTaskResponse |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 404 | Not Found | 模型不存在 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » id | string | false | none | 任务 ID | |
| » status | string | false | none | none | |
| » content | object | false | none | none | |
| »» video_url | string | false | none | none | |
| » error | object | false | none | none | |
| » _gateway | object | false | none | 创建响应附加:request_id、cost、latency_ms |
枚举值
| 属性 | 值 |
|---|---|
| status | queued |
| status | running |
| status | succeeded |
| status | failed |
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 404
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
GET 查询 Seedance 视频任务
GET /seedance/api/v3/contents/generations/tasks/{task_id}
轮询 Seedance 2.0 原生任务状态。可选 query model 指定渠道路由。
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| task_id | path | string | 是 | Seedance 任务 ID |
| model | query | string | 否 | 可选模型 slug,用于路由到 seedance 渠道 |
返回示例
200 Response
{
"id": "string",
"status": "queued",
"content": {
"video_url": "string"
},
"error": {},
"_gateway": {}
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 任务状态 | SeedanceVideoTaskResponse |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
POST OpenAI 语音转写
POST /v1/audio/transcriptions
OpenAI 兼容 audio/transcriptions(multipart/form-data)。
Body 请求参数
file: ""
model: ""
language: ""
prompt: ""
response_format: ""
temperature: 0
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | object | 否 | none |
| » file | body | string(binary) | 是 | none |
| » model | body | string | 是 | none |
| » language | body | string | 否 | none |
| » prompt | body | string | 否 | none |
| » response_format | body | string | 否 | none |
| » temperature | body | number(float) | 否 | none |
返回示例
402 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功 | None |
| 402 | Payment Required | 余额不足 | ErrorDetail |
| 403 | Forbidden | 模型未订阅或未授权 | ErrorDetail |
| 404 | Not Found | 模型不存在 | ErrorDetail |
| 429 | Too Many Requests | 配额超限 | Inline |
| 502 | Bad Gateway | 上游错误 | ErrorDetail |
| 503 | Service Unavailable | 上游不可用 | ErrorDetail |
返回数据结构
状态码 402
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 403
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 404
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 502
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
状态码 503
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » detail | any | false | none | 错误详情(字符串或对象) |
