File size: 3,314 Bytes
7dda88d
 
 
 
 
 
 
 
 
 
 
 
 
 
5478a75
 
7dda88d
 
5478a75
7dda88d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5478a75
7dda88d
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
---
language:
  - en
license: other
pipeline_tag: text-to-image
tags:
  - midjourney
  - text-to-image
  - image-to-image
inference: false
---

# Midjourney API

**Model Page:** [Midjourney API](https://apiframe.ai/models/midjourney)

Community model card for calling Midjourney through a REST API.

Midjourney has no official public API. This repo documents the `midjourney` model as exposed by Apiframe: 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`.

This repository does not host weights. Midjourney is a closed model. Inference runs remotely.

<img src="https://apiframe.ai/models-examples/midjourney-glitter-beauty-macro-neon-lashes-feather.webp" alt="Sample output" width="280" />

## Model description

| | |
|---|---|
| Architecture | Midjourney V8.2 (current default) |
| Task | text-to-image; image-to-image via follow-up actions |
| Output | 4 images + `gridUrl` |
| Aspect ratios | `1:1`, `3:4`, `4:3`, `9:16`, `16:9`, `21:9` |
| Typical latency | ~50s |

## How to use

```bash
pip install requests
```

```python
import os
import time
import requests

API = "https://api.apiframe.ai/v2"
headers = {
    "X-API-Key": os.environ["APIFRAME_API_KEY"],
    "Content-Type": "application/json",
}

job = requests.post(
    f"{API}/images/generate",
    headers=headers,
    json={
        "model": "midjourney",
        "prompt": "editorial still life of a red heirloom tomato and mimosa, cobalt background",
        "midjourneyParams": {"aspect_ratio": "16:9"},
    },
).json()

while True:
    result = requests.get(f"{API}/jobs/{job['jobId']}", headers=headers).json()
    if result["status"] in ("COMPLETED", "FAILED"):
        break
    time.sleep(2)

print(result.get("result"))
```

`result["images"]` is a list of 4 CDN URLs. Pass `webhookUrl` on the generate call if you do not want to poll.

### Follow-up actions

```python
import os
import requests

headers = {
    "X-API-Key": os.environ["APIFRAME_API_KEY"],
    "Content-Type": "application/json",
}

requests.post(
    "https://api.apiframe.ai/v2/images/midjourney/action",
    headers=headers,
    json={
        "parentJobId": "JOB_ID",
        "action": "upsample",  # variation | inpaint | outpaint | pan
        "index": 1,            # 1-4
    },
)
```

### Image-to-video

```python
import os
import requests

headers = {
    "X-API-Key": os.environ["APIFRAME_API_KEY"],
    "Content-Type": "application/json",
}

requests.post(
    "https://api.apiframe.ai/v2/videos/generate",
    headers=headers,
    json={
        "model": "midjourney-video",
        "prompt": "slow push in, soft daylight",
        "midjourneyVideoParams": {
            "start_image": "https://example.com/still.jpg",
            "motion": "low",
            "resolution": "hd",
        },
    },
)
```

## Limitations

- Closed model. No weights, fine-tuning, or local inference.
- Not an official Midjourney endpoint. Requires an Apiframe API key (`X-API-Key`).
- Commercial use follows Midjourney's terms.
- Generated media is retained on the CDN for 90 days.

## License

Outputs are subject to Midjourney's terms. This card is documentation only. Apiframe is not affiliated with, endorsed by, or sponsored by Midjourney, Inc.