API method

Pan for Midjourney images via API

The arrow buttons under an upscaled image in Discord. Midjourney adds canvas on the chosen side and draws what would be there. In the API it is the pan method with a direction in choice.

Updated

Why use it

  • To get a wide banner or a tall story out of a square picture.
  • To show more of the scene on one side and keep the rest as is.
  • For a panorama: pan several times in the same direction.

Request

POST/midjourney/v2/pan

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": "left",
"prompt": "new prompt, required only if account in remix mode",
"webhook_url": "https://example.com/pan/webhook-url",
"webhook_type": "result"
}

Parameters

FieldRequiredDescription
hashYesHash of the upscale.
choiceYesDirection: left, right, up or down.
promptNoA new prompt. Only needed when the account is in Remix mode (more on Remix).
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": "f815cef1-49f2-4819-92c3-8be17d0b8514",
"hash": "15061f02-c54b-41ca-a66a-49da2988d62b",
"choice": "left",
"type": "pan",
"progress": 100,
"status": "done",
"result": {
"url": "https://cdn.discordapp.com/attachments/...8be17d0b8514.png",
"proxy_url": "https://media.discordapp.net/attachments/...8be17d0b8514.png",
"filename": "...8be17d0b8514.png",
"content_type": "image/png",
"width": 2048,
"height": 2048,
"size": 3354153
},
"status_reason": null,
"created_at": "2024-01-20T09:06:27Z"
}
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. Picture and upscale

curl -X POST https://api.userapi.ai/midjourney/v2/imagine \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"prompt": "a street market at night, neon signs"}'
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/upscale \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"hash": "IMAGINE_HASH", "choice": 4}'

2. Pan right

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

3. Further

Pan returns a grid of four. Upscale one and pan again with the new hash.

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

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.

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

Which directions are there?

left, right, up, down. They go in choice.

Can I change the prompt when panning?

Yes, if Remix is on for the account (it is switched with the prefer method). Then add prompt to the pan request.

How is this different from zoom out?

Zoom out extends the picture on all sides at once, pan on one side only.

See also

Use image generation Magic with UserAPI