Midjourney
High-quality image generation from text prompts using Midjourney.
POST /v2/images/generate — model: "midjourney"
High-quality image generation from text prompts.
See Image Generation overview for common request fields, response format, and error codes.
Model-specific parameters
| Parameter | Type | Description |
|---|---|---|
midjourneyParams.aspect_ratio | string | Aspect ratio in "W:H" format (e.g. "16:9", "1:1") |
Credit cost
| Variant | Credits |
|---|---|
| — | 16 |
upsample | 4 |
variation | 16 |
inpaint | 16 |
outpaint | 16 |
pan | 16 |
The upsample and variation rows apply to follow-up actions on a completed generation.
Example result
Once the job is COMPLETED, the result object on GET /v2/jobs/:id looks like:
{
"images": [
"https://cdn2.apiframe.ai/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890-1.png",
"https://cdn2.apiframe.ai/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890-2.png",
"https://cdn2.apiframe.ai/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890-3.png",
"https://cdn2.apiframe.ai/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890-4.png"
],
"gridUrl": "https://cdn2.apiframe.ai/images/a1b2c3d4-e5f6-7890-abcd-ef1234567890-grid.png"
}Midjourney always generates 4 images per request; gridUrl is a single 2×2 composite of all four.
See Result format for field details.
Follow-up actions
Once a generation is COMPLETED, any of its 4 images can be acted on —
equivalent to Midjourney's U1–U4 and V1–V4 buttons. See
Upsample and
Variations in the Follow-up Actions
section. Upsampled images support further actions:
Inpaint (Vary Region),
Outpaint (Zoom Out), and
Pan.
Code examples
curl -X POST https://api.apiframe.ai/v2/images/generate \
-H "X-API-Key: afk_your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"prompt": "a futuristic city skyline at sunset, cyberpunk style",
"model": "midjourney",
"midjourneyParams": {
"aspect_ratio": "16:9"
}
}'import requests
response = requests.post(
"https://api.apiframe.ai/v2/images/generate",
headers={
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
json={
"prompt": "a futuristic city skyline at sunset, cyberpunk style",
"model": "midjourney",
"midjourneyParams": {"aspect_ratio": "16:9"},
},
)
print(response.json())const response = await fetch("https://api.apiframe.ai/v2/images/generate", {
method: "POST",
headers: {
"X-API-Key": "afk_your_api_key_here",
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "a futuristic city skyline at sunset, cyberpunk style",
model: "midjourney",
midjourneyParams: { aspect_ratio: "16:9" },
}),
});
console.log(await response.json());body := `{
"prompt": "a futuristic city skyline at sunset, cyberpunk style",
"model": "midjourney",
"midjourneyParams": {"aspect_ratio": "16:9"}
}`
req, _ := http.NewRequest("POST", "https://api.apiframe.ai/v2/images/generate",
strings.NewReader(body))
req.Header.Set("X-API-Key", "afk_your_api_key_here")
req.Header.Set("Content-Type", "application/json")
resp, err := http.DefaultClient.Do(req)Try it
/v2/images/generateTry it