AI-APIs commited on
Commit
7dda88d
·
verified ·
1 Parent(s): 1e0ca30

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +128 -0
README.md ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language:
3
+ - en
4
+ license: other
5
+ pipeline_tag: text-to-image
6
+ tags:
7
+ - midjourney
8
+ - text-to-image
9
+ - image-to-image
10
+ inference: false
11
+ ---
12
+
13
+ # Midjourney API
14
+
15
+ Community model card for calling Midjourney through a REST API.
16
+
17
+ Midjourney has no official public API. This repo documents the `midjourney` model as exposed by [Apiframe](https://apiframe.ai/docs/images/midjourney): text-to-image on V8.2, a 4-image grid per job, and follow-up actions (upsample, variation, inpaint, outpaint, pan). Image-to-video is a separate model id, `midjourney-video`.
18
+
19
+ This repository does not host weights. Midjourney is a closed model. Inference runs remotely.
20
+
21
+ <img src="https://apiframe.ai/models-examples/midjourney-glitter-beauty-macro-neon-lashes-feather.webp" alt="Sample output" width="280" />
22
+
23
+ ## Model description
24
+
25
+ | | |
26
+ |---|---|
27
+ | Architecture | Midjourney V8.2 (current default) |
28
+ | Task | text-to-image; image-to-image via follow-up actions |
29
+ | Output | 4 images + `gridUrl` |
30
+ | Aspect ratios | `1:1`, `3:4`, `4:3`, `9:16`, `16:9`, `21:9` |
31
+ | Typical latency | ~50s |
32
+
33
+ ## How to use
34
+
35
+ ```bash
36
+ pip install requests
37
+ ```
38
+
39
+ ```python
40
+ import os
41
+ import time
42
+ import requests
43
+
44
+ API = "https://api.apiframe.ai/v2"
45
+ headers = {
46
+ "X-API-Key": os.environ["APIFRAME_API_KEY"],
47
+ "Content-Type": "application/json",
48
+ }
49
+
50
+ job = requests.post(
51
+ f"{API}/images/generate",
52
+ headers=headers,
53
+ json={
54
+ "model": "midjourney",
55
+ "prompt": "editorial still life of a red heirloom tomato and mimosa, cobalt background",
56
+ "midjourneyParams": {"aspect_ratio": "16:9"},
57
+ },
58
+ ).json()
59
+
60
+ while True:
61
+ result = requests.get(f"{API}/jobs/{job['jobId']}", headers=headers).json()
62
+ if result["status"] in ("COMPLETED", "FAILED"):
63
+ break
64
+ time.sleep(2)
65
+
66
+ print(result.get("result"))
67
+ ```
68
+
69
+ `result["images"]` is a list of 4 CDN URLs. Pass `webhookUrl` on the generate call if you do not want to poll.
70
+
71
+ ### Follow-up actions
72
+
73
+ ```python
74
+ import os
75
+ import requests
76
+
77
+ headers = {
78
+ "X-API-Key": os.environ["APIFRAME_API_KEY"],
79
+ "Content-Type": "application/json",
80
+ }
81
+
82
+ requests.post(
83
+ "https://api.apiframe.ai/v2/images/midjourney/action",
84
+ headers=headers,
85
+ json={
86
+ "parentJobId": "JOB_ID",
87
+ "action": "upsample", # variation | inpaint | outpaint | pan
88
+ "index": 1, # 1-4
89
+ },
90
+ )
91
+ ```
92
+
93
+ ### Image-to-video
94
+
95
+ ```python
96
+ import os
97
+ import requests
98
+
99
+ headers = {
100
+ "X-API-Key": os.environ["APIFRAME_API_KEY"],
101
+ "Content-Type": "application/json",
102
+ }
103
+
104
+ requests.post(
105
+ "https://api.apiframe.ai/v2/videos/generate",
106
+ headers=headers,
107
+ json={
108
+ "model": "midjourney-video",
109
+ "prompt": "slow push in, soft daylight",
110
+ "midjourneyVideoParams": {
111
+ "start_image": "https://example.com/still.jpg",
112
+ "motion": "low",
113
+ "resolution": "hd",
114
+ },
115
+ },
116
+ )
117
+ ```
118
+
119
+ ## Limitations
120
+
121
+ - Closed model. No weights, fine-tuning, or local inference.
122
+ - Not an official Midjourney endpoint. Requires an Apiframe API key (`X-API-Key`).
123
+ - Commercial use follows [Midjourney's terms](https://docs.midjourney.com/hc/en-us/articles/32080852940557-Community-Guidelines).
124
+ - Generated media is retained on the CDN for 90 days.
125
+
126
+ ## License
127
+
128
+ Outputs are subject to Midjourney's terms. This card is documentation only. Apiframe is not affiliated with, endorsed by, or sponsored by Midjourney, Inc.