メインコンテンツまでスキップ

画像生成

This page covers Midjourney image workflows together with OpenAI, Gemini, and Alibaba image generation and editing endpoints.

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
bodybodyanyNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
idpathstringYesTask ID
Content-TypeheaderstringNonone
AcceptheaderstringNonone
AuthorizationheaderstringNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
Content-TypeheaderstringNonone
AcceptheaderstringNonone
AuthorizationheaderstringNonone
bodybodyanyNonone

Response Example

200 Response

[
null
]

Responses

StatusMeaningDescriptionModel
200OKnoneInline
201CreatednoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

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

NameInTypeRequiredDescription
idpathstringYesTask ID
Content-TypeheaderstringNonone
AcceptheaderstringNonone
AuthorizationheaderstringNonone

Response Example

200 Response

null

Responses

StatusMeaningDescriptionModel
200OKnoneInline
401UnauthorizednoneInline
403ForbiddennoneInline
404Not FoundnoneInline

Response Schema

モデル API / 画像生成

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

NameInTypeRequiredDescription
AuthorizationheaderstringNonone
bodybodyobjectNonone
» promptbodystringYesText description of the desired image. Maximum length: 1000 characters.
» nbodyintegerNoNumber of images to generate. Must be between 1 and 10.
» sizebodystringNoSize of the generated image. Must be one of 256x256, 512x512, or 1024x1024.

Response Example

200 Response

{
"created": 0,
"data": [
{
"url": "string"
}
]
}

Responses

StatusMeaningDescriptionModel
200OKnoneInline

Response Schema

Status 200

NameTypeRequiredConstraintsChinese NameDescription
» createdintegertruenonenone
» data[object]truenonenone
»» urlstringtruenonenone

モデル API / 画像生成 / 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

NameInTypeRequiredDescription
AuthorizationheaderstringNonone
bodybodyobjectNonone
» imagebodystring(binary)YesBase image used to create the variation. Must be a valid square PNG smaller than 4 MB.
» nbodystringNo1024x1024
» sizebodystringNoGenerated 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

StatusMeaningDescriptionModel
200OKnoneInline

Response Schema

Status 200

NameTypeRequiredConstraintsChinese NameDescription
» createdintegertruenonenone
» data[object]truenonenone
»» urlstringtruenonenone

モデル API / 画像生成 / Google Gemini / ネイティブ Gemini 形式

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

NameInTypeRequiredDescription
modelpathstringYesModel Name
keyquerystringYesnone
Content-TypeheaderstringYesnone
bodybodyobjectNonone
» contentsbody[object]Yesnone
»» partsbody[object]Nonone
»»» textbodystringNonone

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

StatusMeaningDescriptionModel
200OKnoneInline

Response Schema

Status 200

NameTypeRequiredConstraintsChinese NameDescription
» idstringtruenonenone
» objectstringtruenonenone
» createdintegertruenonenone
» choices[object]truenonenone
»» indexintegerfalsenonenone
»» messageobjectfalsenonenone
»»» rolestringtruenonenone
»»» contentstringtruenonenone
»» finish_reasonstringfalsenonenone
» usageobjecttruenonenone
»» prompt_tokensintegertruenonenone
»» completion_tokensintegertruenonenone
»» total_tokensintegertruenonenone

モデル API / 画像生成 / 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

NameInTypeRequiredDescription
AuthorizationheaderstringNonone
bodybodyobjectNonone
» imagebodystring(binary)Yesnone
» promptbodystringYesText description of the image you want to generate.
» modelbodystringNoModel used for image generation.

Response Example

200 Response

{
"created": 0,
"data": [
{
"url": "string"
}
]
}

Responses

StatusMeaningDescriptionModel
200OKnoneInline

Response Schema

Status 200

NameTypeRequiredConstraintsChinese NameDescription
» createdintegertruenonenone
» data[object]truenonenone
»» urlstringtruenonenone