GPT Image 2
Model ID openai/gpt-image-2/text-to-image
概览
支持自定义尺寸及三档质量的图像生成模型。
接口
POST /v1/images/generations/async
认证
Authorization: Bearer <AIAPIAIAPI_API_KEY>
请求体
| 参数 | 类型 | 必填 | 可空 | 默认值 | 约束 | 说明 |
|---|---|---|---|---|---|---|
model | string | 是 | 否 | - | values: openai/gpt-image-2/text-to-image | 用于路由请求的模型 ID。 |
prompt | string | 是 | 否 | - | - | 描述目标生成结果的文本提示词。 |
size | string | 否 | 否 | `1024x1024` | - | auto 或 WIDTHxHEIGHT;宽高须为 16 的倍数,宽高比为 1:3 至 3:1,最长边 3840,最多 3840x2160 像素;超过 2560x1440 的分辨率属于实验功能。 |
output_format | string | 否 | 否 | `jpeg` | values: jpeg, png | 输出文件格式。 |
quality | string | 否 | 否 | `medium` | values: low, medium, high | 图像生成质量档位。 |
moderation | string | 否 | 否 | - | values: low | 供应商请求示例中提供的可选审核设置。 |
model
类型:string · 必填:是 · 可空:否
用于路由请求的模型 ID。
prompt
类型:string · 必填:是 · 可空:否
描述目标生成结果的文本提示词。
size
类型:string · 必填:否 · 可空:否
auto 或 WIDTHxHEIGHT;宽高须为 16 的倍数,宽高比为 1:3 至 3:1,最长边 3840,最多 3840x2160 像素;超过 2560x1440 的分辨率属于实验功能。
output_format
类型:string · 必填:否 · 可空:否
输出文件格式。
quality
类型:string · 必填:否 · 可空:否
图像生成质量档位。
moderation
类型:string · 必填:否 · 可空:否
供应商请求示例中提供的可选审核设置。
请求示例
curl --request POST \
--url https://aiapiaiapi.com/v1/images/generations/async \
--header 'Authorization: Bearer $AIAPIAIAPI_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "openai/gpt-image-2/text-to-image",
"prompt": "A cinematic camera movement through a forest"
}'JSON
{
"model": "openai/gpt-image-2/text-to-image",
"prompt": "A cinematic camera movement through a forest"
}响应
{
"code": "success",
"message": "",
"data": { "task_id": "image_01K2ABC123" }
}任务状态
使用创建响应中的 task_id 查询:
GET /v1/images/generations/async/{task_id}
{
"code": "success",
"message": "",
"data": {
"task_id": "image_01K2ABC123",
"status": "SUCCESS",
"progress": "100%",
"outputs": ["https://cdn.example.com/images/image_01K2ABC123.png"],
"start_time": 1786960805,
"finish_time": 1786960900,
"submit_time": 1786960800,
"fail_reason": ""
}
}错误响应
参数校验错误返回 HTTP 400,并包含稳定的错误代码。
{
"code": "unsupported_parameter",
"message": "The parameter is not supported by this model.",
"data": null
}文档索引
获取完整文档索引:
https://aiapiaiapi.com/llms.txt
使用该文件发现所有可用的 API 文档。