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
| Capacity | Path | Input | Result |
|---|---|---|---|
| Picture Generation | /v1/images/generations | JSON prompt | synchronous returns the photo result. |
| Picture asynchronous Generation | /v1/images/generations/async | JSON prompt | Returns task ID first, then query task results. |
| Picture Editor | /v1/images/edits | Multipart Photo Files and Prompt | synchronous returns the edit result. |
| Photo asynchronous Edit | /v1/images/edits/async | JSON Picture URL or Base64 and Prompt | Returns task ID first, then query task results. |
| Picture variant | /v1/images/variations | Multipart Photo File | returns 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
POST /v1/images/generationscurl 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
POST /v1/images/generations/asynccurl 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:
{
"id": "task_xxx",
"object": "image.generation",
"status": "queued",
"progress": 3,
"model": "gpt-image-2"
}Query task:
curl https://moonnexai.com/v1/images/tasks/task_xxx \
-H "Authorization: Bearer <MOONNEXAI_API_KEY>"task:
{
"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
POST /v1/images/editscurl 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
POST /v1/images/edits/asyncPhoto 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.
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
POST /v1/images/variationscurl 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
| field | Purpose |
|---|---|
model | Picture model name. |
prompt | Picture generation or edit description. |
image | Uploads a photo file. |
size | Output size, e.g. 1024x1024. |
n | Generates the quantity. |
asynchronous tasks Status
| Status | Meaning |
|---|---|
queued / submitted | Submitted, pending processing. |
running | Generating. |
succeeded | Successfully read data[].url. |
failed | Failed 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.