Getting started
How to get a Midjourney API key
You won't find an API key in your Midjourney account: Midjourney has no public API. What you can do is get a UserAPI.ai key and attach your own Midjourney account to it. It takes a few minutes, mostly spent on getting the Discord token.
Updated
What you need
- An email to register with.
- A Discord account with a Midjourney subscription. Basic or Standard is enough.
1. Register
Sign up with your email and confirm it. The API key is created automatically.
2. Add the Discord account
On its own the key can't generate anything, it needs a Discord account with Midjourney behind it. In the dashboard go to Discord accounts, press Add Account, paste the Discord token and choose which API key the account belongs to. Activation usually takes 20-40 seconds.
The token is taken from the browser's developer tools. It looks scarier than it is, and the first steps page has screenshots for every step.
3. Check that it works
When the account turns active, copy the key from the dashboard. It goes in the api-key header:
curl -X POST https://api.userapi.ai/midjourney/v2/imagine \-H "Content-Type: application/json" \-H "api-key: YOUR_API_KEY" \-d '{"prompt": "a kitty lying on a cozy couch"}'
You should get a task hash back. The finished picture comes from GET /midjourney/v2/status?hash=… or in a webhook. Ready code: Python, Node.js, PHP.
Keys and accounts
One key can have several Discord accounts. That is useful when one account isn't enough: requests without account_hash go to the accounts in turn, so the load is even. If you need a specific account, pass its account_hash (it is shown in the dashboard).
You can also have several keys, for example one per project or one for testing. Then a key can be deleted without breaking the others.
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
Can I get a key from Midjourney itself?
No. Midjourney has no public API and does not give out keys. Every "Midjourney API key" is from a third-party service, ours included.
Is the key free?
Registration and the key are free, and there is a free pack of 50 requests. After that it is $0.04 per request or $25 a month per Discord account.
Do I need a Midjourney subscription?
Yes. The key works through a Discord account with a paid Midjourney plan, which you add in the dashboard once.
Can one key have several Discord accounts?
Yes. If a request has no account_hash, the accounts on the key take turns.
What if the key leaks?
Delete it on the API Keys page in the dashboard, create a new one and replace it in your code.