Skip to content

Generate Image

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

Generate images through SandBase's synchronous OpenAI Images-compatible endpoint. This endpoint is distinct from the general /v1/run model API.

Request body

ImageGenerateParams
stringmodelrequired

Use gpt-image-2 on this endpoint.

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, medium, high, or auto.

Optional<string>background

Background setting such as transparent, opaque, or auto.

Optional<string>output_format

Output encoding such as png, webp, or jpeg.

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.

Synchronous only

stream=true, mode=stream, and mode=async are rejected. Use the returned data array directly.

Compatible fields

Additional JSON fields are forwarded unchanged, but support remains model- and provider-specific.

Errors

400

Invalid JSON, unsupported model, streaming mode, or provider request.

401

Missing or invalid API key.

402

Organization or API Key spending limit reached.

403

API key scope does not authorize this endpoint.

404

The routed image model is unavailable.

429

Rate limit exceeded.

500

Request persistence or response processing failed.

502

The provider returned an invalid native response.

503

No provider route succeeded.