默认模块
Base URL:https://cobabaai.com(全球节点)
认证:请求头 Authorization: Bearer <令牌>。请到 令牌管理 获取 API Key。
WARNING
请勿将 API Key 写入前端代码或公开仓库。
cobabaai图片/视频生成接口
POST gpt-image-2接口
POST /v1/api/generate
例子:https://cobabaai.com/v1/api/generate
Body 请求参数
{
"model": "gpt-image-2",
"prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
"images": [],
"aspectRatio": "1024x1024",
"replyType": "json"
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| Authorization | header | string | 是 | 请前往 令牌管理 获取 API Key | |
| body | body | object | 是 | ||
| » model | body | string | 是 | 模型名称 | 支持以下模型 |
| » prompt | body | string | 是 | 提示词 | |
| » images | body | [string] | 否 | 参考图 | 支持 base64 与 url 链接 |
| » aspectRatio | body | string | 否 | 比例 | 分辨率参数说明 |
| » replyType | body | string | 否 | 回复类型 | 仅 json 或 async,不支持 stream |
详细说明
» model:支持以下模型
gpt-image-2gpt-image-2-vip
» aspectRatio:分辨率参数说明
gpt-image-2:支持比例(如"16:9")或 1K 像素值(如"1024x1024")gpt-image-2-vip:支持 1–4K 像素值(如"1024x1024"、"2048x2048"),不支持比例
自定义像素值约束(仅限 vip 模型):
- 最大边长必须小于或等于 3840px
- 两条边都必须是 16 的倍数
- 长边与短边之比不得超过 3:1
- 总像素数必须至少为 655360 且不得超过 8294400
gpt-image-2-vip 比例参考(1K、2K、4K)
| 比例 | 像素 |
|---|---|
| auto | |
| 1:1 | 1024x1024、2048x2048、2880x2880 |
| 16:9 | 1280x720、2048x1152、3840x2160 |
| 9:16 | 720x1280、1152x2048、2160x3840 |
| 4:3 | 1152x864、2304x1728、3264x2448 |
| 3:4 | 864x1152、1728x2304、2448x3264 |
| 3:2 | 1536x1024、2048x1360、3504x2336 |
| 2:3 | 1024x1536、1360x2048、2336x3504 |
| 5:4 | 1120x896、2240x1792、3200x2560 |
| 4:5 | 896x1120、1792x2240、2560x3200 |
| 21:9 | 1456x624、2912x1248、3840x1648 |
| 9:21 | 624x1456、1248x2912、1648x3840 |
| 1:3 | 688x2048、1280x3840 |
| 3:1 | 2048x688、3840x1280 |
| 2:1 | 1536x768、3072x1536、3840x1920 |
| 1:2 | 768x1536、1536x3072、1920x3840 |
gpt-image-2 比例参考
| 比例 | 像素 |
|---|---|
| auto | |
| 1:1 | 1024x1024 |
| 16:9 | 1672x941 |
| 9:16 | 941x1672 |
| 4:3 | 1443x1090 |
| 3:4 | 1090x1443 |
| 3:2 | 1536x1024 |
| 2:3 | 1024x1536 |
| 5:4 | 1408x1120 |
| 4:5 | 1120x1408 |
| 21:9 | 1920x832 |
| 9:21 | 832x1920 |
| 1:2 | 896x1792 |
| 2:1 | 1792x896 |
» replyType:仅支持以下两个值
json:本条 HTTP 等到出图结束(或失败)再返回完整结果async:立刻返回任务 id,再用 GET /v1/api/result 查询
不支持 stream。传入会 HTTP 400,body 为网关错误(不是出图任务的 {id,status,error}):
{
"code": "invalid_request",
"message": "replyType stream is not supported; use json or async",
"data": null
}返回示例
replyType=json 出图成功(HTTP 200)
{
"id": "14-5f3cf761-a4bb-486a-8016-77f490998f80",
"status": "succeeded",
"progress": 100,
"results": [
{
"url": "https://file1.aitohumanize.com/file/fcdd2d07449d438d9d69d450f5626976.png"
}
]
}replyType=async 提交成功(HTTP 200)
提交成功时通常只有任务 id 和进行中状态,没有 progress / results。进度和图地址在查询接口返回。
{
"id": "task_xxxx",
"status": "running"
}出图任务失败 / 违规(HTTP 400)
json 模式结束时,或查询接口发现失败时:
{
"id": "12-1f771fbf-f23a-4b89-a7d0-a98ba9862edb",
"status": "failed",
"error": "generate failed"
}返回结果
| 状态码 | 说明 |
|---|---|
| 200 | json 成功,或 async 已受理(status=running) |
| 400 | 出图任务 failed / violation;或参数错误(如 replyType=stream) |
返回数据结构
json 完成时,或查询接口最终结果(HTTP 200 / 400)
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 任务 id | |
| status | string | 是 | 状态 | running(进行中)、violation(违规)、succeeded(生成成功)、failed(任务失败) |
| progress | integer | 否 | 进度 | 0~100;异步提交当时通常没有,查询时才有 |
| results | [object] | 否 | succeeded 时才有 | |
| » url | string | 否 | 图片/视频链接 | |
| error | string | 否 | 报错信息 | failed / violation 时必有 |
async 提交成功(HTTP 200)
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 任务 id | 后续查询必须用这个值 |
| status | string | 是 | 状态 | 一般为 running |
参数错误(如 stream,HTTP 400)
| 名称 | 类型 | 必选 | 说明 |
|---|---|---|---|
| code | string | 是 | 如 invalid_request |
| message | string | 是 | 错误说明 |
| data | any | 否 | 常为 null |
GET 异步生成结果查询接口
GET /v1/api/result
例子:https://cobabaai.com/v1/api/result?id=<任务id>
请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| id | query | string | 是 | 任务 id | 提交接口返回的 id |
| Authorization | header | string | 是 | 请前往 令牌管理 获取 API Key |
也支持 POST /v1/api/result,body:{"id":"<任务id>"}。查询不重复扣费。
返回示例
轮询时 status=running 会带上进度,成功后再给 results。
进行中(HTTP 200)
{
"id": "task_xxxx",
"status": "running",
"progress": 20
}成功(HTTP 200)
{
"id": "14-5f3cf761-a4bb-486a-8016-77f490998f80",
"status": "succeeded",
"progress": 100,
"results": [
{
"url": "https://file1.aitohumanize.com/file/fcdd2d07449d438d9d69d450f5626976.png"
}
]
}失败(HTTP 400)
{
"id": "12-1f771fbf-f23a-4b89-a7d0-a98ba9862edb",
"status": "failed",
"error": "generate failed"
}返回数据结构
查询接口才会稳定返回 progress / results / error(按状态):
| 名称 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|
| id | string | 是 | 任务 id | 与提交时相同 |
| status | string | 是 | 状态 | running / succeeded / failed / violation |
| progress | integer | 否 | 进度 | 0~100,running 时常见 |
| results | [object] | 否 | succeeded 时才有 | |
| » url | string | 否 | 图片/视频链接 | |
| error | string | 否 | 报错信息 | failed / violation 时必有,HTTP 400 |
openai-completions接口
POST /v1/chat/completions
例子:https://cobabaai.com/v1/chat/completions
Body 请求参数
文本:
{
"model": "gemini-3.1-pro",
"stream": false,
"messages": [
{
"role": "user",
"content": "你好"
}
]
}图文:
{
"model": "gemini-3.1-pro",
"stream": false,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "这张图片内容是什么"
},
{
"type": "image_url",
"image_url": {
"url": "https://xxxxxxx.png"
}
}
]
}
]
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| Authorization | header | string | 是 | 请前往 令牌管理 获取 API Key | |
| body | body | object | 是 | ||
| » model | body | string | 是 | 模型名称 | 支持所有对话模型 |
| » stream | body | boolean | 是 | stream 流 | |
| » messages | body | [object] | 是 | ||
| »» role | body | string | 否 | user | |
| »» content | body | string / array | 否 | 提示词内容 | 可为字符串,或图文数组 |
返回示例
200 Response
{
"id": "1-2ede12b5-77cc-48f9-b1d0-7ae35ee8d444",
"object": "",
"created": 1777897048,
"model": "gemini-3.1-pro",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!请问有什么我可以帮您的吗?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 2,
"completion_tokens": 261,
"total_tokens": 263,
"prompt_tokens_details": null,
"completion_tokens_details": null
},
"system_fingerprint": ""
}400 Response
{
"error": {
"message": "generation failed"
}
}返回数据结构
状态码 200
| 名称 | 类型 | 必选 | 说明 |
|---|---|---|---|
| id | string | 是 | |
| object | string | 是 | |
| created | integer | 是 | |
| model | string | 是 | |
| choices | [object] | 是 | |
| » index | integer | 否 | |
| » message | object | 否 | |
| »» role | string | 是 | |
| »» content | string | 是 | |
| » finish_reason | string | 否 | |
| usage | object | 是 | |
| » prompt_tokens | integer | 是 | |
| » completion_tokens | integer | 是 | |
| » total_tokens | integer | 是 | |
| system_fingerprint | string | 是 |
状态码 400
| 名称 | 类型 | 必选 | 中文名 |
|---|---|---|---|
| error | object | 是 | |
| » message | string | 是 | 报错信息 |
openai-generations接口
POST /v1/images/generations
例子:https://cobabaai.com/v1/images/generations
Body 请求参数
{
"model": "gpt-image-2",
"prompt": "生成一张边牧与古牧正在抖音直播间直播带货截图",
"image": [],
"size": "1024x1024",
"response_format": "url"
}请求参数
| 名称 | 位置 | 类型 | 必选 | 中文名 | 说明 |
|---|---|---|---|---|---|
| Authorization | header | string | 是 | 请前往 令牌管理 获取 API Key | |
| body | body | object | 是 | ||
| » model | body | string | 是 | 模型名称 | 支持所有图片生成模型 |
| » prompt | body | string | 是 | 提示词 | |
| » image | body | [string] | 否 | 参考图 | 支持 base64 与 url 链接 |
| » size | body | string | 否 | 比例 | gpt-image-2 系列模型分辨率参数说明 |
| » response_format | body | string | 否 |
详细说明
» size:gpt-image-2 系列模型分辨率参数说明,规则与上文 aspectRatio 相同。
gpt-image-2:支持比例(如"16:9")或 1K 像素值(如"1024x1024")gpt-image-2-vip:支持 1–4K 像素值,不支持比例;自定义像素约束同上
比例参考表见 POST gpt-image-2接口。
返回示例
200 Response
{
"created": 1777689832,
"data": [
{
"url": "https://file4.aitohumanize.com/file/dfa13fe60e7649e88f46037b968b54a3.png"
}
],
"usage": {
"total_tokens": 6267,
"input_tokens": 17,
"output_tokens": 6250,
"input_tokens_details": {}
}
}400 Response
{
"error": {
"message": "generation failed"
}
}返回数据结构
状态码 200
| 名称 | 类型 | 必选 |
|---|---|---|
| created | integer | 是 |
| data | [object] | 是 |
| » url | string | 否 |
| usage | object | 是 |
| » total_tokens | integer | 是 |
| » input_tokens | integer | 是 |
| » output_tokens | integer | 是 |
| » input_tokens_details | object | 是 |
状态码 400
| 名称 | 类型 | 必选 | 中文名 |
|---|---|---|---|
| error | object | 是 | |
| » message | string | 是 | 报错信息 |