图像生成(Image Generation)

Image Generation

图像生成

POST
/v1/images/generations
AuthorizationBearer <token>

In: header

Header Parameters

Authorization?string
X-Request-Timeout?integer

请求超时时间,单位:秒,默认为60秒

Default60
Range1 <= value <= 120
modelstring

要使用的模型 ID

promptstring

生成图像的文本描述

n?integer

默认为 1,要生成的图像数量。目前暂时只支持1张图像的生成

size?string

默认为 1024x1024,生成图像的尺寸

Value in"1024x1024" | "1024x1792" | "1792x1024" | "1536x1536" | "1536x1152" | "1152x1536"
response_format?string

本站只支持b64_json格式的返回值

Value in"b64_json"
stream?boolean

是否以流式方式返回图像生成结果,默认为 false。

Response Body

curl -X POST "https://api.x-aio.com/v1/images/generations" \  -H "Authorization: string" \  -H "X-Request-Timeout: 60" \  -H "Content-Type: application/json" \  -d '{    "model": "Z-Image-Turbo",    "prompt": "一只可爱的小猫坐在花园里",    "n": 1,    "size": "1024x1024"  }'

{
  "created": 1589478378,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ]
}

"event: image_generation.completed\n\ndata: {\"type\":\"image_generation.completed\",\"b64_json\":\"iVBORw0KGgoAAAANSUhEUgAA...\"}"