Skip to main content
POST
/
api
/
v1
/
mj
/
generate
Generate Midjourney Image
curl --request POST \
  --url https://api.midapi.ai/api/v1/mj/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "taskType": "mj_txt2img",
  "speed": "relaxed",
  "prompt": "Help me generate a sci-fi themed fighter jet in a beautiful sky, to be used as a computer wallpaper",
  "fileUrls": [
    "https://example.com/image.jpg"
  ],
  "aspectRatio": "16:9",
  "version": "7",
  "variety": 10,
  "stylization": 1,
  "weirdness": 1,
  "waterMark": "",
  "enableTranslation": false,
  "callBackUrl": "https://api.example.com/callback",
  "ow": 500,
  "videoBatchSize": 1,
  "motion": "high"
}'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "mj_task_abcdef123456"
  }
}

Usage Guide

  • This endpoint creates images based on your text prompt
  • Multiple variations will be generated
  • Supports text-to-image, image-to-image, and image-to-video generation

Developer Notes

  • Recommendation for First-Time Users: Start with simple prompts for best results.
  • Generated image files are retained for 15 days before being deleted.
  • Ensure all required fields are provided for optimal generation.

Authorizations

Authorization
string
header
required

All APIs require authentication via Bearer Token.

Get API Key:

  1. Visit API Key Management Page to get your API Key

Usage: Add to request header: Authorization: Bearer YOUR_API_KEY

Note:

  • Keep your API Key secure and do not share it with others
  • If you suspect your API Key has been compromised, reset it immediately in the management page

Body

application/json
taskType
enum<string>
default:mj_txt2img
required

Task type for generation mode.

Image Generation Types:

  • mj_txt2img: Text-to-image generation
  • mj_img2img: Image-to-image generation
  • mj_style_reference: Style reference
  • mj_omni_reference: Omni reference

Video Generation Types:

  • mj_video: Image-to-standard-definition-video generation (supports videoBatchSize parameters)
  • mj_video_hd: Image-to-high-definition-video generation (supports videoBatchSize parameters)
Available options:
mj_txt2img,
mj_img2img,
mj_style_reference,
mj_omni_reference,
mj_video,
mj_video_hd
Example:

"mj_txt2img"

prompt
string
required

Text prompt describing the desired image content. Required for all generation modes.

  • Should be detailed and specific in describing image content
  • Can include style, composition, lighting and other visual elements
  • Max length: 2000 characters
Example:

"Help me generate a sci-fi themed fighter jet in a beautiful sky, to be used as a computer wallpaper"

speed
enum<string>

The speed of the API. It can be 'fast', 'relaxed' or 'turbo', which corresponds to different speed of Midjourney.

  • This parameter is not required when taskType is mj_video, mj_video_hd or mj_omni_reference
Available options:
relaxed,
fast,
turbo
Example:

"relaxed"

fileUrl
string

Input image URL (required for image-to-image and image-to-video generation).

  • Use either fileUrl or fileUrls field
  • Must be a valid image URL
  • Image must be accessible to the API server
  • Leave empty for text-to-image generation
Example:

"https://example.com/image.jpg"

fileUrls
string[]

Input image URL array (required for image-to-image and image-to-video generation).

  • Use either fileUrl or fileUrls field
  • For backward compatibility, fileUrl field is currently retained
  • When generating videos, fileUrls can only have one image link
  • Recommended to use fileUrls field going forward
  • Must be valid image URLs
  • Images must be accessible to the API server
  • Leave empty for text-to-image generation
Example:
["https://example.com/image.jpg"]
aspectRatio
enum<string>

Output image/video aspect ratio.

Supported Aspect Ratios:

RatioFormat TypeCommon Use Cases
2:1Ultra-wideCinematic displays, panoramic views
16:9WidescreenHD video, desktop wallpapers
4:3StandardTraditional displays, presentations
3:2ClassicTraditional photography, prints
1:1SquareSocial media posts, profile pictures
3:4PortraitMagazine layouts, portrait photos
5:6PortraitMobile photography, stories
9:16Mobile PortraitSmartphone wallpapers, stories
2:3PortraitMobile app splash screens
6:5LandscapeTablet wallpapers, digital art
1:2Ultra-tallMobile app splash screens, banners
Available options:
1:2,
9:16,
2:3,
3:4,
5:6,
6:5,
4:3,
3:2,
1:1,
16:9,
2:1
Example:

