Skip to content

OpenAI Images compatible ​

OpenAI Images compatible portals are used to call image models such as gpt-image-*, doubao-seedream-*, grok-imagine-* through /v1/images/*. Actual models, sizes and quantities are based on MoonNexAI console, price pages and GET /v1/models.

Picture generation and image editing are requested using /v1/images/generations, /v1/images/edits or the asynchronous entry. /v1/chat/completions is not a recommended photo generation entry for GPT Image series. It is not recommended that gpt-image-* be placed in chat completion request to generate pictures.

Overview of capacities ​

CapacityPathInputResult
Picture Generation/v1/images/generationsJSON promptsynchronous returns the photo result.
Picture asynchronous Generation/v1/images/generations/asyncJSON promptReturns task ID first, then query task results.
Picture Editor/v1/images/editsMultipart Photo Files and Promptsynchronous returns the edit result.
Photo asynchronous Edit/v1/images/edits/asyncJSON Picture URL or Base64 and PromptReturns task ID first, then query task results.
Picture variant/v1/images/variationsMultipart Photo Filereturns a similar version when the model supports.

Synchronous APIs keep the connection open until generation or editing finishes. Use asynchronous image APIs to avoid long connections, gateway timeouts or client disconnections. Save the returned id, query GET /v1/images/tasks/{task_id}, and read data[].url only after success.

If your business system is connected to both chat and picture capabilities, it is recommended to configure chat and image models separately: chat walk /v1/chat/completions, GPT Image Generation /v1/images/generations, Picture Editor /v1/images/edits.

Picture Generation ​

http
POST /v1/images/generations
bash
curl https://moonnexai.com/v1/images/generations \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A clean product mockup on a white studio table.",
    "size": "1024x1024",
    "n": 1
  }'

Picture asynchronous Generation ​

http
POST /v1/images/generations/async
bash
curl https://moonnexai.com/v1/images/generations/async \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A clean product mockup on a white studio table.",
    "size": "1024x1024",
    "n": 1
  }'

response will contain task ID after successful submission:

json
{
  "id": "task_xxx",
  "object": "image.generation",
  "status": "queued",
  "progress": 3,
  "model": "gpt-image-2"
}

Query task:

bash
curl https://moonnexai.com/v1/images/tasks/task_xxx \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>"

task:

json
{
  "id": "task_xxx",
  "object": "image.generation",
  "status": "succeeded",
  "progress": 100,
  "model": "gpt-image-2",
  "data": [
    {
      "url": "https://media-nex.windfimusic.com/image/example.png"
    }
  ]
}

Picture Editor ​

http
POST /v1/images/edits
bash
curl https://moonnexai.com/v1/images/edits \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -F "image=@./product.png" \
  -F "model=gpt-image-2-pro" \
  -F "prompt=Change the background to a clean studio scene." \
  -F "size=1024x1024"

Photo asynchronous Edit ​

http
POST /v1/images/edits/async

Photo asynchronous edits are suitable for submitting task using the URL or Base64 image content that is accessible. The editing scene for local files needs to be uploaded and continued with synchronous /v1/images/edits.

bash
curl https://moonnexai.com/v1/images/edits/async \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2-pro",
    "prompt": "Change the background to a clean studio scene.",
    "image": "https://example.com/product.png",
    "size": "1024x1024"
  }'

Picture variant ​

http
POST /v1/images/variations
bash
curl https://moonnexai.com/v1/images/variations \
  -H "Authorization: Bearer <MOONNEXAI_API_KEY>" \
  -F "image=@./product.png" \
  -F "model=gpt-image-2" \
  -F "n=2"

Common field ​

fieldPurpose
modelPicture model name.
promptPicture generation or edit description.
imageUploads a photo file.
sizeOutput size, e.g. 1024x1024.
nGenerates the quantity.

asynchronous tasks Status ​

StatusMeaning
queued / submittedSubmitted, pending processing.
runningGenerating.
succeededSuccessfully read data[].url.
failedFailed to read error.message.

The asynchronous picture task returns URL, does not return the image Base64 text. If the result is a picture content, MoonNexAI will be converted to a URL to accessable picture and then write task results.

Use recommendations ​

  • Prompt recommends to include the subject, image style, use and size.
  • Make sure the picture is clear before uploading it, and the subject is not covered.
  • Keep request parameters and return results on batch generation to facilitate follow-up.
  • Synchronous APIs suit short requests. Asynchronous APIs suit long image tasks, background jobs and applications sensitive to connection stability.
  • Ideogram Image can be evaluated if posters are required to be typed or texted.
  • For highly stylized asynchronous generation, consider Midjourney tasks.

Relevant Pages ​