license: mit
Midjourney API
Model Page: Midjourney API
This model card illustartes the steps to use Midjourney API's endpoint. You can also check out other model cards:
Model Information
Renowned for its exceptional text-to-image generative AI capabilities, Midjourney is a preferred tool among graphic designers, photographers, and creatives aiming to explore AI-driven artistry. Despite the absence of an official API from Midjourney, PiAPI has introduced the unofficial Midjourney API, empowering developers to incorporate this cutting-edge text-to-image model into their AI applications.
Usage Steps
Below we share the code snippets on how to use Midjourney API's upscale endpoint.
- The programming language is Python
- The origin task ID should be the task ID of the fetched imagine endpoint
Create an upscale task ID
import http.client
conn = http.client.HTTPSConnection("api.piapi.ai")
payload = "{\n \"origin_task_id\": \"9c6796dd*********1e7dfef5203b\",\n \"index\": \"1\",\n \"webhook_endpoint\": \"\",\n \"webhook_secret\": \"\"\n}"
headers = {
'X-API-Key': "{{x-api-key}}", //Insert your API Key here
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/mj/v2/upscale", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
Retrieve the task ID
{
"code": 200,
"data": {
"task_id": :3be7e0b0****************d1a725da0b1d" //Record the taskID provided in your response terminal
},
"message": "success"
}
Insert the upscale task ID into the fetch endpoint
import http.client
conn = http.client.HTTPSConnection("api.piapi.ai")
payload = "{\n \"task_id\": \"3be7e0b0****************d1a725da0b1d\"\n}" /Replace the task ID with your task ID
headers = {
'Content-Type': "application/json",
'Accept': "application/json"
}
conn.request("POST", "/mj/v2/fetch", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
For fetch endpoint responses - Refer to our documentation for more detailed information.
Contact us
Contact us at contact@piapi.ai for any inquires.