OpenAI Async Image API
A single unified endpoint for both text-to-image generation and image editing. The operation type is auto-detected based on whether you provide an image field in the request body.
Supported Model
Model Description gpt-image-2Latest OpenAI image model
How It Works
Create a task
Call POST /openai/images with your prompt. The endpoint auto-detects the operation:
No image field → text-to-image generation
With image field → image editing
With image + mask → inpainting (transparent mask areas are repainted)
Returns { "taskId": "..." }.
Poll for results
Call GET /openai/tasks?taskId=<taskId> until status is completed or failed.
Use the result
The task result field contains the generated image (base64 encoded by default for gpt-image-2).
Quick Examples
Text-to-Image
Image Edit (URL)
Image Edit (base64)
Inpainting (with mask)
Poll Task Status
curl -X POST "https://api.mountsea.ai/openai/images" \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A photorealistic cat wearing a space helmet, floating in orbit",
"model": "gpt-image-2",
"size": "1024x1024",
"quality": "high"
}'
Parameters
Field Type Required Description promptstring ✅ Prompt describing the desired image (for editing: describe the modification) modelstring — Defaults to gpt-image-2 sizeenum — auto, 1024x1024 (default), 1024x1536, 1536x1024nnumber — Generation count (currently only 1 supported) qualityenum — auto, low, medium, high, standardbackgroundenum — transparent, opaque, autooutput_formatenum — png / jpeg / webpoutput_compressionnumber — JPEG/WebP compression 0-100 moderationenum — auto, lowresponse_formatenum — url or b64_json (gpt-image-2 always returns b64_json)input_fidelityenum — high or low — only for edit; controls how closely the output follows the inputimagestring / string[] — URL or base64 data URL. Presence triggers editing mode. Single or multiple images maskstring — Mask image (URL or base64). Transparent areas will be repainted. Edit-only
Task Status
Status Meaning pendingTask created, awaiting processing readyReady for assignment assignedAssigned to a worker processingActively generating completedDone — result contains the image failedFailed — see errorMessage / errorCode cancelledCancelled by user or system timeoutExceeded processing timeout
Poll every 2-5 seconds . Tasks typically complete in 10-60 seconds depending on quality and size.
Available Endpoints
Endpoint Method Description /openai/imagesPOST Create image task (generate or edit) /openai/tasksGET Get task status / result by taskId
Explore the API Documentation
Looking for the synchronous OpenAI-compatible API? See OpenAI Compat to use the official openai SDK.