LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How to Use the Missing Midjourney API (Plus the Hidden Command Language)

Midjourney Art

If you want to create images using Midjourney, you’re stuck using Discord.

Sort of.

Midjourney has not released an API, though they are slowly staggering towards one.  There’s undoubtedly a private internal API but for external public users, the technology is completely tied to Discord.  Authentication on midjourney.com is via Discord and the only way to interact with the technology is by submitting /imagine commands on Discord.

This inhibits some logical workflows.  For example, perhaps you want to work out a set of prompts and then batch-submit them so it can run overnight.  Perhaps you want to auto-upsize each image and save them in a directory along with a text file (or a database entry) describing the prompt used.

And just to state the obvious, Midjourney is the kind of technology that works best with volume.  Yes, if you play around with it, you’ll make some nice images just by feeding it fun creative prompts.  But if you’re trying to get a specific kind of image or look, you’ll need to iteratively generate and tune the results.

For example, here’s a typical workflow.  I have a friend who’s suffering from Lou Gehrig’s  disease and is in full-time managed care.  I had the idea to brighten his spirits by sending him funny images of someone who looks like him, and our other friends can comment and have a chat with him.

To make this happen, the steps are:

  1. Find a phrase that describes my friend.  For example, “middle-aged Italian man with a friendly face and giant forearms”
  2. Add “no mustache” and tweak the age otherwise every image looks like Mario meets Hulk Hogan.
  3. Find a fun scene – for example “terrifically handsome grumpy Italian man with giant forearms taking a selfie with his fellow sailors aboard their World War II German U-boat, everyone laughing, sloshing beer”
  4. Experiment with lighting, mood, art style, and dozens of other parameters.
  5. And then eliminate all the gens where the hands are messed up or someone in the background is missing an eye or other AI artifacts

So you can easily generate 50 times to get what you want.  I mean, that’s what /relax is for.

Alas, to do this, you’re going to be typing all these commands into Discord.  Forget a Python script that generates all the variations you want neatly pipelining to an API.

Well, you don’t have to entirely forget it…

I came across a great article on Medium that takes an interesting approach.  It uses PyAutoGUI to build a bot that talks on your Discord and feeds it prompts from a text file.  I played with it and it works as advertised.  You create a prompts.txt file and then watch the bot type commands.

Just writing a bog-standard Discord bot won’t work because the Midjourney bot expects “/imagine” and then “tab” and then your prompt.  It’s tedious.

Unfortunately, since it’s a fake gui operator waiting for events, I haven’t quite got it modified to create those database entries.  In theory it should be possible to get the attachments and save them – work in progress!

Meanwhile, you might find these resources helpful:

  • First, as general advice, create your own Discord server and add the Midjourney bot to it.  Otherwise if you use their official server your results are jammed in with everyone else’s and it’s a visual mess.
  • All major styles and commands: This Github is an amazing resource.  Tons of lighting, style, mood, artist, perspective, etc. commands.
  • Quick gist of all the major Github commands
  • An incredible 50TB Google Sheet showing all artists and styles (OK, it’s not really 50TB but it’s huge)






  1. @sparker888:

    I was thinking the same about the need for a good API today and stumbled on your post. Thanks for the info and references.

    April 15, 2023 @ 9:01 pm | Reply
  2. MK:

    How to get directly in touch? Twitter perhaps?

    April 26, 2023 @ 9:36 pm | Reply
  3. Just want to show you API layer to Midjourney: userapi.ai
    Link to the documentation
    There are all methods including Vary Region and Remix mode provided

    March 25, 2024 @ 4:44 am | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *