PiAPI commited on
Commit
c8f1415
·
verified ·
1 Parent(s): 11c7f53

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +104 -3
README.md CHANGED
@@ -1,3 +1,104 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ ---
4
+
5
+ # Midjourney API
6
+
7
+ **Model Page:** [Midjourney API](https://piapi.ai/midjourney-api)
8
+
9
+ This model card illustartes the steps to use Midjourney API's endpoint.
10
+ You can also check out other model cards:
11
+
12
+ - [Faceswap API](https://huggingface.co/PiAPI/Faceswap-API)
13
+ - [Suno API](https://huggingface.co/PiAPI/Suno-API)
14
+ - [Dream Machine API](https://huggingface.co/PiAPI/Dream-Machine-API)
15
+
16
+ **Model Information**
17
+
18
+ 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.
19
+
20
+
21
+
22
+ ## Usage Steps
23
+
24
+ Below we share the code snippets on how to use Midjourney API's upscale endpoint.
25
+ - The programming language is Python
26
+ - The origin task ID should be the task ID of the fetched imagine endpoint
27
+
28
+ **Create an upscale task ID**
29
+
30
+ <pre><code class="language-python">
31
+ <span class="hljs-keyword">import</span> http.client
32
+
33
+ conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
34
+
35
+ payload = <span class="hljs-string">"{\n \"origin_task_id\": \"9c6796dd*********1e7dfef5203b\",\n \"index\": \"1\",\n \"webhook_endpoint\": \"\",\n \"webhook_secret\": \"\"\n}"</span>
36
+
37
+ headers = {
38
+ <span class="hljs-built_in">'X-API-Key': "{{x-api-key}}"</span>, //Insert your API Key here
39
+ <span class="hljs-built_in">'Content-Type': "application/json"</span>,
40
+ <span class="hljs-built_in">'Accept': "application/json"</span>
41
+ }
42
+
43
+ conn.request("POST", "/mj/v2/upscale", payload, headers)
44
+
45
+ res = conn.getresponse()
46
+ data = res.read()
47
+
48
+ <span class="hljs-keyword">print</span>(data.decode("utf-8"))
49
+ </code></pre>
50
+
51
+
52
+
53
+ **Retrieve the task ID**
54
+
55
+ <pre><code class="language-python">
56
+ {
57
+ <span class="hljs-built_in">"code"</span>: 200,
58
+ <span class="hljs-built_in">"data"</span>: {
59
+ <span class="hljs-built_in">"task_id"</span>: :3be7e0b0****************d1a725da0b1d" //Record the taskID provided in your response terminal
60
+ },
61
+ <span class="hljs-built_in">"message"</span>: "success"
62
+ }
63
+ </code></pre>
64
+
65
+
66
+
67
+ **Insert the upscale task ID into the fetch endpoint**
68
+
69
+ <pre><code class="language-python">
70
+ <span class="hljs-keyword">import</span> http.client
71
+
72
+ conn = http.client.HTTPSConnection(<span class="hljs-string">"api.piapi.ai"</span>)
73
+
74
+ payload = <span class="hljs-string">"{\n \"task_id\": \"3be7e0b0****************d1a725da0b1d\"\n}"</span> /Replace the task ID with your task ID
75
+
76
+ headers = {
77
+ <span class="hljs-built_in">'Content-Type': "application/json"</span>,
78
+ <span class="hljs-built_in">'Accept': "application/json"</span>
79
+ }
80
+
81
+ conn.request("POST", "/mj/v2/fetch", payload, headers)
82
+
83
+ res = conn.getresponse()
84
+ data = res.read()
85
+
86
+ <span class="hljs-keyword">print</span>(data.decode("utf-8"))
87
+ </code></pre>
88
+
89
+
90
+
91
+ **For fetch endpoint responses** - Refer to our [documentation](https://piapi.ai/docs) for more detailed information.
92
+
93
+
94
+
95
+ <br>
96
+
97
+
98
+
99
+ ## Contact us
100
+
101
+ Contact us at <a href="mailto:[email protected]">[email protected]</a> for any inquires.
102
+
103
+ <br>
104
+