{
  "openapi": "3.1.0",
  "info": {
    "title": "TokLab Seedance 2.5",
    "version": "1.0.0",
    "description": "The official ModelArk video generation request body, submitted to the unified POST /videos/generations and read from GET /tasks/{task_id}. Media by URL only; tasks cannot be cancelled or deleted; tools are not exposed. Supports 480p drafts and 1080p final videos from draft_task."
  },
  "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 video task",
        "operationId": "getVideoTask",
        "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"
                }
              }
            }
          },
          "503": {
            "description": "Public error; no infrastructure details.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "VideoRequest": {
        "$schema": "https://json-schema.org/draft/2020-12/schema",
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "enum": [
              "dreamina-seedance-2-5"
            ]
          },
          "content": {
            "minItems": 1,
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "type": {
                      "type": "string",
                      "const": "draft_task"
                    },
                    "draft_task": {
                      "type": "object",
                      "properties": {
                        "id": {
                          "type": "string",
                          "pattern": "^task_[A-Za-z0-9]{1,64}$"
                        }
                      },
                      "required": [
                        "id"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "type",
                    "draft_task"
                  ],
                  "additionalProperties": false
                },
                {
                  "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",
                          "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",
                          "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",
                          "format": "uri"
                        }
                      },
                      "required": [
                        "url"
                      ],
                      "additionalProperties": false
                    },
                    "role": {
                      "type": "string",
                      "const": "reference_audio"
                    }
                  },
                  "required": [
                    "type",
                    "audio_url"
                  ],
                  "additionalProperties": false
                }
              ]
            },
            "description": "One text item plus media by public HTTP(S) URL: first_frame / last_frame images, or up to 30 reference_image, 10 reference_video and 10 reference_audio items. Base64, data: and asset:// are not accepted."
          },
          "resolution": {
            "type": "string",
            "enum": [
              "480p",
              "720p",
              "1080p"
            ],
            "description": "Default 720p for standard generation, 480p for draft=true. Draft requires 480p. A draft_task final requires explicit 1080p."
          },
          "ratio": {
            "type": "string",
            "enum": [
              "16:9",
              "4:3",
              "1:1",
              "3:4",
              "9:16",
              "21:9",
              "adaptive"
            ],
            "default": "adaptive"
          },
          "duration": {
            "type": "integer",
            "minimum": -1,
            "maximum": 30,
            "not": {
              "enum": [
                0,
                1,
                2,
                3
              ]
            },
            "default": -1,
            "description": "-1 (the model chooses) or 4–30 seconds."
          },
          "generate_audio": {
            "type": "boolean",
            "default": true
          },
          "watermark": {
            "type": "boolean",
            "default": false
          },
          "return_last_frame": {
            "type": "boolean",
            "default": false
          },
          "execution_expires_after": {
            "type": "integer",
            "minimum": 3600,
            "maximum": 259200,
            "default": 172800
          },
          "priority": {
            "type": "integer",
            "minimum": 0,
            "maximum": 9,
            "default": 0
          },
          "safety_identifier": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "service_tier": {
            "type": "string",
            "const": "default",
            "default": "default"
          },
          "output_format": {
            "type": "string",
            "enum": [
              "mp4",
              "mov"
            ],
            "default": "mp4"
          },
          "omni_reference_task_type": {
            "type": "string",
            "enum": [
              "auto",
              "reference",
              "edit",
              "extend"
            ],
            "default": "auto",
            "description": "edit and extend need a reference video."
          },
          "content_filter": {
            "type": "boolean",
            "default": true,
            "description": "TokLab extension. false turns off content filtering."
          },
          "draft": {
            "type": "boolean",
            "default": false,
            "description": "true generates a 480p draft. For final video, use one content draft_task with your successful TokLab task ID (valid 7 days), explicitly set resolution to 1080p and omit draft or set false. Do not repeat duration, ratio, seed, generate_audio, omni_reference_task_type, text or media. Each stage is billed separately; final billing inherits the original reference-video category and duration."
          }
        },
        "required": [
          "model",
          "content"
        ],
        "additionalProperties": false,
        "allOf": [
          {
            "if": {
              "required": [
                "draft"
              ],
              "properties": {
                "draft": {
                  "const": true
                }
              }
            },
            "then": {
              "properties": {
                "resolution": {
                  "const": "480p"
                }
              }
            }
          },
          {
            "if": {
              "properties": {
                "content": {
                  "contains": {
                    "required": [
                      "type"
                    ],
                    "properties": {
                      "type": {
                        "const": "draft_task"
                      }
                    }
                  }
                }
              }
            },
            "then": {
              "required": [
                "resolution"
              ],
              "properties": {
                "resolution": {
                  "const": "1080p"
                },
                "draft": {
                  "const": false
                },
                "content": {
                  "maxItems": 1
                }
              },
              "not": {
                "anyOf": [
                  {
                    "required": [
                      "duration"
                    ]
                  },
                  {
                    "required": [
                      "ratio"
                    ]
                  },
                  {
                    "required": [
                      "seed"
                    ]
                  },
                  {
                    "required": [
                      "generate_audio"
                    ]
                  },
                  {
                    "required": [
                      "omni_reference_task_type"
                    ]
                  }
                ]
              }
            }
          }
        ]
      },
      "TaskAccepted": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "dreamina-seedance-2-5"
            ]
          },
          "status": {
            "const": "processing"
          },
          "created_at": {
            "type": "integer"
          }
        }
      },
      "Task": {
        "type": "object",
        "required": [
          "id",
          "model",
          "status",
          "created_at"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "model": {
            "enum": [
              "dreamina-seedance-2-5"
            ]
          },
          "status": {
            "enum": [
              "processing",
              "completed",
              "failed"
            ]
          },
          "created_at": {
            "type": "integer"
          },
          "finished_at": {
            "type": "integer"
          },
          "output": {
            "type": "object",
            "properties": {
              "video_url": {
                "type": "string",
                "format": "uri"
              },
              "last_frame_url": {
                "type": "string",
                "format": "uri",
                "description": "Present when return_last_frame is true."
              },
              "content": {
                "type": "object",
                "description": "The same URLs in the official ModelArk shape.",
                "properties": {
                  "video_url": {
                    "type": "string",
                    "format": "uri"
                  },
                  "last_frame_url": {
                    "type": "string",
                    "format": "uri"
                  }
                }
              },
              "usage": {
                "type": "object",
                "properties": {
                  "completion_tokens": {
                    "type": "integer",
                    "description": "Video tokens of the finished video; the billed unit."
                  },
                  "total_tokens": {
                    "type": "integer"
                  }
                }
              },
              "seed": {
                "type": "integer"
              },
              "resolution": {
                "type": "string"
              },
              "ratio": {
                "type": "string"
              },
              "duration": {
                "type": "integer"
              },
              "framespersecond": {
                "type": "integer"
              },
              "generate_audio": {
                "type": "boolean"
              },
              "draft": {
                "type": "boolean"
              },
              "draft_task_id": {
                "type": "string",
                "description": "Your original TokLab draft task ID."
              },
              "output_format": {
                "type": "string"
              },
              "service_tier": {
                "type": "string"
              },
              "execution_expires_after": {
                "type": "integer"
              },
              "priority": {
                "type": "integer"
              },
              "safety_identifier": {
                "type": "string"
              }
            }
          },
          "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"
          }
        }
      }
    }
  }
}
