Create an image using a text prompt

Table of contents

March 17, 2025

  1. Request Headers
  2. Request Body
  3. Responses
  4. Model
  5. Examples
  6. Try It

Use hailuoai.video account to retrieve list of generated images, see Setup MiniMax for details.

To retrieve generated image(s), use:

https://api.useapi.net/v1/minimax/images/create

Request Headers
Authorization: Bearer {API token}
Content-Type: application/json
# Alternatively you can use multipart/form-data
# Content-Type: multipart/form-data
Request Body
{
    "account": "Optional MiniMax API account",
    "prompt": "Required text prompt",
    "promptOptimization": true,
    "model": "image-01",
    "aspectRatio": "9:16",
    "quantity": 4,
    "replyUrl": "Place your call back URL here",
    "replyRef": "Place your reference id here",
}
  • account is optional when only one account configured. However, if you have multiple accounts configured, this parameter becomes required.

  • prompt is required, describe your image.
    Maximum length 1250 characters.

  • promptOptimization is optional.
    Supported values: true (default), false.

  • model is optional.
    Supported values:
    • image-01 (default).
  • aspectRatio is optional. Supported values: 21:9, 16:9 (default), 4:3, 1:1, 3:4, 9:16.

  • quantity is optional. Supported range: 1…4, default 1.

  • replyUrl is optional, if not provided value from account will be used.
    Place here your callback URL. API will call the provided replyUrl once MiniMax image completed or failed.
    Maximum length 1024 characters.
    We recommend using sites like webhook.site to test callback URL functionality.

  • replyRef is optional, place here your reference id which will be stored and returned along with this MiniMax image response/result.
    Maximum length 1024 characters.
Responses
  • 200 OK

    Use returned in array imageIds values to retrieve image status and results using GET images/imageId. Check videoURL and/or downloadURL (paid account, no watermarks) for generated image with the status 2 (Completed).

    If you specify the optional parameter replyUrl the API will call the provided replyUrl with image progress updates until the image is complete or fails.

    {
        "id": "<image_id_1>",
        "task": {
            "batchID": "<batch_id>",
            "videoIDs": [
                "<image_id_1>",
                "<image_id_2>",
                "<image_id_3>",
                "<image_id_4>"
            ]
        },
        "isFirstGenerate": false,
        "imageIds": [
            "user:<user>-minimax:<account>-image:<image_id_1>",
            "user:<user>-minimax:<account>-image:<image_id_2>",
            "user:<user>-minimax:<account>-image:<image_id_3>",
            "user:<user>-minimax:<account>-image:<image_id_4>"
        ],
        "replyUrl": "https://webhook.site/…",
        "replyRef": "2025-03-11T17:23:05.795Z",
        "code": 200
    }
    
  • 400 Bad Request

    {
      "error": "<Error message>"
    }
    
  • 401 Unauthorized

    {
      "error": "Unauthorized"
    }
    
  • 412 Insufficient credits

    Insufficient credits. Please recharge to get more credits or try again next day.

    {
      "error": "Insufficient credits. Please recharge to get more credits or try again next day."
    }
    
  • 422 Unprocessable Content

    Moderated message.

    {
      "error": "Your prompt is too short, please provide more details"
    }
    
  • 429 Too Many Requests

    Wait in a loop for at least 10..30 seconds and retry again.

    {
        "error": "There are currently multiple tasks in the queue, and only <number> can be generated at once"
    }
    
  • 596 Pending mod message

    Your hailuoai.video account has been placed on hold, which may last a few hours. It may be a good idea to pause operations until then. You can reach out to the Discord support channel or send an email requesting your account to be unlocked. Based on the information we have gathered, this seems to be a temporary ban that will automatically unlock in just a few hours.

    {
      "error": "Unusual account activities detected. Please contact customer support at [email protected]"
    }
    
Model
{ // TypeScript, all fields are optional
  id: string
  task: {
    batchID: string
    videoIDs: string[]
  }
  isFirstGenerate: boolean
  imageIds: string[]
  replyUrl: string
  replyRef: string
  code: number
}
Examples
  • curl -H "Accept: application/json" \
         -H "Content-Type: application/json" \
         -H "Authorization: Bearer …" \
         -X POST "https://api.useapi.net/v1/minimax/images/create" \
         -d '{"prompt": "…"}'
    
  • const prompt = "text prompt";      
    const apiUrl = `https://api.useapi.net/v1/minimax/images/create`; 
    const token = "API token";
    const data = { 
      method: 'POST',
      headers: {
        'Authorization': `Bearer ${token}`,
        'Content-Type': 'application/json' }
    };
    data.body = JSON.stringify({ 
      prompt
    });
    const response = await fetch(apiUrl, data);
    const result = await response.json();
    console.log("response", {response, result});
    
  • import requests
    prompt = "text prompt"      
    apiUrl = f"https://api.useapi.net/v1/minimax/images/create" 
    token = "API token"
    headers = {
        "Content-Type": "application/json", 
        "Authorization" : f"Bearer {token}"
    }
    body = {
        "prompt": f"{prompt}"
    }
    response = requests.post(apiUrl, headers=headers, json=body)
    print(response, response.json())
    
Try It