"16:9"

version
enum<string>

Midjourney model version to use.

Midjourney routinely releases new model versions to improve efficiency, coherency, and quality. The latest model is the default, but each model excels at producing different types of images.

Available options:
7,
6.1,
6,
5.2,
5.1,
niji6
Example:

"7"

variety
integer

Controls the diversity of generated images.

  • Increment by 5 each time, such as (0, 5, 10, 15...)
  • Higher values create more diverse results
  • Lower values create more consistent results
Required range: 0 <= x <= 100
Example:

10

stylization
integer

Stylization level (0-1000).

  • Controls the artistic style intensity
  • Higher values create more stylized results
  • Lower values create more realistic results
  • Suggested to be a multiple of 50
Required range: 0 <= x <= 1000
Example:

1

weirdness
integer

Weirdness level (0-3000).

  • Controls the creativity and uniqueness
  • Higher values create more unusual results
  • Lower values create more conventional results
  • Suggested to be a multiple of 100
Required range: 0 <= x <= 3000
Example:

1

ow
integer

Omni intensity parameter. Controls the strength of the omni reference effect. Range: 1-1000, increments of 1 (e.g. 1, 2, 3).

  • Only used when taskType is 'mj_omni_reference'
  • Using an Omni Reference allows you to put characters, objects, vehicles, or non-human creatures from a reference image into your Midjourney creations
  • Higher values result in stronger reference influence
  • Lower values allow for more creative interpretation
Required range: 1 <= x <= 1000
Example:

500

waterMark
string

Watermark identifier.

  • Optional parameter
  • If provided, a watermark will be added to the generated content
Example:

"my_watermark"

enableTranslation
boolean
default:false

Whether to enable automatic translation.

  • Since prompt only supports English, when this parameter is true, the system will automatically translate non-English prompts to English
  • If your prompt is already in English, you can set this to false
  • Default: false
Example:

false

callBackUrl
string<uri>

Callback URL to receive task completion updates.

  • Optional but recommended for production use
  • System will POST task completion status to this URL
  • Alternatively, use the Get Midjourney Task Details endpoint to check status

šŸ“– Detailed Callback Mechanism: See Midjourney Image Generation Callbacks for callback format, status codes, best practices, and troubleshooting.

Example:

"https://api.example.com/callback"

videoBatchSize
enum<integer>
default:1

Number of videos to generate. Only effective when taskType is 'mj_video' or 'mj_video_hd'.

  • 1: Generate 1 video (default)
  • 2: Generate 2 videos
  • 4: Generate 4 videos
Available options:
1,
2,
4
Example:

1

motion
enum<string>
default:high

Motion parameter for video generation. Controls the level of motion in generated videos.

  • high: High motion level (default)
  • low: Low motion level
  • Required when taskType is 'mj_video' or 'mj_video_hd'
  • Only effective when taskType is 'mj_video' or 'mj_video_hd'
Available options:
high,
low
Example:

"high"

Response

Request successful

code
enum<integer>

Response status code

  • 200: Success - Request has been processed successfully
  • 400: Bad Request - Invalid request parameters
  • 401: Unauthorized - Authentication credentials are missing or invalid
  • 402: Insufficient Credits - Account does not have enough credits to perform the operation
  • 404: Not Found - The requested resource or endpoint does not exist
  • 422: Validation Error - The request parameters failed validation checks
  • 429: Rate Limited - Request limit has been exceeded for this resource
  • 455: Service Unavailable - System is currently undergoing maintenance
  • 500: Server Error - An unexpected error occurred while processing the request
  • 501: Generation Failed - Image generation task failed
  • 505: Feature Disabled - The requested feature is currently disabled
Available options:
200,
400,
401,
402,
404,
422,
429,
455,
500,
501,
505
msg
string

Response message

Example:

"success"

data
object