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
/midjourney/v2/panBase 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
| Field | Required | Description |
|---|---|---|
hash | Yes | Hash of the upscale. |
choice | Yes | Direction: left, right, up or down. |
prompt | No | A new prompt. Only needed when the account is in Remix mode (more on Remix). |
webhook_url | No | Where we POST the task when its status changes. |
webhook_type | No | result: 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"}
| status | What it means |
|---|---|
sent | we passed the task on for processing |
waiting | Midjourney accepted it and put it in the queue |
progress | it is running, progress goes from 0 to 100 |
done | finished, the output is in result |
error | failed, 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
| Method | Endpoint (POST /midjourney/v2…) | Input |
|---|---|---|
| Imagine | /imagine | prompt |
| Upscale | /upscale | hash of imagine / blend / describe / animate + choice 1-4 |
| Upsample (Subtle, Creative, 2x, 4x) | /upsample | hash of upscale |
| Variation | /variation | hash of imagine / describe / blend + choice 1-4 |
| Vary (Subtle) / Vary (Strong) | /vary-subtle, /vary-strong | hash of upscale |
| Reroll | /reroll | hash of a task |
| Animate (video) | /animate | hash of upscale + high / low |
| Inpaint (Vary Region) | /inpaint | hash of upscale + mask + prompt |
| Zoom Out | /zoom | hash of upscale + 50 / 75 or prompt |
| Pan | /pan | hash of upscale + direction |
| Blend | /blend | 2-5 image URLs |
| Describe | /describe | image URL |
| Seed | /seed | hash of a task |
| Upload | /upload | PNG / JPG file or URL |
| Info, Speed, Prefer (Remix) | /info, /speed, /prefer | account_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.