{
  "openapi": "3.1.0",
  "info": {
    "title": "vidgena API",
    "version": "2.0.0"
  },
  "servers": [
    {
      "url": "https://api.vidgena.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v2/image_generation": {
      "post": {
        "summary": "Create an image task",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Reuse the same key and body on retries to receive the original task.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[\\x21-\\x7e]+$"
            }
          },
          {
            "name": "X-Vidgena-Quote-Id",
            "in": "header",
            "required": false,
            "description": "An optional quote ID for the same request body.",
            "schema": {
              "$ref": "#/components/schemas/QuoteId"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGeneration"
              },
              "example": {
                "model": "image",
                "content": [
                  {
                    "type": "text",
                    "text": "A slow tracking shot of a fox at dawn."
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskIdResponse"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/video_generation": {
      "post": {
        "summary": "Create a video task",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Reuse the same key and body on retries to receive the original task.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[\\x21-\\x7e]+$"
            }
          },
          {
            "name": "X-Vidgena-Quote-Id",
            "in": "header",
            "required": false,
            "description": "An optional quote ID for the same request body.",
            "schema": {
              "$ref": "#/components/schemas/QuoteId"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoGeneration"
              },
              "example": {
                "model": "MiniMax-H3",
                "content": [
                  {
                    "type": "text",
                    "text": "A slow tracking shot of a fox at dawn."
                  }
                ],
                "duration": 5,
                "resolution": "768P",
                "ratio": "16:9"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskIdResponse"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/video_regeneration": {
      "post": {
        "summary": "Regenerate an eligible video at 2K",
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Reuse the same key and body on retries to receive the original task.",
            "schema": {
              "type": "string",
              "minLength": 1,
              "maxLength": 128,
              "pattern": "^[\\x21-\\x7e]+$"
            }
          },
          {
            "name": "X-Vidgena-Quote-Id",
            "in": "header",
            "required": false,
            "description": "An optional quote ID for the same request body.",
            "schema": {
              "$ref": "#/components/schemas/QuoteId"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/VideoRegeneration"
              },
              "example": {
                "model": "MiniMax-H3",
                "source_task_id": "job_0123456789abcdef0123456789abcdef",
                "resolution": "2K"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TaskIdResponse"
                }
              }
            },
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri-reference"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/query/image_generation/{task_id}": {
      "get": {
        "summary": "Query an image task",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TaskId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current task status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "task": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "required": [
                    "task"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/query/video_generation/{task_id}": {
      "get": {
        "summary": "Query a video or regeneration task",
        "parameters": [
          {
            "name": "task_id",
            "in": "path",
            "required": true,
            "schema": {
              "$ref": "#/components/schemas/TaskId"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Current task status.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "task": {
                      "$ref": "#/components/schemas/Task"
                    }
                  },
                  "required": [
                    "task"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/models": {
      "get": {
        "summary": "List available models, prices, and limits",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "models": {
                      "type": "array",
                      "items": {
                        "oneOf": [
                          {
                            "$ref": "#/components/schemas/ImageModel"
                          },
                          {
                            "$ref": "#/components/schemas/VideoModel"
                          }
                        ]
                      }
                    }
                  },
                  "required": [
                    "models"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/account/credits": {
      "get": {
        "summary": "Read credits",
        "responses": {
          "200": {
            "description": "Success.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "available": {
                      "type": "integer",
                      "minimum": 0
                    },
                    "held": {
                      "type": "integer",
                      "minimum": 0
                    }
                  },
                  "required": [
                    "available",
                    "held"
                  ],
                  "additionalProperties": false
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v2/quotes": {
      "post": {
        "summary": "Quote the credits required for a generation request",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/ImageGeneration"
                  },
                  {
                    "$ref": "#/components/schemas/VideoGeneration"
                  },
                  {
                    "$ref": "#/components/schemas/VideoRegeneration"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Quote created.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "default": {
            "description": "Request failed.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer"
      }
    },
    "schemas": {
      "Reference": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "description": "A publicly accessible HTTPS media URL."
          }
        },
        "required": [
          "url"
        ],
        "additionalProperties": false
      },
      "Text": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "text"
          },
          "text": {
            "type": "string",
            "minLength": 1,
            "maxLength": 16000
          }
        },
        "required": [
          "type",
          "text"
        ],
        "additionalProperties": false
      },
      "ImageReference": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "image_url"
          },
          "image_url": {
            "$ref": "#/components/schemas/Reference"
          },
          "role": {
            "type": "string",
            "const": "reference_image"
          }
        },
        "required": [
          "type",
          "image_url"
        ],
        "additionalProperties": false
      },
      "VideoImage": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "image_url"
          },
          "image_url": {
            "$ref": "#/components/schemas/Reference"
          },
          "role": {
            "type": "string",
            "enum": [
              "first_frame",
              "last_frame",
              "reference_image"
            ]
          }
        },
        "required": [
          "type",
          "image_url"
        ],
        "additionalProperties": false
      },
      "VideoReference": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "video_url"
          },
          "video_url": {
            "$ref": "#/components/schemas/Reference"
          },
          "role": {
            "type": "string",
            "const": "reference_video"
          }
        },
        "required": [
          "type",
          "video_url",
          "role"
        ],
        "additionalProperties": false
      },
      "AudioReference": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "const": "audio_url"
          },
          "audio_url": {
            "$ref": "#/components/schemas/Reference"
          },
          "role": {
            "type": "string",
            "const": "reference_audio"
          }
        },
        "required": [
          "type",
          "audio_url",
          "role"
        ],
        "additionalProperties": false
      },
      "Seed": {
        "description": "An unsigned seed. Use a decimal string above the safe integer range. The max is 10^18 for images and 2^64 − 1 for videos.",
        "oneOf": [
          {
            "type": "integer",
            "minimum": 0,
            "maximum": 9007199254740991
          },
          {
            "type": "string",
            "pattern": "^[0-9]{1,20}$"
          }
        ]
      },
      "ImageGeneration": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "image"
          },
          "content": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Text"
                },
                {
                  "$ref": "#/components/schemas/ImageReference"
                }
              ]
            },
            "minItems": 1,
            "maxItems": 2,
            "description": "Up to one text prompt and one reference image."
          },
          "options": {
            "type": "object",
            "properties": {
              "negative_prompt": {
                "type": "string",
                "maxLength": 16000
              },
              "seed": {
                "$ref": "#/components/schemas/Seed"
              }
            },
            "required": [],
            "additionalProperties": false
          }
        },
        "required": [
          "model",
          "content"
        ],
        "additionalProperties": false
      },
      "VideoGeneration": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "MiniMax-H3"
          },
          "content": {
            "type": "array",
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/Text"
                },
                {
                  "$ref": "#/components/schemas/VideoImage"
                },
                {
                  "$ref": "#/components/schemas/VideoReference"
                },
                {
                  "$ref": "#/components/schemas/AudioReference"
                }
              ]
            },
            "minItems": 1,
            "maxItems": 13,
            "description": "One prompt. Use keyframes at 768P or up to 6 image, 3 video, and 3 audio references."
          },
          "duration": {
            "type": "integer",
            "minimum": 4,
            "maximum": 15,
            "description": "Seconds. See /v2/models for enabled durations."
          },
          "resolution": {
            "type": "string",
            "enum": [
              "768P",
              "2K"
            ]
          },
          "ratio": {
            "type": "string",
            "enum": [
              "adaptive",
              "21:9",
              "16:9",
              "4:3",
              "1:1",
              "3:4",
              "9:16"
            ],
            "description": "Required for text-only generation. Keyframe aspect ratio follows the source frame."
          },
          "options": {
            "type": "object",
            "properties": {
              "seed": {
                "$ref": "#/components/schemas/Seed"
              }
            },
            "required": [],
            "additionalProperties": false
          }
        },
        "required": [
          "model",
          "content",
          "duration",
          "resolution"
        ],
        "additionalProperties": false
      },
      "VideoRegeneration": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "const": "MiniMax-H3"
          },
          "source_task_id": {
            "$ref": "#/components/schemas/TaskId"
          },
          "resolution": {
            "type": "string",
            "const": "2K"
          },
          "options": {
            "type": "object",
            "properties": {
              "seed": {
                "$ref": "#/components/schemas/Seed"
              }
            },
            "required": [],
            "additionalProperties": false
          }
        },
        "required": [
          "model",
          "source_task_id",
          "resolution"
        ],
        "additionalProperties": false
      },
      "TaskId": {
        "type": "string",
        "pattern": "^job_[a-f0-9]{32}$"
      },
      "QuoteId": {
        "type": "string",
        "pattern": "^quote_[a-f0-9]{32}$"
      },
      "TaskIdResponse": {
        "type": "object",
        "properties": {
          "task_id": {
            "$ref": "#/components/schemas/TaskId"
          }
        },
        "required": [
          "task_id"
        ],
        "additionalProperties": false
      },
      "Error": {
        "type": "object",
        "properties": {
          "code": {
            "type": "string"
          },
          "message": {
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/Error"
          },
          "request_id": {
            "type": "string"
          }
        },
        "required": [
          "error",
          "request_id"
        ],
        "additionalProperties": false
      },
      "Content": {
        "type": "object",
        "properties": {
          "url": {
            "type": "string",
            "format": "uri"
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          },
          "width": {
            "type": [
              "integer",
              "null"
            ]
          },
          "height": {
            "type": [
              "integer",
              "null"
            ]
          },
          "actual_duration": {
            "type": [
              "number",
              "null"
            ]
          },
          "refinable": {
            "type": "boolean",
            "description": "Present for video outputs. True when this output can be used for video regeneration."
          }
        },
        "required": [
          "url",
          "expires_at",
          "width",
          "height",
          "actual_duration"
        ],
        "additionalProperties": false
      },
      "Task": {
        "type": "object",
        "properties": {
          "id": {
            "$ref": "#/components/schemas/TaskId"
          },
          "model": {
            "type": "string",
            "enum": [
              "image",
              "MiniMax-H3"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "running",
              "succeeded",
              "failed",
              "cancelled"
            ]
          },
          "modality": {
            "type": "string",
            "enum": [
              "image",
              "video"
            ]
          },
          "task_type": {
            "type": "string",
            "enum": [
              "generation",
              "regeneration"
            ]
          },
          "created_at": {
            "type": "integer",
            "description": "Unix seconds."
          },
          "updated_at": {
            "type": "integer",
            "description": "Unix seconds."
          },
          "resolution": {
            "type": "string",
            "enum": [
              "768P",
              "2K"
            ]
          },
          "duration": {
            "type": "number"
          },
          "ratio": {
            "type": "string"
          },
          "content": {
            "$ref": "#/components/schemas/Content"
          },
          "error": {
            "$ref": "#/components/schemas/Error"
          },
          "credits": {
            "type": "object",
            "properties": {
              "requested": {
                "type": "integer",
                "minimum": 0
              },
              "charged": {
                "type": "integer",
                "minimum": 0
              }
            },
            "required": [
              "requested",
              "charged"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "id",
          "model",
          "status",
          "modality",
          "task_type",
          "created_at",
          "updated_at",
          "credits"
        ],
        "additionalProperties": false
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "quote_id": {
            "$ref": "#/components/schemas/QuoteId"
          },
          "credits": {
            "type": "integer",
            "minimum": 0
          },
          "units": {
            "type": "integer",
            "minimum": 1,
            "description": "One unit for an image. For video, the duration divided by the billing unit in seconds, rounded up. Regeneration uses the source task's duration."
          },
          "price_version": {
            "type": "integer",
            "minimum": 0
          },
          "expires_at": {
            "type": "string",
            "format": "date-time"
          }
        },
        "required": [
          "quote_id",
          "credits",
          "units",
          "price_version",
          "expires_at"
        ],
        "additionalProperties": false
      },
      "ReferenceLimits": {
        "type": "object",
        "properties": {
          "images": {
            "type": "integer",
            "minimum": 0
          },
          "videos": {
            "type": "integer",
            "minimum": 0
          },
          "audios": {
            "type": "integer",
            "minimum": 0
          }
        },
        "required": []
      },
      "ImageModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "const": "image"
          },
          "type": {
            "type": "string",
            "const": "image"
          },
          "credits": {
            "type": "integer",
            "minimum": 0
          },
          "reference_limits": {
            "$ref": "#/components/schemas/ReferenceLimits"
          }
        },
        "required": [
          "id",
          "type",
          "credits",
          "reference_limits"
        ],
        "additionalProperties": false
      },
      "VideoCredits": {
        "type": "object",
        "properties": {
          "768P": {
            "type": "integer",
            "minimum": 1
          },
          "2K": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "regeneration": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "768P",
          "2K",
          "regeneration"
        ],
        "additionalProperties": false
      },
      "VideoModel": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "const": "MiniMax-H3"
          },
          "type": {
            "type": "string",
            "const": "video"
          },
          "durations": {
            "type": "array",
            "items": {
              "type": "integer"
            }
          },
          "ratios": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "adaptive",
                "21:9",
                "16:9",
                "4:3",
                "1:1",
                "3:4",
                "9:16"
              ]
            }
          },
          "resolutions": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "768P",
                "2K"
              ]
            }
          },
          "reference_limits": {
            "$ref": "#/components/schemas/ReferenceLimits"
          },
          "credits": {
            "$ref": "#/components/schemas/VideoCredits",
            "description": "Credits per billing unit for each video operation. A null 2K rate indicates direct 2K generation is unavailable."
          },
          "billing_unit_seconds": {
            "type": "integer",
            "const": 5
          },
          "credits_by_duration": {
            "type": "object",
            "description": "Total credits for each supported duration, keyed by duration in seconds.",
            "additionalProperties": {
              "$ref": "#/components/schemas/VideoCredits"
            }
          }
        },
        "required": [
          "id",
          "type",
          "durations",
          "ratios",
          "resolutions",
          "reference_limits",
          "credits",
          "billing_unit_seconds",
          "credits_by_duration"
        ],
        "additionalProperties": false
      }
    }
  }
}
