OpenAI

Create an image

Generate an image from a text prompt.

POST /openai/v1/images/generations● Supported

Official OpenAI docs ↗

Request body

  • modelstring必填

    Verified to take effect.

  • response_formatstring可选○ Unsupported

    Omit for GPT Image models, which return native base64 data. Only send for models that explicitly support response_format; platform hosting is a separate Image extension.

    gpt-image-2 returns 400 for both b64_json and url; omit this field.

    取值 urlb64_json
  • promptstring必填

    Verified to take effect.

  • ninteger可选
    默认 1

    Controls image count; zero returns 400 and values 1–10 are accepted.

  • sizestring可选◐ Partially supported

    gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.

    取值 1024x10241024x15361536x1024auto
  • qualitystring可选

    Verified to take effect.

    取值 lowmediumhighauto
  • backgroundstring可选

    transparent returns a transparent PNG on gpt-image-2.

  • output_formatstring可选

    jpeg returns JPEG on gpt-image-2.

Returns

200

Errors follow the OpenAI format — see error codes

Response

HTTP 200

Image generation response

application/json

NameTypeDescription
createdinteger
dataarray<object>
data[].urlstring
data[].b64_jsonstring
data[].revised_promptstring