MiniMax Image Generation Example
MiniMax image-01 / image-01-live are available via the OpenAI-compatible POST /v1/images/generations endpoint. Follow the examples below to integrate.
1. Base URL & Endpoint
- HTTP Method:
POST - Request Path:
https://www.whatstoken.ai/v1/images/generations
2. Text-to-Image
curl -X POST https://www.whatstoken.ai/v1/images/generations \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "image-01",
"prompt": "A man in a white t-shirt, full-body, Venice Beach sign background, 90s documentary fashion, film grain",
"ratio": "16:9",
"n": 2,
"prompt_optimizer": true,
"response_format": "url"
}'
3. Image-to-Image / Subject Reference
curl -X POST https://www.whatstoken.ai/v1/images/generations \
-H "Authorization: Bearer sk-your_token_here" \
-H "Content-Type: application/json" \
-d '{
"model": "image-01",
"prompt": "Keep the character identity, looking out from a library window, cinematic light",
"image_urls": ["https://example.com/assets/character_face.jpg"],
"ratio": "16:9",
"n": 1
}'
4. Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | - | image-01 or image-01-live. |
prompt | string | Yes | - | Image description (up to ~1500 chars). |
ratio / aspect_ratio | string | No | 1:1 | Aspect ratio; 21:9 only for image-01. |
image / image_urls | string / array | No | - | Reference image(s) for subject. |
subject_reference | array | No | - | Subject refs: {type:"character", image_file}. |
style | object | No | - | image-01-live only (style_type + style_weight). |
n | integer | No | 1 | Count [1, 9]. |
prompt_optimizer | boolean | No | false | Auto-optimize prompt. |
response_format | string | No | url | url or b64_json. |
5. Response Example (200 OK)
{
"created": 1719441600,
"data": [{ "url": "https://example.com/output/img_minimax_1.png" }]
}
5. Common Error Responses
Our API conforms to standard HTTP status codes and unified JSON error formats. Below are common failure scenarios and troubleshooting tips:
400 Bad Request (Invalid Parameters / Model Not Found)
Returned when the requested model does not exist, is misspelled, or the request JSON body is malformed or missing required fields.
- HTTP Status:
400 - Response Example:
{ "error": { "message": "The model does not exist or you do not have access to it.", "type": "invalid_request_error", "param": "model", "code": "model_not_found" } } - Troubleshooting:
- Check if the
modelparameter is correct. Refer to the "Endpoints Overview" for available models. - Validate your JSON request body structure to ensure all delimiters are closed.
- Check if the
401 Unauthorized (Invalid API Key)
Returned when the API Key (Token) in the HTTP Header is missing, expired, or invalid.
- HTTP Status:
401 - Response Example:
{ "error": { "message": "Invalid API Key or authorization header. Please check your credentials.", "type": "invalid_request_error", "param": null, "code": "invalid_api_key" } } - Troubleshooting:
- Ensure the request header includes
"Authorization: Bearer sk-xxx". Note the space betweenBearerand the key. - Check the developer console to confirm the token is active and has not been disabled or deleted.
- Ensure the request header includes
429 Too Many Requests (Insufficient Quota / Rate Limit)
Returned when your account credit balance is insufficient to pay for the request, or your request frequency exceeds the Rate Limit (RPM/TPM).
- HTTP Status:
429 - Response Example:
{ "error": { "message": "Your credit balance is insufficient. Please recharge your account.", "type": "insufficient_quota", "param": null, "code": "insufficient_quota" } } - Troubleshooting:
- Log in to the console to check if your account balance is positive.
- If you hit a rate limit, implement an exponential backoff retry policy in your application, or contact us to raise limits.