Midjourney-API / README.md
AI-APIs's picture
Update README.md
5478a75 verified
|
Raw
History Blame Contribute Delete
3.31 kB
---
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.