API method

Midjourney describe: image to prompt via API

You send a link to an image and Midjourney writes four prompts for it, exactly like the /describe command in Discord. The answer is a JSON array of strings.

Updated

What it's used for

  • Image-to-prompt services: a user uploads a picture and gets prompts to edit and generate from.
  • Getting closer to a reference: describe it, then send one of the prompts to imagine.
  • Text descriptions for an image library, for example as a starting point for alt text or tags.

Request

POST/midjourney/v2/describe

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

{
"url": "https://example.com/image.jpg",
"webhook_url": "https://example.com/describe/webhook-url",
"webhook_type": "result",
"account_hash": "a7d44910-88a6-4673-acc8-d60ffc3479a6"
}

Parameters

FieldRequiredDescription
urlYesLink to the image. It has to be reachable from the internet.
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.
account_hashNoWhich of your Discord accounts should run the task. If omitted, accounts on the key take turns.

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": "a7d44710-88a6-4673-acc8-d60ffc3479a6",
"hash": "2d7116bf-3006-41e7-9fcc-f1628fc4693a",
"prompt": "https://example.com/50a9.jpg",
"type": "describe",
"status": "done",
"result": [
"nice girl in the hat",
"girl in the nice hat",
"cute girl in the hat",
"girl in the little hat"
],
"status_reason": null,
"created_at": "2006-01-02T15:04:05+00:00"
}

Note that result here is not an image but an array of four strings, and the promptfield contains the URL you sent.

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. Send the image

curl -X POST https://api.userapi.ai/midjourney/v2/describe \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"url": "https://example.com/reference.jpg"}'

2. Get the prompts

When status is done, the prompts are in result:

curl "https://api.userapi.ai/midjourney/v2/status?hash=DESCRIBE_HASH" \
-H "api-key: $USERAPI_KEY"

3. Generate from one of them

curl -X POST https://api.userapi.ai/midjourney/v2/imagine \
-H "Content-Type: application/json" \
-H "api-key: $USERAPI_KEY" \
-d '{"prompt": "girl in the nice hat"}'

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.

If the image only exists on your disk or behind a login, upload it first with POST /midjourney/v2/upload. It takes a PNG or JPG (as a file or a link) and returns a Discord URL that you then pass to describe. Details: Upload.

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

Is there an image-to-prompt API for Midjourney?

Midjourney itself has no public API. Our describe method runs /describe on your Discord account and returns the four prompts as JSON.

How many prompts come back?

Four, same as in Discord. They are in result as an array of strings.

What about a local file?

describe only takes a URL. Upload the file with the upload method first (PNG or JPG) and pass the URL it returns.

Is describe billed?

It is one request, like any other method: $0.04 on pay-per-request, included in the monthly plans.

See also

Use image generation Magic with UserAPI