| | --- |
| | license: mit |
| | --- |
| | |
| | # Midjourney API |
| |
|
| | **Model Page:** [Midjourney API](https://piapi.ai/midjourney-api) |
| |
|
| | This model card illustartes the steps to use Midjourney API's endpoint. |
| | You can also check out other model cards: |
| |
|
| | - [Faceswap API](https://huggingface.co/PiAPI/Faceswap-API) |
| | - [Suno API](https://huggingface.co/PiAPI/Suno-API) |
| | - [Dream Machine API](https://huggingface.co/PiAPI/Dream-Machine-API) |
| |
|
| | **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** |
| |
|
| | <pre><code class="language-python"> |
| | <span class="hljs-keyword">import</span> http.client |
| | |
| | conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>) |
| | |
| | payload = <span class="hljs-string">"{\n \"origin_task_id\": \"9c6796dd*********1e7dfef5203b\",\n \"index\": \"1\",\n \"webhook_endpoint\": \"\",\n \"webhook_secret\": \"\"\n}"</span> |
| | |
| | headers = { |
| | <span class="hljs-built_in">'X-API-Key': "{{x-api-key}}"</span>, //Insert your API Key here |
| | <span class="hljs-built_in">'Content-Type': "application/json"</span>, |
| | <span class="hljs-built_in">'Accept': "application/json"</span> |
| | } |
| | |
| | conn.request("POST", "/mj/v2/upscale", payload, headers) |
| | |
| | res = conn.getresponse() |
| | data = res.read() |
| | |
| | <span class="hljs-keyword">print</span>(data.decode("utf-8")) |
| | </code></pre> |
| | |
| | |
| | |
| | **Retrieve the task ID** |
| | |
| | <pre><code class="language-python"> |
| | { |
| | <span class="hljs-built_in">"code"</span>: 200, |
| | <span class="hljs-built_in">"data"</span>: { |
| | <span class="hljs-built_in">"task_id"</span>: :3be7e0b0****************d1a725da0b1d" //Record the taskID provided in your response terminal |
| | }, |
| | <span class="hljs-built_in">"message"</span>: "success" |
| | } |
| | </code></pre> |
| | |
| | |
| | |
| | **Insert the upscale task ID into the fetch endpoint** |
| | |
| | <pre><code class="language-python"> |
| | <span class="hljs-keyword">import</span> http.client |
| | |
| | conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>) |
| | |
| | payload = <span class="hljs-string">"{\n \"task_id\": \"3be7e0b0****************d1a725da0b1d\"\n}"</span> /Replace the task ID with your task ID |
| | |
| | headers = { |
| | <span class="hljs-built_in">'Content-Type': "application/json"</span>, |
| | <span class="hljs-built_in">'Accept': "application/json"</span> |
| | } |
| | |
| | conn.request("POST", "/mj/v2/fetch", payload, headers) |
| | |
| | res = conn.getresponse() |
| | data = res.read() |
| | |
| | <span class="hljs-keyword">print</span>(data.decode("utf-8")) |
| | </code></pre> |
| | |
| | |
| | |
| | **For fetch endpoint responses** - Refer to our [documentation](https://piapi.ai/docs/midjourney-api/upscale) for more detailed information. |
| | |
| | |
| | |
| | <br> |
| | |
| | |
| | |
| | ## Contact us |
| | |
| | Contact us at <a href="mailto:contact@piapi.ai">contact@piapi.ai</a> for any inquires. |
| | |
| | <br> |
| | |
| | |