|
| 1 | +from enum import Enum |
| 2 | +from typing import Optional |
| 3 | + |
| 4 | +from pydantic import BaseModel, Field |
| 5 | + |
| 6 | + |
| 7 | +class MinimaxBaseResponse(BaseModel): |
| 8 | + status_code: int = Field( |
| 9 | + ..., |
| 10 | + description='Status code. 0 indicates success, other values indicate errors.', |
| 11 | + ) |
| 12 | + status_msg: str = Field( |
| 13 | + ..., description='Specific error details or success message.' |
| 14 | + ) |
| 15 | + |
| 16 | + |
| 17 | +class File(BaseModel): |
| 18 | + bytes: Optional[int] = Field(None, description='File size in bytes') |
| 19 | + created_at: Optional[int] = Field( |
| 20 | + None, description='Unix timestamp when the file was created, in seconds' |
| 21 | + ) |
| 22 | + download_url: Optional[str] = Field( |
| 23 | + None, description='The URL to download the video' |
| 24 | + ) |
| 25 | + backup_download_url: Optional[str] = Field( |
| 26 | + None, description='The backup URL to download the video' |
| 27 | + ) |
| 28 | + |
| 29 | + file_id: Optional[int] = Field(None, description='Unique identifier for the file') |
| 30 | + filename: Optional[str] = Field(None, description='The name of the file') |
| 31 | + purpose: Optional[str] = Field(None, description='The purpose of using the file') |
| 32 | + |
| 33 | + |
| 34 | +class MinimaxFileRetrieveResponse(BaseModel): |
| 35 | + base_resp: MinimaxBaseResponse |
| 36 | + file: File |
| 37 | + |
| 38 | + |
| 39 | +class MiniMaxModel(str, Enum): |
| 40 | + T2V_01_Director = 'T2V-01-Director' |
| 41 | + I2V_01_Director = 'I2V-01-Director' |
| 42 | + S2V_01 = 'S2V-01' |
| 43 | + I2V_01 = 'I2V-01' |
| 44 | + I2V_01_live = 'I2V-01-live' |
| 45 | + T2V_01 = 'T2V-01' |
| 46 | + Hailuo_02 = 'MiniMax-Hailuo-02' |
| 47 | + |
| 48 | + |
| 49 | +class Status6(str, Enum): |
| 50 | + Queueing = 'Queueing' |
| 51 | + Preparing = 'Preparing' |
| 52 | + Processing = 'Processing' |
| 53 | + Success = 'Success' |
| 54 | + Fail = 'Fail' |
| 55 | + |
| 56 | + |
| 57 | +class MinimaxTaskResultResponse(BaseModel): |
| 58 | + base_resp: MinimaxBaseResponse |
| 59 | + file_id: Optional[str] = Field( |
| 60 | + None, |
| 61 | + description='After the task status changes to Success, this field returns the file ID corresponding to the generated video.', |
| 62 | + ) |
| 63 | + status: Status6 = Field( |
| 64 | + ..., |
| 65 | + description="Task status: 'Queueing' (in queue), 'Preparing' (task is preparing), 'Processing' (generating), 'Success' (task completed successfully), or 'Fail' (task failed).", |
| 66 | + ) |
| 67 | + task_id: str = Field(..., description='The task ID being queried.') |
| 68 | + |
| 69 | + |
| 70 | +class SubjectReferenceItem(BaseModel): |
| 71 | + image: Optional[str] = Field( |
| 72 | + None, description='URL or base64 encoding of the subject reference image.' |
| 73 | + ) |
| 74 | + mask: Optional[str] = Field( |
| 75 | + None, |
| 76 | + description='URL or base64 encoding of the mask for the subject reference image.', |
| 77 | + ) |
| 78 | + |
| 79 | + |
| 80 | +class MinimaxVideoGenerationRequest(BaseModel): |
| 81 | + callback_url: Optional[str] = Field( |
| 82 | + None, |
| 83 | + description='Optional. URL to receive real-time status updates about the video generation task.', |
| 84 | + ) |
| 85 | + first_frame_image: Optional[str] = Field( |
| 86 | + None, |
| 87 | + description='URL or base64 encoding of the first frame image. Required when model is I2V-01, I2V-01-Director, or I2V-01-live.', |
| 88 | + ) |
| 89 | + model: MiniMaxModel = Field( |
| 90 | + ..., |
| 91 | + description='Required. ID of model. Options: T2V-01-Director, I2V-01-Director, S2V-01, I2V-01, I2V-01-live, T2V-01', |
| 92 | + ) |
| 93 | + prompt: Optional[str] = Field( |
| 94 | + None, |
| 95 | + description='Description of the video. Should be less than 2000 characters. Supports camera movement instructions in [brackets].', |
| 96 | + max_length=2000, |
| 97 | + ) |
| 98 | + prompt_optimizer: Optional[bool] = Field( |
| 99 | + True, |
| 100 | + description='If true (default), the model will automatically optimize the prompt. Set to false for more precise control.', |
| 101 | + ) |
| 102 | + subject_reference: Optional[list[SubjectReferenceItem]] = Field( |
| 103 | + None, |
| 104 | + description='Only available when model is S2V-01. The model will generate a video based on the subject uploaded through this parameter.', |
| 105 | + ) |
| 106 | + duration: Optional[int] = Field( |
| 107 | + None, |
| 108 | + description="The length of the output video in seconds." |
| 109 | + ) |
| 110 | + resolution: Optional[str] = Field( |
| 111 | + None, |
| 112 | + description="The dimensions of the video display. 1080p corresponds to 1920 x 1080 pixels, 768p corresponds to 1366 x 768 pixels." |
| 113 | + ) |
| 114 | + |
| 115 | + |
| 116 | +class MinimaxVideoGenerationResponse(BaseModel): |
| 117 | + base_resp: MinimaxBaseResponse |
| 118 | + task_id: str = Field( |
| 119 | + ..., description='The task ID for the asynchronous video generation task.' |
| 120 | + ) |
0 commit comments