API method

Midjourney variations via API

Discord has several buttons for getting another version of a picture: V1-V4, Vary (Subtle), Vary (Strong) and 🔄. In the API each is a separate method, and the main thing to get right is which hash it takes.

Updated

Button → method

Midjourney buttonEndpointTakes the hash of
V1, V2, V3, V4/midjourney/v2/variation + choice 1-4imagine, describe or blend grid
Vary (Subtle)/midjourney/v2/vary-subtleupscale
Vary (Strong)/midjourney/v2/vary-strongupscale
🔄 Reroll/midjourney/v2/rerollthe task to repaint

Each of them also takes prompt, but it only matters when the account is in Remix mode.

Request

POST/midjourney/v2/variation

Base URL is https://api.userapi.ai. Every request needs two headers, api-key and Content-Type: application/json.

{
"hash": "6794f6ef-866a-4bc3-b0bc-7b28ec010d1b",
"choice": 1,
"prompt": "new prompt if in remix mode",
"webhook_url": "https://example.com/variation/webhook-url",
"webhook_type": "result"
}

Parameters

FieldRequiredDescription
hashYesHash of a done imagine, describe or blend task.
choiceYesPicture number in the grid, 1 to 4.
promptNoNew prompt, if the account is in Remix mode.
webhook_urlNoWhere we POST the task when its status changes.
webhook_typeNoresult: one call at the end (done or error). progress: also every progress update.

What comes back

The response is just the task hash, e.g. {"hash": "ed162774-9244-4038-bdf1-801b033809ec"}. The finished task is what you later get from GET /midjourney/v2/status?hash=… or in the webhook:

{
"account_hash": "a7d44910-88a6-4673-acc8-d60ffc3479a6",
"hash": "c688a245-3964-4286-9572-d6c7e22f589a",
"choice": 3,
"type": "variation",
"progress": 100,
"status": "done",
"result": {
"url": "https://cdn.discordapp.com/...515a41ad678f.png",
"proxy_url": "https://media.discordapp.net/...515a41ad678f.png",
"filename": "...-515a41ad678f.png",
"content_type": "image/png",
"width": 2048,
"height": 2048,
"size": 7003237
},
"status_reason": null,
"created_at": "2006-01-02T15:04:05+00:00"
}

No account_hash here: variations are made by the same Discord account that generated the original.

statusWhat it means
sentwe passed the task on for processing
waitingMidjourney accepted it and put it in the queue
progressit is running, progress goes from 0 to 100
donefinished, the output is in result
errorfailed, see status_reason

Example with cURL

1. Grid

curl -X POST https://api.userapi.ai/midjourney/v2/imagine \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"prompt": "a robot barista making latte art"}'

2. V3

curl "https://api.userapi.ai/midjourney/v2/status?hash=IMAGINE_HASH" \
-H "api-key: $USERAPI_KEY"
curl -X POST https://api.userapi.ai/midjourney/v2/variation \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"hash": "IMAGINE_HASH", "choice": 3}'

3. Or 🔄 for the whole grid

curl -X POST https://api.userapi.ai/midjourney/v2/reroll \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"hash": "IMAGINE_HASH"}'

4. Vary (Subtle) on an upscaled picture

curl -X POST https://api.userapi.ai/midjourney/v2/upscale \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"hash": "IMAGINE_HASH", "choice": 3}'
curl -X POST https://api.userapi.ai/midjourney/v2/vary-subtle \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"hash": "UPSCALE_HASH"}'

Wrappers for Python, Node.js and PHP are on separate pages. If you'd rather not write code, the same methods are available in n8n and Make. This method in the documentation.

Vary (Subtle) and Vary (Strong)

POST/midjourney/v2/vary-subtle

POST/midjourney/v2/vary-strong
{
"hash": "6794f6ef-856a-4bc3-b0bc-7b28ec010d1b",
"prompt": "new prompt if in remix mode",
"webhook_url": "https://example.com/vary-subtle/webhook-url",
"webhook_type": "result"
}

Both work on an upscale, not on a grid. Subtle changes small details, Strong changes the picture noticeably more.

Reroll

POST/midjourney/v2/reroll

The 🔄 button: the same prompt is generated again. Send the task hash, and in Remix mode also a new prompt.

Remix

When Remix is on, variation, vary-subtle, vary-strong, reroll and pan use the prompt you send. This is how you keep the composition and change the details. Remix is set per Discord account, with the prefer method:

POST/midjourney/v2/prefer
{
"account_hash": "6794f6ef-866a-4bc3-b0bc-7b28ec010d1b",
"choice": "remix",
"is_async": false
}

prefer toggles the mode, and the new state comes back in result ("on" or "off"). With is_async: false the response waits until the switch is done. The current state is in the is_remix field of GET /discord/info?account_hash=….

Other methods

MethodEndpoint (POST /midjourney/v2…)Input
Imagine/imagineprompt
Upscale/upscalehash of imagine / blend / describe / animate + choice 1-4
Upsample (Subtle, Creative, 2x, 4x)/upsamplehash of upscale
Variation/variationhash of imagine / describe / blend + choice 1-4
Vary (Subtle) / Vary (Strong)/vary-subtle, /vary-stronghash of upscale
Reroll/rerollhash of a task
Animate (video)/animatehash of upscale + high / low
Inpaint (Vary Region)/inpainthash of upscale + mask + prompt
Zoom Out/zoomhash of upscale + 50 / 75 or prompt
Pan/panhash of upscale + direction
Blend/blend2-5 image URLs
Describe/describeimage URL
Seed/seedhash of a task
Upload/uploadPNG / JPG file or URL
Info, Speed, Prefer (Remix)/info, /speed, /preferaccount_hash

Try it on 50 free requests

Register, add a Discord account that has Midjourney, and you get an API key. The first 50 requests are free and you don't need to enter a card. Since 2023 more than 10,000 people have signed up and sent over 8 million requests through the API.

Questions

Variation or Vary?

variation (V1-V4) works on a grid: the grid hash plus picture number 1-4. vary-subtle and vary-strong work on an upscaled picture and take the upscale hash.

How do I change the prompt in a variation?

Turn on Remix for the account with prefer, then add prompt to variation, vary-subtle, vary-strong, reroll or pan.

Can I get the seed?

Yes, with the seed method. Besides the seed it returns links to the four pictures of the grid separately. It can only be called once per hash.

Is every variation a separate request?

Yes, every call is one request: $0.04 on pay-per-request, not counted on monthly plans.

See also

Use image generation Magic with UserAPI