Unode
User GuideAPI ReferenceHelp & SupportBusiness Cooperation

Generate Images

Creates images from a text prompt. Use response_format to request temporary image URLs or Base64 data.

POST
/v1/images/generations
AuthorizationBearer <token>

In: header

Request Body

application/json

model*string

用于图像生成的模型,例如 gpt-image-1、gpt-image-1.5 或 gpt-image-2。

prompt*string

所需图像的文本描述。

n?integer

要生成的图像数量。

Default1
Range1 <= value <= 10
size?string

生成图像的尺寸,例如 1024x1024、1536x1024、1024x1536 或 auto。

quality?string

生成图像的质量,例如 high、medium、low 或 auto。

background?string

生成图像的背景设置。

Value in"transparent" | "opaque" | "auto"
output_format?string

生成图像的文件格式。

Value in"png" | "jpeg" | "webp"
output_compression?integer

JPEG 或 WebP 输出的压缩级别。

Range0 <= value <= 100
moderation?string

内容审核级别。

Value in"low" | "auto"
response_format?string

响应图像格式。url 请求图像 URL,仅适用于非流式完整 JSON 响应;原生 URL 会直接返回,Base64-only 模型会在 URL 交付已启用时返回临时签名 URL。b64_json 返回 Base64 数据。不传时保留模型或上游渠道的默认行为。

Value in"url" | "b64_json"
user?string

代表最终用户的唯一标识符。

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://loading/v1/images/generations" \  -H "Content-Type: application/json" \  -d '{    "model": "gpt-image-2",    "prompt": "A watercolor painting of a mountain lake at sunrise",    "n": 1,    "size": "1024x1024",    "response_format": "url"  }'
{
  "created": 0,
  "data": [
    {
      "url": "http://example.com",
      "b64_json": "string",
      "revised_prompt": "string"
    }
  ],
  "usage": {}
}
{
  "error": {
    "message": "string",
    "type": "string",
    "code": "string"
  }
}
{
  "error": {
    "message": "string",
    "type": "image_delivery_error",
    "code": "image_url_delivery_failed"
  }
}
{
  "error": {
    "message": "string",
    "type": "image_delivery_error",
    "code": "image_url_delivery_unavailable"
  }
}

Last updated on