{
  "openapi": "3.1.0",
  "info": {
    "title": "MAGI-2 API on SeedRouter",
    "version": "1.0.0",
    "description": "Asynchronous video generation for MAGI-2 (text-to-video, first/last-frame image-to-video, and multimodal reference-to-video). Submit via POST /v1/videos/generations and poll GET /v1/tasks/{task_id}."
  },
  "servers": [
    {
      "url": "https://api.seedrouter.ai/v1"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/videos/generations": {
      "post": {
        "operationId": "createMagi2VideoTask",
        "summary": "Submit a MAGI-2 video generation task",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Magi2Request"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Accepted. Poll the returned task id until status reaches completed or failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskAccepted"
                }
              }
            }
          },
          "400": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "503": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/tasks/{task_id}": {
      "get": {
        "operationId": "getMagi2VideoTask",
        "summary": "Poll a MAGI-2 video task",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current task status and output URL when completed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Task"
                }
              }
            }
          },
          "401": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "404": {
            "description": "Error response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Magi2TextToVideoRequest": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "magi-2-text-to-video"
          },
          "prompt": {
            "type": "string"
          },
          "duration": {
            "type": "integer",
            "minimum": 4,
            "maximum": 30
          },
          "quality": {
            "type": "string",
            "enum": [
              "1080p"
            ]
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4",
              "21:9"
            ]
          },
          "generate_audio": {
            "type": "boolean"
          },
          "seed": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 4294967295
              },
              {
                "type": "null"
              }
            ]
          },
          "fallback": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "model",
          "prompt"
        ],
        "additionalProperties": false
      },
      "Magi2ImageToVideoRequest": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "magi-2-image-to-video"
          },
          "prompt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "image_urls": {
            "minItems": 1,
            "maxItems": 2,
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "duration": {
            "type": "integer",
            "minimum": 4,
            "maximum": 30
          },
          "quality": {
            "type": "string",
            "enum": [
              "1080p"
            ]
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4",
              "21:9"
            ]
          },
          "generate_audio": {
            "type": "boolean"
          },
          "seed": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 4294967295
              },
              {
                "type": "null"
              }
            ]
          },
          "fallback": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "model",
          "image_urls"
        ],
        "additionalProperties": false
      },
      "Magi2ReferenceToVideoRequest": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "magi-2-reference-to-video"
          },
          "prompt": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "image_urls": {
            "anyOf": [
              {
                "maxItems": 10,
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "video_urls": {
            "anyOf": [
              {
                "maxItems": 5,
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "audio_urls": {
            "anyOf": [
              {
                "maxItems": 5,
                "type": "array",
                "items": {
                  "type": "string",
                  "format": "uri"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "duration": {
            "type": "integer",
            "minimum": 4,
            "maximum": 30
          },
          "quality": {
            "type": "string",
            "enum": [
              "1080p"
            ]
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "16:9",
              "9:16",
              "1:1",
              "4:3",
              "3:4",
              "21:9"
            ]
          },
          "generate_audio": {
            "type": "boolean"
          },
          "seed": {
            "anyOf": [
              {
                "type": "integer",
                "minimum": 0,
                "maximum": 4294967295
              },
              {
                "type": "null"
              }
            ]
          },
          "fallback": {
            "type": "object",
            "properties": {
              "enabled": {
                "type": "boolean"
              }
            },
            "additionalProperties": false
          }
        },
        "required": [
          "model"
        ],
        "additionalProperties": false
      },
      "Magi2Request": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/Magi2TextToVideoRequest"
          },
          {
            "$ref": "#/components/schemas/Magi2ImageToVideoRequest"
          },
          {
            "$ref": "#/components/schemas/Magi2ReferenceToVideoRequest"
          }
        ]
      },
      "TaskAccepted": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "magi-2-text-to-video",
              "magi-2-image-to-video",
              "magi-2-reference-to-video"
            ]
          },
          "status": {
            "const": "processing"
          },
          "created_at": {
            "type": "integer"
          }
        }
      },
      "Task": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "magi-2-text-to-video",
              "magi-2-image-to-video",
              "magi-2-reference-to-video"
            ]
          },
          "status": {
            "enum": [
              "processing",
              "completed",
              "failed"
            ]
          },
          "created_at": {
            "type": "integer"
          },
          "finished_at": {
            "type": "integer"
          },
          "output": {
            "type": "object",
            "properties": {
              "video_url": {
                "type": "string",
                "format": "uri"
              }
            }
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          }
        }
      },
      "ErrorResponse": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          }
        }
      }
    }
  }
}
