Skip to main content
POST
/
v1
/
image_generation
Image Generation
curl --request POST \
  --url https://api.minimax.io/v1/image_generation \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "model": "image-01",
  "prompt": "A girl looking into the distance from a library window",
  "aspect_ratio": "16:9",
  "subject_reference": [
    {
      "type": "character",
      "image_file": "https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg"
    }
  ],
  "n": 2
}
'
import requests

url = "https://api.minimax.io/v1/image_generation"

payload = {
"model": "image-01",
"prompt": "A girl looking into the distance from a library window",
"aspect_ratio": "16:9",
"subject_reference": [
{
"type": "character",
"image_file": "https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg"
}
],
"n": 2
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "Bearer <token>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: 'Bearer <token>'},
body: JSON.stringify({
model: 'image-01',
prompt: 'A girl looking into the distance from a library window',
aspect_ratio: '16:9',
subject_reference: [
{
type: 'character',
image_file: 'https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg'
}
],
n: 2
})
};

fetch('https://api.minimax.io/v1/image_generation', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
CURLOPT_URL => "https://api.minimax.io/v1/image_generation",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'image-01',
'prompt' => 'A girl looking into the distance from a library window',
'aspect_ratio' => '16:9',
'subject_reference' => [
[
'type' => 'character',
'image_file' => 'https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg'
]
],
'n' => 2
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: <content-type>"
],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}
package main

import (
"fmt"
"strings"
"net/http"
"io"
)

func main() {

url := "https://api.minimax.io/v1/image_generation"

payload := strings.NewReader("{\n \"model\": \"image-01\",\n \"prompt\": \"A girl looking into the distance from a library window\",\n \"aspect_ratio\": \"16:9\",\n \"subject_reference\": [\n {\n \"type\": \"character\",\n \"image_file\": \"https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg\"\n }\n ],\n \"n\": 2\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "Bearer <token>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.minimax.io/v1/image_generation")
.header("Content-Type", "<content-type>")
.header("Authorization", "Bearer <token>")
.body("{\n \"model\": \"image-01\",\n \"prompt\": \"A girl looking into the distance from a library window\",\n \"aspect_ratio\": \"16:9\",\n \"subject_reference\": [\n {\n \"type\": \"character\",\n \"image_file\": \"https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg\"\n }\n ],\n \"n\": 2\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.minimax.io/v1/image_generation")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = 'Bearer <token>'
request.body = "{\n \"model\": \"image-01\",\n \"prompt\": \"A girl looking into the distance from a library window\",\n \"aspect_ratio\": \"16:9\",\n \"subject_reference\": [\n {\n \"type\": \"character\",\n \"image_file\": \"https://cdn.hailuoai.com/prod/2025-08-12-17/video_cover/1754990600020238321-411603868533342214-cover.jpg\"\n }\n ],\n \"n\": 2\n}"

response = http.request(request)
puts response.read_body
{
  "id": "03ff3cd0820949eb8a410056b5f21d38",
  "data": {
    "image_urls": [
      "XXX",
      "XXX",
      "XXX"
    ]
  },
  "metadata": {
    "failed_count": "0",
    "success_count": "3"
  },
  "base_resp": {
    "status_code": 0,
    "status_msg": "success"
  }
}

Authorizations

Authorization
string
header
required

HTTP: Bearer Auth

Headers

Content-Type
enum<string>
default:application/json
required

The media type of the request body. Must be set to application/json to ensure the data is sent in JSON format.

Available options:
application/json

Body

application/json
model
enum<string>
required

Model name. Options: image-01.

Available options:
image-01,
image-01-live
prompt
string
required

Text description of the image, max length 1500 characters.

subject_reference
object[]

Subject reference for image-to-image generation.

aspect_ratio
enum<string>

Image aspect ratio, default 1:1. Options:

  • 1:1 (1024x1024)
  • 16:9 (1280x720)
  • 4:3 (1152x864)
  • 3:2 (1248x832)
  • 2:3 (832x1248)
  • 3:4 (864x1152)
  • 9:16 (720x1280)
  • 21:9 (1344x576)
Available options:
1:1,
16:9,
4:3,
3:2,
2:3,
3:4,
9:16,
21:9
width
integer

Image width (px). Only effective for image-01. Must be set together with height. Range [512, 2048], must be divisible by 8. If both width/height and aspect_ratio are provided, aspect_ratio takes priority.

height
integer

Height of generated image (pixels). Only effective when model is image-01. Same rules as width.

response_format
enum<string>
default:url

Response format for images. Default: url. Options: url, base64. ⚠️ Note: url expires in 24 hours.

Available options:
url,
base64
seed
integer<int64>

Random seed. Using the same seed and parameters allows result reproduction. If omitted, each of the n images will use a unique random seed.

n
integer
default:1

Number of images to generate per request. Range [1, 9]. Default: 1.

Required range: 1 <= x <= 9
prompt_optimizer
boolean
default:false

Enable automatic optimization of prompt. Default: false.

Response

200 - application/json
data
object
metadata
object

Additional metadata about the generation.

id
string

Trace ID for request tracking

base_resp
object