模型

生成图像

根据文字描述生成图像。

POST /model/v1/images/generations● 支持

官方文档 ↗

请求体

  • modelstring必填

    Image model id; list candidates with listModels?type=image. Router support (supported): Verified to take effect.

    已验证生效。

  • response_formatstring可选◐ 部分支持

    Image response encoding. Only b64_json is accepted; url returns 400.

    gpt-image-2 支持 b64_json;url 返回 400。

    取值 b64_json
  • promptstring必填

    Text description of the image to generate. Router support (supported): Verified to take effect.

    已验证生效。

  • ninteger可选
    默认 1

    Number of images to generate, from 1 to 10; defaults to 1. Router support (supported): Controls image count; zero returns 400 and values 1–10 are accepted.

    控制图片数量,0 返回 400,允许 1–10。

  • sizestring可选◐ 部分支持

    Size of the generated images. Router support (partial): gpt-image-2 supports tested 1024x1024 and 1024x1536 sizes; 512x512 returns 400.

    gpt-image-2 已验证 1024x1024、1024x1536;512x512 返回 400。

    取值 1024x10241024x15361536x1024auto
  • qualitystring可选

    Quality of the generated images. Router support (supported): Verified to take effect.

    已验证生效。

    取值 lowmediumhighauto
  • backgroundstring可选

    gpt-image-2 的 transparent 返回透明 PNG。

  • output_formatstring可选

    gpt-image-2 的 jpeg 返回 JPEG。

返回

200

鉴权、限流、参数校验等平台错误按 problem+json 返回;OCR 的错误也为 problem+json,其它模型调用的错误按该端点所属格式(OpenAI 或 Anthropic)返回,参见 错误码

响应

HTTP 200

Image generation response

application/json

名称类型说明
createdintegerUnix time in seconds at which the images were created.
dataarray<object>Generated images.
data[].urlstringURL of the image; present when response_format is `url`.
data[].b64_jsonstringBase64-encoded image; present when response_format is `b64_json`.
data[].revised_promptstringPrompt after the image model rewrote it, when the model reports it.