Picture Generation
The image-generation API creates images from text prompts, including product images, posters, sketches, covers and marketing visuals. Common models include gpt-image-2, gpt-image-2-pro, doubao-seedream-5-0-260128 and grok-imagine-image.
API Path
| Methodology | Path | Returns by |
|---|---|---|
POST | /v1/images/generations | synchronous returns the photo result or picture response. |
POST | /v1/images/generations/async | Returns task ID first, then query the results of the picture. |
Example request
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
}'Common field
| field | Annotations |
|---|---|
model | Photo model names, e.g. gpt-image-2, doubao-seedream-5-0-260128, grok-imagine-image. |
prompt | Picture description. |
size | Output size, e.g. 1024x1024. |
n | Generates the quantity. |
response_format | returns the format, which is based on API Reference. |
Results-based processing
| scene | Treatment |
|---|---|
| Return picture URL | Saves URLs, prompts, model names and dimensions. |
| Return picture content | First, you can save access to the business file storage and then you can save the address. |
| Batch Generation | Staples each chart and the parameters for generation in the order of return. |
| asynchronous Generation | Saves id, polling GET /v1/images/tasks/{task_id}, successfully read data[].url. |
Access Recommendations
- Prompt proposes to include the subject, scene, style, aspect ratio and use.
- Saves the prompt, model name, size and result URLs when the batch is generated.
- Synchronous endpoints wait for completion. For long tasks or to avoid a persistent connection, use asynchronous image tasks.
- Use Picture Editor when changing based on a picture already available.