Gateway 接口
对话补全、图像生成、Gemini 多模态与 Seedance 视频 Gateway API 参考(自动生成)
生产环境 Base URL:
https://api.hubridge.net当前开放接口:对话补全(
POST /v1/chat/completions)、图像生成(POST /v1/images/generations)、图像编辑(POST /v1/images/edits)、Gemini 多模态(POST /v1beta/models/{model}:generateContent)、Seedance 2.0 视频生成(POST /seedance/api/v3/contents/generations/tasks、GET /seedance/api/v3/contents/generations/tasks/{task_id})。
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 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 图像生成
POST /v1/images/generations
OpenAI 兼容 images/generations(OpenAI/custom 渠道)。常用模型如 gpt-image-2。
Body 请求参数
{
"model": "gpt-image-2",
"prompt": "A cute cat sitting on a windowsill, watercolor style",
"n": 1,
"size": "1024x1024"
}请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | ImageGenerationRequest | 是 | none |
返回示例
200 Response
{
"created": 1710000000,
"data": [
{
"url": "https://example.com/image.png",
"revised_prompt": "A cute cat sitting on a windowsill, watercolor style"
}
]
}402 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功,返回 OpenAI 格式 images 响应 | Inline |
| 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
| 名称 | 类型 | 必选 | 约束 | 中文名 | 说明 |
|---|---|---|---|---|---|
| » created | integer | false | none | Unix 时间戳 | |
| » data | [object] | false | none | 生成结果列表 | |
| »» url | string | false | none | 图片 URL(response_format=url 时) | |
| »» b64_json | string | false | none | Base64 图片(response_format=b64_json 时) | |
| »» revised_prompt | string | false | none | 模型改写后的提示词 |
状态码 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/edits
OpenAI 兼容 images/edits(multipart/form-data)。基于参考图与提示词生成编辑结果;可选 mask 指定编辑区域。
Body 请求参数
model: gpt-image-2
prompt: Add a red scarf to the cat
image: ""
n: 1
size: 1024x1024
mask: ""
请求参数
| 名称 | 位置 | 类型 | 必选 | 说明 |
|---|---|---|---|---|
| body | body | ImageEditRequest | 是 | multipart/form-data |
| » model | body | string | 是 | 图像模型 slug |
| » prompt | body | string | 是 | 编辑描述提示词 |
| » image | body | string(binary) | 是 | 参考图片文件(PNG,小于 4MB) |
| » n | body | integer | 否 | 生成张数,默认 1 |
| » size | body | string | 否 | 输出尺寸,如 1024x1024 |
| » mask | body | string(binary) | 否 | 可选蒙版(PNG,透明区域为编辑范围) |
返回示例
200 Response
{
"created": 1710000000,
"data": [
{
"url": "https://example.com/edited.png"
}
]
}402 Response
{
"detail": null
}返回结果
| 状态码 | 状态码含义 | 说明 | 数据模型 |
|---|---|---|---|
| 200 | OK | 成功,返回 OpenAI 格式 images 响应 | Inline |
| 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 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 |
