DEV Community

Cover image for How to use Midjourney API
luke
luke

Posted on • Updated on

How to use Midjourney API

Hello developers, this is a popular science document on how to use Midjourney API. If you have the same needs, congratulations, you finally have a suitable solution

First of all, let me state that Midjourney does not officially provide any API services, so this is not the official API of Midjourney. This set of services was originally designed to solve our own needs. Later, we found that more and more companies and individuals had the same needs as us, and then we decided to develop such a set of products.

Now I start to introduce how to use Midjourney Api in TTApi.

First of all, the documentation of Midjourney Api is shown in the figure below. You can take a look to see if there are functions that meet your needs.

Image description

If there is a endpoint you need, please go to TTApi's registration page.

First step Enter your email, password, and repeat the password to register

Image description

Second step Activate the account. After filling in the registration information, you will jump to the activation page, click the "Send Activate Email" button to send the activation email, and then you will find the activation link in your email, click and activate your account.

Image description

Image description

Third step Using Midjourney Api, after activating the account, you will receive a TT-API-KEY with 100 quota in your email.

Then you can use TT-API-KEY to access the Midjourney API of the TTApi platform

The following is a python example.

import requests

endpoint = "https://api.ttapi.io/midjourney/v1/imagine"

headers = {
    "TT-API-KEY": your_key
}

data = {
    "prompt": "a cute cat",
    "model": "fast",
    "hookUrl": ""
}

response = requests.post(endpoint, headers=headers, json=data)

print(response.status_code)
print(response.json())

Enter fullscreen mode Exit fullscreen mode

And for response

{
  "status": "SUCCESS",
  "message": "",
  "data": {
    "jobId": "afa774a3-1aee-5aba-4510-14818d6875e4"
  }
}
Enter fullscreen mode Exit fullscreen mode

Then you can get the status of the task through the webhook address set in your request or the fetch endpoint

Support for other related endpoint, such as U1-U4, V1-V4, blend, etc., are described in detail in the document. The above is about the Midjourney Api if TTApi is used. If you have any usage questions or suggestions, you can leave a message to me. Thank you very much for taking your precious time to read this article. Have a good day D:)

Top comments (0)