Skip to content

GPT Image 2

client.images.generate(params)
POST/v1/images/generations

Generate images with the provider-compatible OpenAI Images API. This synchronous endpoint returns image data directly.

Request body

Use the native OpenAI Images request shape. The model must be gpt-image-2.

ImageGenerateParams
stringmodelrequired

Use gpt-image-2 on this endpoint.

Default: gpt-image-2

stringpromptrequired

Text description of the image to generate.

Optional<integer>n

Number of images to generate when supported.

Optional<string>size

Output dimensions supported by the model.

Optional<string>quality

Output quality such as low

Optional<string>background

Background setting such as transparent

Optional<string>output_format

Output encoding such as png

Optional<integer>output_compression

Output compression level from 0 to 100.

Optional<string>moderation

Provider-compatible moderation setting.

Optional<string>user

Provider-compatible end-user identifier.

Native protocol notes ​

This model uses the OpenAI Images API contract, not the general SandBase /v1/run model endpoint. Requests are synchronous and return the generated image in data as b64_json or a URL.

Use the shared image generation reference for authentication, response details, limits, and error handling. The SandBase catalog entry is openai/gpt-image-2-official; because this endpoint preserves the OpenAI Images protocol, send the provider model name gpt-image-2 in the request body.

Official OpenAI resources ​