API reference · OpenAI

openai/gpt-image-2

Integrate this model through SandBase's unified API, with production-ready schemas and examples.

IMAGEAsyncOpen model
Production endpoint

Send your first request

OpenAI-compatible endpoint with unified authentication and usage tracking.

POSThttps://api.sandbase.ai/v1/run
Model IDopenai/gpt-image-2
01

Input Schema

5 parameters · 1 required · 4 optional

ParameterTypeRequiredDescription
promptstringRequiredThe text prompt to generate an image from. · Min length: 3 · Max length: 50000 · Default: "Generate an image of gray tabby cat hugging an otter with an orange scarf"
qualitystringOptionalQuality for the generated image · Options: low, medium, high · Default: "high"
lowmediumhigh
resolutionstringOptionalThe resolution of the generated image. Leave unset to preserve the provider's standard dimensions. · Options: 1k, 2k, 4k
1k2k4k
aspect_ratiostringOptionalThe aspect ratio of the generated image. · Options: 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"
1:11:22:11:33:12:33:23:44:34:55:49:1616:99:2121:9
output_formatstringOptionalThe format of the generated image. · Options: jpeg, png, webp · Default: "png"
jpegpngwebp
02

Output Schema

FieldTypeDescription
idstringUnique identifier for the generation task
statusstringTask status: pending, running, completed, failed, timeout
modelstringModel used for the generation
outputsarrayArray of output items
outputs[].urlstringURL of the generated artifact
outputs[].content_typestringMIME type (e.g. image/png, video/mp4)
errorobject | nullError details if failed, null on success
error.typestringMachine-readable error type code
error.messagestringHuman-readable error description

Async Workflow

This model uses asynchronous execution. Submit a request and poll for the result.

  1. Submit — POST to /v1/run, receive an id
  2. Poll — GET /v1/run/{id} until status is completed, failed, or timeout
  3. Retrieve — Read outputs from the completed response
03

Code Examples

Ready-to-run snippets

# Step 1: Submit
curl -X POST https://api.sandbase.ai/v1/run \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
  "model": "openai/gpt-image-2",
  "prompt": "Generate an image of gray tabby cat hugging an otter with an orange scarf",
  "quality": "high",
  "aspect_ratio": "1:1",
  "output_format": "png"
}'

# Step 2: Poll result (replace <id>)
curl https://api.sandbase.ai/v1/run/<id> \
  -H "Authorization: Bearer YOUR_API_KEY"