{
  "openapi": "3.1.0",
  "info": {
    "title": "TokLab MiniMax H3",
    "version": "1.0.0",
    "description": "MiniMax H3 Pro uses the native content-array contract; Standard uses a separate flat contract with output-only pricing. Asynchronous task delivery; media by URL only; callbacks are not offered; tasks cannot be cancelled."
  },
  "servers": [
    {
      "url": "https://api.toklab.ai/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/videos/generations": {
      "post": {
        "summary": "Create a video generation task",
        "operationId": "createVideoTask",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted. Poll the returned id; no video is returned by this call.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/tasks/{task_id}": {
      "get": {
        "summary": "Read an owned image task",
        "operationId": "getImageTask",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^task_[A-Za-z0-9]{1,64}$"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Processing, completed or failed task. Polling timeout is not a task failure.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "VideoRequest": {
        "oneOf": [
          {
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "type": "object",
            "properties": {
              "model": {
                "type": "string",
                "enum": [
                  "minimax-h3"
                ]
              },
              "content": {
                "minItems": 1,
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "text"
                        },
                        "text": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "image_url"
                        },
                        "image_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "maxLength": 4096,
                              "format": "uri"
                            }
                          },
                          "required": [
                            "url"
                          ],
                          "additionalProperties": false
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "first_frame",
                            "last_frame",
                            "reference_image"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "image_url"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "video_url"
                        },
                        "video_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "maxLength": 4096,
                              "format": "uri"
                            }
                          },
                          "required": [
                            "url"
                          ],
                          "additionalProperties": false
                        },
                        "role": {
                          "type": "string",
                          "const": "reference_video"
                        }
                      },
                      "required": [
                        "type",
                        "video_url"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "const": "audio_url"
                        },
                        "audio_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string",
                              "maxLength": 4096,
                              "format": "uri"
                            }
                          },
                          "required": [
                            "url"
                          ],
                          "additionalProperties": false
                        },
                        "role": {
                          "type": "string",
                          "const": "reference_audio"
                        }
                      },
                      "required": [
                        "type",
                        "audio_url"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "description": "Exactly one non-empty text item (up to 7000 characters), plus either a first_frame and/or last_frame image, or up to 9 reference_image, 3 reference_video and 3 reference_audio items; frames and references cannot be combined. A single image without a role is the first frame. Media are public http(s) URLs; base64 and mm_file ids are not accepted."
              },
              "resolution": {
                "type": "string",
                "enum": [
                  "768P",
                  "2K"
                ],
                "description": "Required. 768P or 2K."
              },
              "duration": {
                "type": "integer",
                "minimum": 4,
                "maximum": 15,
                "description": "Required. 4–15 seconds."
              },
              "ratio": {
                "type": "string",
                "enum": [
                  "21:9",
                  "16:9",
                  "4:3",
                  "1:1",
                  "3:4",
                  "9:16",
                  "adaptive"
                ],
                "description": "Required for text alone, where adaptive is not accepted. With frames the image sets the shape (any value is treated as adaptive); with references it defaults to adaptive."
              },
              "content_filter": {
                "type": "boolean",
                "default": true,
                "description": "TokLab content filter (not sent to the model): the text, images and first/middle/last frames of reference videos are checked before generation; a flagged or uncheckable request fails without charge."
              }
            },
            "required": [
              "model",
              "content",
              "resolution",
              "duration"
            ],
            "additionalProperties": false
          },
          {
            "$schema": "https://json-schema.org/draft/2020-12/schema",
            "type": "object",
            "properties": {
              "model": {
                "type": "string",
                "const": "minimax-h3-standard"
              },
              "prompt": {
                "type": "string"
              },
              "quality": {
                "type": "string",
                "enum": [
                  "low",
                  "high"
                ]
              },
              "duration_s": {
                "type": "number",
                "minimum": 5,
                "maximum": 15,
                "default": 5
              },
              "resolution": {
                "type": "string",
                "enum": [
                  "480p",
                  "768p",
                  "1080p",
                  "2k",
                  "4k"
                ],
                "default": "768p"
              },
              "aspect_ratio": {
                "type": "string",
                "enum": [
                  "16:9",
                  "9:16",
                  "1:1",
                  "4:3",
                  "3:4",
                  "21:9"
                ],
                "default": "16:9"
              },
              "seed": {
                "type": "integer",
                "format": "int64",
                "minimum": 0,
                "description": "Maximum 9223372036854775807; preserve all digits when serializing."
              },
              "watermark": {
                "type": "boolean",
                "default": false
              },
              "content_filter": {
                "type": "boolean",
                "default": true,
                "description": "TokLab content filter (not sent to the model): the text, images and first/middle/last frames of reference videos are checked before generation; a flagged or uncheckable request fails without charge."
              },
              "enhance": {
                "type": "boolean",
                "default": true
              },
              "priority": {
                "anyOf": [
                  {
                    "type": "number",
                    "const": 1000
                  },
                  {
                    "type": "number",
                    "const": 0
                  }
                ],
                "default": 1000
              },
              "first_frame_image_url": {
                "type": "string",
                "format": "uri"
              },
              "last_frame_image_url": {
                "type": "string",
                "format": "uri",
                "description": "Requires first_frame_image_url. Frames cannot be combined with reference media."
              },
              "reference_image_url": {
                "minItems": 1,
                "maxItems": 4,
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "Up to four reference images; cannot be combined with first/last frames. Images up to 30 MiB; JPG, PNG, WebP, GIF, BMP, TIFF, HEIC, HEIF, AVIF."
              },
              "reference_video_url": {
                "minItems": 1,
                "maxItems": 1,
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                },
                "description": "One reference video; cannot be combined with first/last frames. Up to 100 MiB, 0.5–600 seconds, even width and height of at least 64 pixels."
              }
            },
            "required": [
              "model",
              "prompt",
              "quality"
            ],
            "additionalProperties": false
          }
        ]
      },
      "TaskAccepted": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "minimax-h3",
              "minimax-h3-standard"
            ]
          },
          "status": {
            "const": "processing"
          },
          "created_at": {
            "type": "integer"
          }
        }
      },
      "Task": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "minimax-h3",
              "minimax-h3-standard"
            ]
          },
          "status": {
            "enum": [
              "processing",
              "completed",
              "failed"
            ]
          },
          "created_at": {
            "type": "integer"
          },
          "finished_at": {
            "type": "integer"
          },
          "output": {
            "type": "object",
            "properties": {
              "video_url": {
                "type": "string",
                "format": "uri"
              },
              "resolution": {
                "enum": [
                  "768P",
                  "2K",
                  "480p",
                  "768p",
                  "1080p",
                  "2k",
                  "4k"
                ]
              },
              "ratio": {
                "type": "string",
                "description": "The aspect ratio the clip was made at, including the one chosen for adaptive."
              },
              "duration": {
                "type": "number"
              }
            }
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer",
            "enum": [
              10001,
              10002,
              20001,
              20002,
              30001,
              30002,
              50001,
              50002,
              50003,
              60001,
              60002,
              60003,
              60004,
              90001
            ]
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
