Génération d’images
This page covers Midjourney image workflows together with OpenAI, Gemini, and Alibaba image generation and editing endpoints.
Couverture Apifox
- Midjourney: intro, Imagine, Action, Blend, Modal, Describe, Shorten, FaceSwap, upload, task query, seed, edit, video, and an OpenAI-compatible imagine endpoint
- OpenAI images:
gpt-image-1.5,dall-e-3, edits, web editor, variations, xAI - Google Gemini: Nano-banana2, Imagen 4, image generation, image editing, native Gemini image generation
- Other vendors: Doubao, Alibaba Qwen, Minimax, flux, flux-kontext-pro, stable-diffusion, ideogram, recraftv3
Midjourney
POST 1. Text to Image (Imagine)
POST /mj/submit/imagine
Executes an Imagine action and submits an image generation task. After submission, obtain the task ID and query its status with the fetch endpoint.
Body Parameters
{
"mode": "RELAX",
"prompt": "Cat"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 2. Button Action
POST /mj/submit/action
This endpoint clicks the buttons below an image. The customId can be obtained from the task fetch endpoint.
Body Parameters
{
"customId": "MJ::JOB::upsample::1::0bc41848-dc7f-42f9-893c-9c33b00ebdf3",
"taskId": "1734937261701345"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 3. Image Blend
POST /mj/submit/blend
Executes a Blend action and submits an image blending task.
Body Parameters
{
"mode": "RELAX",
"base64Array": [
"data:image/png;base64,xxx1",
"data:image/png;base64,xxx2"
],
"dimensions": "SQUARE"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 4. Modal Action
POST /mj/submit/modal
When another task returns code 21, call the modal endpoint and provide a new prompt to refine the result.
Body Parameters
{
"maskBase64": "data:image/png;base64,xxx1",
"prompt": "Cat",
"taskId": "1712204995849324"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 6. Shorten Prompt
POST /mj/submit/shorten
Executes a shorten action to identify which words are most important to image generation and which are less important.
Body Parameters
{
"mode": "RELAX",
"prompt": "Cat"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 8. Upload
POST /mj/submit/upload-discord-images
Uploads images to Discord for use in image prompting and related workflows
Body Parameters
{
"mode": "RELAX",
"base64Array": [
"data:image/png;base64,xxx1"
]
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| body | body | any | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
GET 9. Fetch Task
GET /mj/task/{id}/fetch
Fetches task information by task ID. You can poll this endpoint or rely on callback notifications.
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Task ID |
| Content-Type | header | string | No | none |
| Accept | header | string | No | none |
| Authorization | header | string | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
POST 10. Batch Fetch Tasks
POST /mj/task/list-by-condition
Fetches task information by a list of task IDs. You can poll this endpoint or rely on callback notifications.
Body Parameters
{
"ids": [
"1749688282741136"
]
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| Content-Type | header | string | No | none |
| Accept | header | string | No | none |
| Authorization | header | string | No | none |
| body | body | any | No | none |
Response Example
200 Response
[
null
]
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 201 | Created | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
GET 11. Fetch Image Seed
GET /mj/task/{id}/image-seed
Fetches the image seed value for reuse with the --seed parameter
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| id | path | string | Yes | Task ID |
| Content-Type | header | string | No | none |
| Accept | header | string | No | none |
| Authorization | header | string | No | none |
Response Example
200 Response
null
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
| 401 | Unauthorized | none | Inline |
| 403 | Forbidden | none | Inline |
| 404 | Not Found | none | Inline |
Response Schema
API de modèles / Images
POST Flux with Reference Image / OpenAI-Compatible
POST /images/generations
Only some models support reference images For example: seededit flux-kontext
Body Parameters
{
"prompt": "https://replicate.delivery/pbxt/N55l5TWGh8mSlNzW8usReoaNhGbFwvLeZR3TX1NL4pd2Wtfv/replicate-prediction-f2d25rg6gnrma0cq257vdw2n4c.png Make this a 90s cartoon",
"n": 1,
"model": "flux-kontext-pro",
"size": "1024x1024"
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| Authorization | header | string | No | none |
| body | body | object | No | none |
| » prompt | body | string | Yes | Text description of the desired image. Maximum length: 1000 characters. |
| » n | body | integer | No | Number of images to generate. Must be between 1 and 10. |
| » size | body | string | No | Size of the generated image. Must be one of 256x256, 512x512, or 1024x1024. |
Response Example
200 Response
{
"created": 0,
"data": [
{
"url": "string"
}
]
}
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
Response Schema
Status 200
| Name | Type | Required | Constraints | Chinese Name | Description |
|---|---|---|---|---|---|
| » created | integer | true | none | none | |
| » data | [object] | true | none | none | |
| »» url | string | true | none | none |
API de modèles / Images / Format OpenAI
POST Create Image Variation
POST /images/variations
Creates variations of the supplied image.
Official documentation:https://platform.openai.com/docs/api-reference/images/createVariation
Body Parameters
image: ""
n: "2"
size: 1024x1024
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| Authorization | header | string | No | none |
| body | body | object | No | none |
| » image | body | string(binary) | Yes | Base image used to create the variation. Must be a valid square PNG smaller than 4 MB. |
| » n | body | string | No | 1024x1024 |
| » size | body | string | No | Generated image size. For dall-e-2, allowed values are 256x256, 512x512, or 1024x1024. For dall-e-3, allowed values are 1024x1024, 1792x1024, or 1024x1792. |
Response Example
200 Response
{
"created": 0,
"data": [
{
"url": "string"
}
]
}
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
Response Schema
Status 200
| Name | Type | Required | Constraints | Chinese Name | Description |
|---|---|---|---|---|---|
| » created | integer | true | none | none | |
| » data | [object] | true | none | none | |
| »» url | string | true | none | none |
API de modèles / Images / Google Gemini / Format Gemini natif
POST Generate Image
POST /v1beta/models/{model}:generateContent/
Body Parameters
{
"contents": [
{
"role": "user",
"parts": [
{
"text": "draw a cat"
}
]
}
],
"generationConfig": {
"responseModalities": [
"TEXT",
"IMAGE"
],
"imageConfig": {
"aspectRatio": "16:9",
"imageSize": "4K"
}
}
}
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| model | path | string | Yes | Model Name |
| key | query | string | Yes | none |
| Content-Type | header | string | Yes | none |
| body | body | object | No | none |
| » contents | body | [object] | Yes | none |
| »» parts | body | [object] | No | none |
| »»» text | body | string | No | none |
Response Example
200 Response
{
"id": "string",
"object": "string",
"created": 0,
"choices": [
{
"index": 0,
"message": {
"role": "string",
"content": "string"
},
"finish_reason": "string"
}
],
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
Response Schema
Status 200
| Name | Type | Required | Constraints | Chinese Name | Description |
|---|---|---|---|---|---|
| » id | string | true | none | none | |
| » object | string | true | none | none | |
| » created | integer | true | none | none | |
| » choices | [object] | true | none | none | |
| »» index | integer | false | none | none | |
| »» message | object | false | none | none | |
| »»» role | string | true | none | none | |
| »»» content | string | true | none | none | |
| »» finish_reason | string | false | none | none | |
| » usage | object | true | none | none | |
| »» prompt_tokens | integer | true | none | none | |
| »» completion_tokens | integer | true | none | none | |
| »» total_tokens | integer | true | none | none |
API de modèles / Images / Alibaba Qwen
POST General Image Edit 2.5
POST /images/edits
Official documentation:https://help.aliyun.com/zh/model-studio/wan2-5-image-edit-api-reference?spm=a2c4g.11186623.help-menu-2400256.d_2_2_7.36fa95e52PaUYv&scm=20140722.H_2982258._.OR_help-T_cn~zh-V_1
Body Parameters
image: ""
prompt: 转个圈
model: wan2.5-i2i-preview
Request Parameters
| Name | In | Type | Required | Description |
|---|---|---|---|---|
| Authorization | header | string | No | none |
| body | body | object | No | none |
| » image | body | string(binary) | Yes | none |
| » prompt | body | string | Yes | Text description of the image you want to generate. |
| » model | body | string | No | Model used for image generation. |
Response Example
200 Response
{
"created": 0,
"data": [
{
"url": "string"
}
]
}
Responses
| Status | Meaning | Description | Model |
|---|---|---|---|
| 200 | OK | none | Inline |
Response Schema
Status 200
| Name | Type | Required | Constraints | Chinese Name | Description |
|---|---|---|---|---|---|
| » created | integer | true | none | none | |
| » data | [object] | true | none | none | |
| »» url | string | true | none | none |