Documentation
Generate Image

Imagine

POST
https://api.mymidjourney.ai/api/v1/midjourney/imagine

The core API to generate your image.

POST /api/v1/midjourney/imagine

Sample Request

{
  "prompt": "A little cat running on the grass"
}

Request Body

NameTypeRequired
promptstringtrue
refstringfalse
webhookOverridestringfalse

prompt

You can also include an image URL in the prompt attribute, same like you using Midjourney in Discord. For example:

{
  "prompt": "https://cdn.discordapp.com/attachments/123/123/123.png A little cat running on the grass"
}

This will perform image to image generation. You can also include flags such as the --v 5 parameter.

ref (optional)

You can optionally pass ref in your command - which can be used useful when using webhooks You might want to do this to pass some simple metadata through to your webhook.

webhookOverride (optional)

You can optionally pass webhookOverride that will route a response to a webhook of your choosing. Please note that using a webhook is completely optional. You are welcome to use the GET Message endpoint to retrieve responses. The webhook event payload is same as the Message endpoint response.

Sample Response

{
  "success": true,
  "messageId": "your-message-id",
  "createdAt": "2023-08-01T14:03:01.817Z"
}

Response Body

NameTypeDescription
successbooleana boolean value for the generation job creation status
messageIdstringthe messageId for querying the progress later
createdAtstringtimestamp of the task creation
errorstringerror message if any

Examples

const axios = require("axios")
 
const config = {
  method: "post",
  url: "https://api.mymidjourney.ai/api/v1/midjourney/imagine",
  headers: {
    "Content-Type": "application/json",
    Authorization: "Bearer <your-token>",
  },
  data: {
    prompt: "A little cat running on the grass",
  },
}
 
axios(config)
  .then(function (response) {
    console.log(JSON.stringify(response.data))
  })
  .catch(function (error) {
    console.log(error)
  })