Skip to content

创建 gpt-image-1.5

POST https://az.gptplus5.com/v1/images/generations

给定一个提示,该模型将返回一个或多个预测的完成,并且还可以返回每个位置的替代标记的概率。

为提供的提示和参数创建完成

官方文档:https://platform.openai.com/docs/api-reference/images/create

请求参数

Header 参数

参数名类型必需说明示例
Content-Typestring必需application/json
Acceptstring必需application/json
Authorizationstring可选Bearer {{YOUR_API_KEY}}

Body 参数 (application/json)

参数名类型必需说明
promptstring必需所需图像的文本描述。最大长度为 1000 个字符。
ninteger必需要生成的图像数。必须介于 1 和 10 之间。
sizestring必需生成图像的尺寸。对于 GPT 图像模型,必须是 1024x1024 、 1536x1024 (横版)、 1024x1536 (竖版)或 auto (默认值)之一,对于 dall-e-2 必须是 256x256 、 512x512 或 1024x1024 之一,对于 dall-e-3 必须是 1024x1024 、 1792x1024 或 1024x1792 之一。

请求示例

json
{
    "size": "1024x1536",
    "prompt": "a man walks",
    "model": "gpt-image-1.5",
    "n": 1
}

cURL 示例

bash
curl --location --request POST 'https://az.gptplus5.com/v1/images/generations' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
    "size": "1024x1536",
    "prompt": "a man walks",
    "model": "gpt-image-1.5",
    "n": 1
}'

返回响应

🟢200OK

响应 Body

参数名类型必需说明
idstring必需
objectstring必需
createdinteger必需
choicesarray[object]必需
  └ indexinteger可选
  └ messageobject可选
  └ finish_reasonstring可选
usageobject必需
  └ prompt_tokensinteger必需
  └ completion_tokensinteger必需
  └ total_tokensinteger必需

响应示例

json
{
    "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
    }
}