Skip to content
EN

文生图

方法: POST路径: /v1/images/generations

图片

给定提示和/或输入图像,模型将生成新图像。

相关指南:图像生成

根据提示创建图像。

请求参数

Header 参数

text
Authorization
string
可选
默认值:
Bearer {{YOUR_API_KEY}}

Body 参数 application/json

text
prompt
string
必需
所需图像的文本描述。最大长度为 1000 个字符。
n
integer
可选
要生成的图像数。必须介于 1 和 10 之间。
size
string
可选
生成图像的大小。必须是256x256、512x512或 1024x1024之一。
示例
{
"prompt"
:
"string"
,
"n"
:
0
,
"size"
:
"string"
}

请求示例代码

Shell

bash
curl --location --request POST '/v1/images/generations' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "prompt": "string",
    "n": 0,
    "size": "string"
}'

返回响应

🟢 200 Create image

内容类型: application/json

响应结构

text
created
integer
必需
data
array
[object]
必需
url
string
必需

示例

json
{
    "created": 1589478378,
    "data": [
        {
            "url": "https://..."
        },
        {
            "url": "https://..."
        }
    ]
}