Skip to content

GPT Image 2

POST/v1/run

GPT Image 2, OpenAI's available image model, is capable of making fine-grained, detailed edits to images.

Request body

Submit an async generation request. The model field selects the model; other fields are model-specific input parameters.

stringmodelrequired

Model identifier. Set to openai/gpt-image-2.

Default: openai/gpt-image-2

stringpromptrequired

The text prompt to generate an image from.

Default: Generate an image of gray tabby cat hugging an otter with an orange scarf

Optional<string>quality

Quality for the generated image

Allowed values: low, medium, high

Default: high

Optional<string>resolution

The resolution of the generated image. Leave unset to preserve the provider's standard dimensions.

Allowed values: 1k, 2k, 4k

Optional<string>aspect_ratio

The aspect ratio of the generated image.

Allowed values: 1:1, 1:2, 2:1, 1:3, 3:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 9:21, 21:9

Default: 1:1

Optional<string>output_format

The format of the generated image.

Allowed values: jpeg, png, webp

Default: png

Response Schema

The submit endpoint returns a run response. If its status is pending or running, poll GET /v1/run/{id} with the returned opaque ID until it reaches a terminal state.

stringidrequired

Opaque SandBase run identifier. Use it exactly as returned; no prefix is guaranteed.

stringstatusrequired

Current public run status.

Allowed values: pending, running, completed, failed, timeout

Optional<string>model

Public SandBase model name used for this run.

Optional<array<object>>outputs

Present only for completed runs. Each object is capability-specific; inspect the selected model schema for its fields.

Optional<object>error

Present only for failed or timeout runs. Contains a public error type and sanitized message.

Optional<string>error.type

Stable public error category.

Optional<string>error.message

Sanitized error message safe to show to clients.

Optional<object>usage

Usage details when available.

Model capabilities

array<string>capability_tagsrequired

Capabilities declared by the model registry.

Default: text-to-image, commercial

stringexecution_moderequired

Execution mode declared by the model registry.

Default: async