curl --request POST \
--url https://api.poyo.ai/api/generate/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "A premium product photo of a silver espresso machine on a clean white studio background, realistic lighting, high detail",
"quality": "low",
"size": "1:1"
}
}
'
{
"code": 200,
"data": {
"task_id": "task-unified-1757165031-uyujaw3d",
"status": "not_started",
"created_time": "2026-04-19T21:19:42"
}
}{
"code": 400,
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"code": 401,
"error": {
"message": "Unauthorized - Invalid API key",
"type": "authentication_error"
}
}OpenAI
GPT Image 2
GPT Image 2 API 根据文本生成一张图像,或编辑一张或多张参考图。分辨率范围为 1K 到 4K,自定义尺寸的边长最高 3840 像素。
POST
/
api
/
generate
/
submit
curl --request POST \
--url https://api.poyo.ai/api/generate/submit \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "gpt-image-2",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "A premium product photo of a silver espresso machine on a clean white studio background, realistic lighting, high detail",
"quality": "low",
"size": "1:1"
}
}
'
{
"code": 200,
"data": {
"task_id": "task-unified-1757165031-uyujaw3d",
"status": "not_started",
"created_time": "2026-04-19T21:19:42"
}
}{
"code": 400,
"error": {
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"code": 401,
"error": {
"message": "Unauthorized - Invalid API key",
"type": "authentication_error"
}
}- 提交后会返回
task_id。如果提供了callback_url,当任务状态变为finished或failed时,系统会向callback_url发送 POST 请求。 - 无论是否提供
callback_url,都可以通过统一的查询任务状态接口获取结果。
模型
- gpt-image-2 - 文生图,可选以参考图引导生成
- gpt-image-2-edit - 基于一张或多张参考图和文本指令进行图像编辑
分辨率
resolution 参数控制输出图像的分辨率。
| 分辨率 | 说明 |
|---|---|
1K(默认) | 标准分辨率 |
2K | 高分辨率 |
4K | 超高分辨率(仅限真正的 4K 尺寸) |
分辨率规则
size设为auto或未传size参数时,无论resolution取何值,始终使用 1K 分辨率。- 自定义尺寸(
WIDTHxHEIGHT)要求resolution为2K或4K。 4K适用于16:9、9:16、21:9,或边长为 3840 像素的自定义尺寸。其他 4K 选择会自动降为 2K。
自定义尺寸限制
自定义尺寸使用WIDTHxHEIGHT 格式(例如 2304x1536),且必须满足以下要求:
- 两个维度都必须能被 16 整除
- 最大边长:3840 像素
- 宽高比:最高 3:1
- 总像素数:655,360 到 8,294,400 之间
示例
生成图像
{
"model": "gpt-image-2",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "A premium product photo of a silver espresso machine on a clean white studio background",
"quality": "low",
"size": "1:1",
"resolution": "1K"
}
}
编辑图像
{
"model": "gpt-image-2-edit",
"callback_url": "https://your-domain.com/callback",
"input": {
"prompt": "Replace the background with a clean white studio backdrop and add a soft natural shadow",
"image_urls": ["https://example.com/product.jpg"],
"quality": "high",
"size": "1:1"
}
}
注意事项
gpt-image-2-edit必须提供image_urls。image_urls支持上传多张参考图。prompt最多支持 20,000 个字符。- 每次请求返回一张图像。
quality控制输出图像质量。可选值:low、medium、high。默认:low。- 支持的
size值:auto、1:1、2:3、3:2、4:3、3:4、4:5、5:4、16:9、9:16、21:9,或自定义WIDTHxHEIGHT。
授权
所有 API 接口都需要 Bearer Token 认证。
创建 API Key:登录 PoYo,进入 仪表盘 → API 密钥(poyo.ai/zh/dashboard/api-key),点击创建 Key。
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求体
application/json
响应
任务提交成功
Show child attributes
Show child attributes