典名词元典名词元首页
API 文档
AI 模型接口图像OpenAi

图片生成

POST
/api/v1/image/generation

Header Parameters

Authorization*string

格式: Authorization: Bearer sk-xxxxxx

Request Body

application/json

prompt*string

A text description of the desired image(s). The maximum length is 32000 characters for the GPT image models, 1000 characters for dall-e-2 and 4000 characters for dall-e-3.

n*integer

The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported.

minimum1 maximum10

size*string

optional "auto" or "1024x1024" or "1536x1024" or 5 more The size of the generated images. Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default value) for the GPT image models, one of 256x256, 512x512, or 1024x1024 for dall-e-2, and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.

stream*boolean

Generate the image in streaming mode. Defaults to false. See the Image generation guide for more information. This parameter is only supported for the GPT image models.

background?string

optional "transparent" or "opaque" or "auto" Allows to set transparency for the background of the generated image(s). This parameter is only supported for the GPT image models. Must be one of transparent, opaque or auto (default value). When auto is used, the model will automatically determine the best background for the image.

moderation?string

optional "low" or "auto" Control the content-moderation level for images generated by the GPT image models. Must be either low for less restrictive filtering or auto (default value).

output_compression*integer

The compression level (0-100%) for the generated images. This parameter is only supported for the GPT image models with the webp or jpeg output formats, and defaults to 100.

output_format?string

optional "png" or "jpeg" or "webp" The format in which the generated images are returned. This parameter is only supported for the GPT image models. Must be one of png, jpeg, or webp.

partial_images?string

optional "standard" or "hd" or "low" or 3 more The quality of the image that will be generated.

response_format?string

optional "url" or "b64_json" The format in which generated images with dall-e-2 and dall-e-3 are returned. Must be one of url or b64_json. URLs are only valid for 60 minutes after the image has been generated. This parameter isn't supported for the GPT image models, which always return base64-encoded images.

style?string

optional "vivid" or "natural" The style of the generated images. This parameter is only supported for dall-e-3. Must be one of vivid or natural. Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images.

user?string

A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse.

model*string

模型名称,固定值: gpt-image-1.5

Response Body

application/json

curl -X POST "https://api.aa.com.cn/api/v1/image/generation" \  -H "Authorization: string" \  -H "Content-Type: application/json" \  -d '{    "prompt": "string",    "n": 0,    "size": "string",    "stream": true,    "output_compression": 0,    "model": "string"  }'
{
  "code": 0,
  "data": {
    "urls": [
      "string"
    ],
    "usage": {
      "images": 0,
      "seconds": 0,
      "input_tokens": 0,
      "total_tokens": 0,
      "output_tokens": 0
    },
    "expired": "string",
    "task_id": "string",
    "task_status": "string"
  },
  "message": "string",
  "request_id": "string"
}