Midjourney Text To Image API Documentation
Playground
Try it on WaveSpeedAI!Midjourney Text-to-Image creates high-quality, artistic images from text prompts, with strong creative interpretation, detailed composition, and flexible visual styles for concept art, marketing assets, social content, and production workflows. Ready-to-use REST inference API, best performance, no coldstarts, affordable pricing.
Features
Midjourney Text-to-Image generates images from a text prompt. Describe the image you want, optionally add a style reference image, choose an aspect ratio, and adjust generation controls such as HD mode, quality, stylize, chaos, weird, and seed.
Why Choose This?
-
Prompt-based image generation
Generate images directly from a text prompt. -
Style reference support
Use an optional style reference image to guide the visual style of the generated images. -
Flexible aspect ratios
Choose from multiple output aspect ratios, including square, vertical, horizontal, and cinematic formats. -
Generation control parameters
Adjuststylize,chaos, andweirdto control aesthetic strength, variation, and unconventional visual characteristics. -
HD mode
Enablehdwhen you want higher-definition generation. -
Seed support
Use a fixed seed for more reproducible results, or set-1for a random seed.
Parameters
| Parameter | Required | Description |
|---|---|---|
| prompt | Yes | Text prompt describing the image to generate. Maximum length: 1024 characters. |
| sref | No | Optional style reference image URL. |
| aspect_ratio | No | Aspect ratio of the generated images. Options: 1:1, 9:16, 16:9, 4:3, 3:4, 2:3, 3:2, 9:21, or 21:9. Default: 1:1. |
| hd | No | Enable HD generation mode. Default: false. |
| quality | No | Generation quality setting. Options: 1 or 4. Default: 1. |
| stylize | No | Controls how strongly the model’s aesthetic style influences the result. Range: 0–1000. Default: 0. |
| chaos | No | Controls variation and unpredictability. Range: 0–100. Default: 0. |
| weird | No | Adds unconventional or surreal characteristics. Range: 0–3000. Default: 0. |
| seed | No | Random seed. Use -1 for a random seed. Range: -1–2147483647. Default: -1. |
How to Use
- Write your prompt — Describe the image you want to generate, including subject, composition, lighting, mood, and style.
- Add a style reference optional — Provide
srefif you want to guide the visual style with a reference image. - Choose aspect ratio — Select the output format, such as
1:1,9:16,16:9, or21:9. - Configure HD optional — Enable
hdwhen higher-definition generation is needed. - Adjust generation settings optional — Configure
quality,stylize,chaos,weird, andseedas needed. - Submit — Generate the image outputs.
Output
Returns generated image URL(s) in the standard WaveSpeed prediction response.
Each request generates 4 images.
Pricing
Pricing is based on whether hd is enabled. Each request generates 4 images.
| HD Mode | Request Cost | Effective Cost per Image |
|---|---|---|
false | $0.10 | $0.025 |
true | $0.15 | $0.0375 |
Other parameters do not add separate charges.
Best Use Cases
- Creative image generation — Generate original images from text prompts.
- Concept art — Create visual concepts for characters, scenes, objects, and environments.
- Social media visuals — Generate images for posts, thumbnails, banners, and campaigns.
- Style exploration — Use
sref,stylize,chaos, andweirdto test different visual directions. - Cinematic and vertical formats — Use aspect ratios such as
16:9,21:9,9:16, or9:21for different content formats.
Pro Tips
- Keep prompts clear and specific.
- Use
srefwhen you want the output to follow a specific visual style. - Use
stylizeto control the strength of the model’s aesthetic influence. - Increase
chaoswhen you want more variation across outputs. - Increase
weirdwhen you want more unconventional or surreal results. - Enable
hdwhen higher-definition output is needed. - Use a fixed
seedwhen you want more reproducible generations. - Use
-1for random seed generation. - Choose the aspect ratio based on the final use case, such as
1:1for square images,9:16for vertical content, or16:9for widescreen images.
Authentication
For authentication details, please refer to the Authentication Guide.
API Endpoints
Submit Task & Query Result
set -euo pipefail
export WAVESPEED_API_KEY="your-api-key"
REQUEST_BODY=$(cat <<'JSON'
{
"prompt": "A cinematic ocean wave at sunrise, highly detailed",
"aspect_ratio": "1:1",
"hd": false,
"quality": 1,
"stylize": 0,
"chaos": 0,
"weird": 0,
"seed": -1
}
JSON
)
# 1. Submit the prediction.
SUBMIT_RESPONSE=$(curl --silent --show-error --fail-with-body \
-X POST "https://api.wavespeed.ai/api/v3/midjourney/text-to-image" \
-H "Authorization: Bearer ${WAVESPEED_API_KEY}" \
-H "Content-Type: application/json" \
-d "${REQUEST_BODY}")
TASK=$(printf '%s' "${SUBMIT_RESPONSE}" | jq 'if type == "object" and has("data") then .data else . end')
PREDICTION_ID=$(printf '%s' "${TASK}" | jq -r '.id // empty')
if [ -z "${PREDICTION_ID}" ]; then
printf 'Submission response did not contain a prediction id
' >&2
exit 1
fi
RESULT_URL="https://api.wavespeed.ai/api/v3/predictions/${PREDICTION_ID}/result"
# 2. Poll until the prediction finishes.
while true; do
RESPONSE=$(curl --silent --show-error --fail-with-body \
"${RESULT_URL}" \
-H "Authorization: Bearer ${WAVESPEED_API_KEY}")
RESULT=$(printf '%s' "${RESPONSE}" | jq 'if type == "object" and has("data") then .data else . end')
STATUS=$(printf '%s' "${RESULT}" | jq -r '.status // empty')
case "${STATUS}" in
completed) printf '%s\n' "${RESULT}" | jq '.outputs'; break ;;
failed|cancelled|timeout|deleted) printf '%s\n' "${RESULT}" | jq . >&2; exit 1 ;;
*) sleep 2 ;;
esac
doneParameters
Task Submission Parameters
Request Parameters
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
| prompt | string | Yes | - | Text prompt describing the image to generate. | |
| sref | string | No | - | - | Optional style reference image URL. |
| aspect_ratio | string | No | 1:1 | 1:1, 9:16, 16:9, 4:3, 3:4, 2:3, 3:2, 9:21, 21:9 | Aspect ratio of the generated images. |
| hd | boolean | No | false | - | Enable HD generation mode. |
| quality | integer | No | 1 | 1, 4 | Generation quality setting supported by Midjourney v8.1. |
| stylize | integer | No | 0 | 0 ~ 1000 | Controls how strongly Midjourney's aesthetic style influences the result. |
| chaos | integer | No | 0 | 0 ~ 100 | Controls variation and unpredictability. |
| weird | integer | No | 0 | 0 ~ 3000 | Adds unconventional or surreal characteristics. |
| seed | integer | No | -1 | -1 ~ 2147483647 | Random seed. Use -1 for a random seed. |
Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | integer | HTTP status code (e.g., 200 for success) |
| message | string | Status message (e.g., “success”) |
| data.id | string | Unique identifier for the prediction, Task Id |
| data.model | string | Model ID used for the prediction |
| data.outputs | array | Output values, usually URL strings; some models return text strings or structured result objects (empty when status is not completed) |
| data.urls | object | Object containing related API endpoints |
| data.status | string | Task status. completed is successful; failed, cancelled, timeout, and deleted are failure terminal statuses. |
| data.created_at | string | ISO timestamp of when the request was created (e.g., “2023-04-01T12:34:56.789Z”) |
| data.error | string | Error message (empty if no error occurred) |
| data.timings | object | Object containing timing details |
| data.timings.inference | integer | Inference time in milliseconds |
Result Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| id | string | Yes | - | Task ID |
Result Response Parameters
| Parameter | Type | Description |
|---|---|---|
| code | integer | HTTP status code (e.g., 200 for success) |
| message | string | Status message (e.g., “success”) |
| data | object | The prediction data object containing all details |
| data.id | string | Unique identifier for the prediction |
| data.model | string | Model ID used for the prediction |
| data.outputs | array<string | object> | Array of generated outputs (empty when status is not completed). Items are usually URL strings, but may be text strings or structured result objects, depending on the model. |
| data.urls | object | Object containing related API endpoints |
| data.status | string | Status: completed is successful; failed, cancelled, timeout, and deleted are failure terminal statuses |
| data.created_at | string | ISO timestamp of when the request was created |
| data.error | string | Error message (empty if no error occurred) |
| data.timings | object | Object containing timing details |
| data.timings.inference | integer | Inference time in milliseconds |