注册

GPT-image-2 创建 - QuickRouter API 中转接口

POST https://api.quickrouter.ai/v1/images/generations 在线调试 →
Authorization

在 Header 添加参数 Authorization,其值为 Bearer 之后拼接 Token

示例: Authorization: Bearer ********************

给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。为提供的提示和参数创建完成。官方文档:https://platform.openai.com/docs/api-reference/images/create

请求参数

Header 参数
Content-Type string
必需
示例: application/json
Accept string
必需
示例: application/json
Authorization string
可选
示例: Bearer {{YOUR_API_KEY}}
Body 参数 application/json
model string
必需
要使用的模型ID。示例: gpt-image-2
prompt string
必需
所需图像的文本描述。最大长度为 1000 个字符。
n integer
必需
要生成的图像数。必须介于 1 和 10 之间。
size string
必需
生成图像的尺寸。支持 1024x1024、1536x1024(横版)、1024x1536(竖版)或 auto(默认值)。
quality string
可选
图片质量。可选值: lowmediumhighauto
format string
可选
返回图片的格式。可选值: pngjpegwebp
示例
{
    "model": "gpt-image-2",
    "prompt": "A childrens book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.",
    "n": 1,
    "size": "1024x1024",
    "quality": "low",
    "format": "jpeg"
}

请求示例代码

curl --location --request POST 'https://api.quickrouter.ai/v1/images/generations' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
    "model": "gpt-image-2",
    "prompt": "A childrens book drawing of a veterinarian using a stethoscope to listen to the heartbeat of a baby otter.",
    "n": 1,
    "size": "1024x1024",
    "quality": "low",
    "format": "jpeg"
}'

返回响应

响应参数 🟢 200 OK · application/json
id string
必需
object string
必需
created integer
必需
choices array [object]
必需
index integer
可选
message object
可选
finish_reason string
可选
usage object
必需
prompt_tokens integer
必需
completion_tokens integer
必需
total_tokens integer
必需
示例
{
    "id": "chatcmpl-123",
    "object": "chat.completion",
    "created": 1677652288,
    "choices": [
        {
            "index": 0,
            "message": {
                "role": "assistant",
                "content": "\n\nHello there, how may I assist you today?"
            },
            "finish_reason": "stop"
        }
    ],
    "usage": {
        "prompt_tokens": 9,
        "completion_tokens": 12,
        "total_tokens": 21
    }
}