# MiniMax Video Generation Example

`MiniMax-H3` supports text-to-video, first/last-frame image-to-video, and multimodal reference-to-video (image / video / audio). Use the OpenAI-compatible async flow: submit then poll. First/last-frame roles must not mix with reference roles.

### 1. Submit Task
* **HTTP Method**: `POST`
* **Request Path**: `https://www.whatstoken.ai/v1/video/generations`

#### A. Text-to-Video
```bash
curl -X POST https://www.whatstoken.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-H3",
    "prompt": "Epic space-opera teaser: a captain stands alone as the fleet jumps away",
    "resolution": "2K",
    "ratio": "16:9",
    "duration": 5
  }'
```

#### B. First / Last Frame Image-to-Video
```bash
curl -X POST https://www.whatstoken.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-H3",
    "prompt": "Pull focus to the background and add more steam",
    "images": [
      "https://example.com/first_frame.png",
      "https://example.com/last_frame.png"
    ],
    "resolution": "2K",
    "duration": 5
  }'
```

#### C. Reference-to-Video (image + video + audio)
```bash
curl -X POST https://www.whatstoken.ai/v1/video/generations \
  -H "Authorization: Bearer sk-your_token_here" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "MiniMax-H3",
    "prompt": "Character speaks with the reference voice; motion follows the reference video",
    "images": [{ "url": "https://example.com/character.png", "role": "reference_image" }],
    "videos": ["https://example.com/motion_ref.mp4"],
    "audios": ["https://example.com/voice_ref.mp3"],
    "resolution": "2K",
    "duration": 5
  }'
```

### 2. Poll Result
```bash
curl -X GET https://www.whatstoken.ai/v1/video/generations/video_task_minimax_001 \
  -H "Authorization: Bearer sk-your_token_here"
```

### 3. Key Parameters
| Parameter | Type | Required | Description |
| :--- | :--- | :--- | :--- |
| `model` | `string` | Yes | `MiniMax-H3` |
| `prompt` | `string` | Yes | Text prompt (always required) |
| `images` | `array` | No | 1→first frame, 2→first+last, or explicit `role` |
| `videos` / `audios` | `array` | No | Reference media (reference scenario only) |
| `resolution` | `string` | Yes | `768P` or `2K` |
| `duration` | `integer` | Yes | `4`–`15` seconds |
| `ratio` | `string` | Conditional | Required for T2V (not `adaptive`) |

### 4. Response Example
```json
{
  "id": "video_task_minimax_001",
  "task_id": "video_task_minimax_001",
  "status": "completed",
  "data": [{ "url": "https://example.com/output/minimax_h3.mp4" }]
}
```



### 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:

:::tabs
=== 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**:
    ```json
    {
      "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**:
    1. Check if the `model` parameter is correct. Refer to the "Endpoints Overview" for available models.
    2. Validate your JSON request body structure to ensure all delimiters are closed.

=== 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**:
    ```json
    {
      "error": {
        "message": "Invalid API Key or authorization header. Please check your credentials.",
        "type": "invalid_request_error",
        "param": null,
        "code": "invalid_api_key"
      }
    }
    ```
*   **Troubleshooting**:
    1. Ensure the request header includes `"Authorization: Bearer sk-xxx"`. Note the space between `Bearer` and the key.
    2. Check the developer console to confirm the token is active and has not been disabled or deleted.

=== 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**:
    ```json
    {
      "error": {
        "message": "Your credit balance is insufficient. Please recharge your account.",
        "type": "insufficient_quota",
        "param": null,
        "code": "insufficient_quota"
      }
    }
    ```
*   **Troubleshooting**:
    1. Log in to the console to check if your account balance is positive.
    2. If you hit a rate limit, implement an exponential backoff retry policy in your application, or contact us to raise limits.
:::
