{
  "openapi": "3.1.0",
  "info": {
    "title": "VoooAI Agent API",
    "version": "1.0.0",
    "summary": "Machine-readable description of the VoooAI public programmatic API for AI agents and developer integrations.",
    "description": "VoooAI (https://voooai.com) is a multi-model AI creative platform for video, image, music, digital human, comic/manga, picture book and storyboard production, orchestrated on a visual node-based workflow canvas (NL2Workflow).\n\nThis document describes the REST surface used by external AI agents and by the official VoooAI skill scripts (OpenClaw, Claude Code, Cursor, MCP): capability discovery, reference-media upload, image/video generation, task polling and cancellation, node-workflow execution, and the stateful Director Mode pipeline (Stage 1 script → Stage 2 characters & elements → Stage 3 storyboard → Stage 4 workflow/film) streamed over Server-Sent Events.\n\nAuthentication: send `Authorization: Bearer <token>` where the token is either an AccessKey (prefix `vooai_`, issued from the account page at https://voooai.com/access-keys) or a session JWT. AccessKey calls require a PAID membership: free (VIP0) accounts receive HTTP 403 with error_code `MEMBERSHIP_REQUIRED`.\n\nBilling: generation endpoints deduct points on submit. Always discover balance and engine costs via `GET /api/agent/capabilities` first, and poll tasks until `status` is `completed`, then read the media URLs (`image_url` / `video_url` / `audio_url`, `result_urls`).\n\nRecommended clients: the official skill scripts shipped with the VoooAI agent skill; they implement the upload → submit → poll → download flows and the Director `[REQUIRED_CONFIG]` gate protocol described below.",
    "contact": {
      "name": "VoooAI Support",
      "url": "https://voooai.com",
      "email": "support@voooai.com"
    }
  },
  "externalDocs": {
    "description": "VoooAI Agent API & AccessKeys guide",
    "url": "https://voooai.com/access-keys"
  },
  "servers": [
    {
      "url": "https://voooai.com",
      "description": "Production (HTTPS only)"
    }
  ],
  "tags": [
    { "name": "Discovery", "description": "Health and capability/cost discovery." },
    { "name": "Generation", "description": "Image and video generation task submission (points deducted on submit)." },
    { "name": "Tasks", "description": "Generation task polling and cancellation." },
    { "name": "Uploads", "description": "Reference media upload via COS three-step flow (request → PUT → confirm), with MD5 dedup." },
    { "name": "Workflow", "description": "Node-based workflow execution and execution status (Director film route A)." },
    { "name": "Director", "description": "Stateful multi-turn Director Mode sessions over SSE: script → characters → storyboard → film." }
  ],
  "security": [
    { "bearerAuth": [] }
  ],
  "paths": {
    "/api/health": {
      "get": {
        "tags": ["Discovery"],
        "operationId": "getHealth",
        "summary": "Service health probe",
        "description": "Unauthenticated liveness probe reporting database and engine connectivity. Useful before starting an agent session.",
        "security": [],
        "responses": {
          "200": {
            "description": "Health snapshot.",
            "content": {
              "application/json": {
                "schema": { "type": "object", "additionalProperties": true }
              }
            }
          }
        }
      }
    },
    "/api/agent/capabilities": {
      "get": {
        "tags": ["Discovery"],
        "operationId": "getAgentCapabilities",
        "summary": "Capability, constraint and cost discovery",
        "description": "Dynamically aggregated engine/skill catalog, per-engine parameter constraints, file-size limits, concurrency limits and the caller's points balance. Trust levels: AccessKey callers are `trusted_agent` (full detail incl. `cost_guide`, 60 req/min); JWT callers are `authenticated` (condensed, 20 req/min). Exceeding the limit returns 429 with `retry_after_seconds`.",
        "responses": {
          "200": {
            "description": "Capability document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "trust_level": { "type": "string", "enum": ["trusted_agent", "authenticated"] },
                    "generated_at": { "type": "string", "format": "date-time" },
                    "rate_limit": {
                      "type": "object",
                      "properties": {
                        "limit": { "type": "integer" },
                        "window_seconds": { "type": "integer" },
                        "remaining": { "type": "integer" }
                      }
                    },
                    "constraints": { "type": "object", "description": "File size limits (image 10 MB / video 200 MB / audio 15 MB), user points balance and membership level, concurrency limits." },
                    "engine_constraints": { "type": "object", "description": "Per-engine required membership level, prompt length and duration ranges." },
                    "workflow_guide": { "type": "object" },
                    "skills": { "type": "array", "items": { "type": "object" } },
                    "engines": { "type": "object" },
                    "cost_guide": { "type": "object", "description": "Present only for trusted_agent (AccessKey) callers." },
                    "data_warnings": { "type": "array", "items": { "type": "string" }, "description": "Transient data-source unavailability; retry in a few seconds." }
                  },
                  "required": ["success", "trust_level"]
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/create-task": {
      "post": {
        "tags": ["Generation"],
        "operationId": "createTask",
        "summary": "Submit an image or video generation task",
        "description": "Submits a single generation task; points are deducted on submit. Leave `engine_type` / `video_engine_type` empty to let the platform auto-select the best engine. Reference inputs are file URLs/IDs obtained from the Uploads flow. Actual output pixels are governed by aspect ratio / resolution tier / quality; `image_size` is a backward-compat hint only.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "prompt": { "type": "string", "description": "Creative description, forwarded verbatim to the platform AI." },
                  "task_type": { "type": "string", "enum": ["image", "video"] },
                  "negative_prompt": { "type": "string" },
                  "aspect_ratio": { "type": "string", "description": "Image aspect ratio, e.g. 16:9, 3:4, 1:1." },
                  "resolution_tier": { "type": "string" },
                  "quality": { "type": "string", "enum": ["low", "medium", "high"] },
                  "style": { "type": "string" },
                  "model_type": { "type": "string" },
                  "engine_type": { "type": "string", "description": "Image engine id; empty = platform Auto routing." },
                  "image_size": { "type": "string", "description": "Backward-compat hint (e.g. 1024x1024); some engines ignore it." },
                  "reference_image_ids": { "description": "Reference image file URLs/IDs from /api/cos upload (image-to-image, first frame)." },
                  "video_aspect_ratio": { "type": "string" },
                  "video_duration": { "type": "number", "description": "Video length in seconds (engine-dependent range)." },
                  "video_size": { "type": "string", "enum": ["480p", "720p", "1080p"] },
                  "video_engine_type": { "type": "string", "description": "Video engine id; empty = platform Auto routing." },
                  "generation_type": { "type": "string", "enum": ["TEXT", "FIRST&LAST", "REFERENCE"] },
                  "reference_video_ids": { "description": "Reference video file URLs/IDs." },
                  "reference_audio_ids": { "description": "Reference audio file URLs/IDs." }
                },
                "required": ["prompt", "task_type"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Task accepted; poll GET /api/tasks/{task_id}.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "task_id": { "type": "string" }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/api/tasks/{task_id}": {
      "get": {
        "tags": ["Tasks"],
        "operationId": "getTask",
        "summary": "Poll a generation task",
        "description": "Returns task status and result media. Alias path: /api/tasks/{task_id}/status. Poll every 5 s (images up to 300 s, videos up to 600 s). On `completed` read `image_url` / `video_url` / `audio_url`; on `failed` read `error_message`.",
        "parameters": [
          { "$ref": "#/components/parameters/TaskId" }
        ],
        "responses": {
          "200": {
            "description": "Task snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "task_id": { "type": "string" },
                    "status": { "type": "string", "description": "e.g. pending / processing / completed / failed." },
                    "image_url": { "type": "string" },
                    "video_url": { "type": "string" },
                    "audio_url": { "type": "string" },
                    "error_message": { "type": "string" }
                  },
                  "additionalProperties": true
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/tasks/{task_id}/cancel": {
      "patch": {
        "tags": ["Tasks"],
        "operationId": "cancelTask",
        "summary": "Cancel a running generation task",
        "parameters": [
          { "$ref": "#/components/parameters/TaskId" }
        ],
        "responses": {
          "200": {
            "description": "Cancellation result.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessEnvelope" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/cos/request-upload": {
      "post": {
        "tags": ["Uploads"],
        "operationId": "requestUpload",
        "summary": "Step 1: request a COS upload credential",
        "description": "Returns `data.file_id` and a pre-signed `data.upload_url` for a direct HTTPS PUT of the file bytes. MD5 dedup: when `data.status` is `exists`, skip the PUT and fetch the existing URL via GET /api/cos/download-url/{file_id}. Limits: image 10 MB, video 200 MB, audio 15 MB. Supported: jpg/png/webp/gif/svg/bmp, mp4/mov/avi/mkv/webm, mp3/wav/flac/m4a/ogg.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "filename": { "type": "string" },
                  "file_size": { "type": "integer", "description": "Bytes." },
                  "file_md5": { "type": "string", "description": "Hex MD5 of the file content (dedup key)." }
                },
                "required": ["filename", "file_size", "file_md5"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Upload credential.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "file_id": { "type": "string" },
                        "upload_url": { "type": "string", "format": "uri" },
                        "status": { "type": "string", "description": "`exists` when MD5 dedup hit." }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" }
        }
      }
    },
    "/api/cos/confirm-upload": {
      "post": {
        "tags": ["Uploads"],
        "operationId": "confirmUpload",
        "summary": "Step 3: confirm a completed COS PUT",
        "description": "Call after the direct PUT to `upload_url` succeeded (HTTP 200/201/204). Marks the file ready so its URL can be used as a generation reference input.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "file_id": { "type": "string" }
                },
                "required": ["file_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Confirmation result.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessEnvelope" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/cos/download-url/{file_id}": {
      "get": {
        "tags": ["Uploads"],
        "operationId": "getDownloadUrl",
        "summary": "Resolve a CDN download URL for an uploaded file",
        "parameters": [
          { "$ref": "#/components/parameters/FileId" }
        ],
        "responses": {
          "200": {
            "description": "Download URL.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "data": {
                      "type": "object",
                      "properties": {
                        "download_url": { "type": "string", "format": "uri" }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/node-builder/execute": {
      "post": {
        "tags": ["Workflow"],
        "operationId": "executeWorkflow",
        "summary": "Execute a node workflow (Director film route A)",
        "description": "Executes a workflow graph of engine nodes. Director sessions export a compatible graph via GET /api/director/v2/{session_id}/export-workflow (normalize ReactFlow `edges` into `connections`). Returns an `execution_id` to poll.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workflow": {
                    "type": "object",
                    "properties": {
                      "nodes": { "type": "array", "items": { "type": "object" } },
                      "connections": { "type": "array", "items": { "type": "object" } }
                    },
                    "required": ["nodes"]
                  }
                },
                "required": ["workflow"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Execution accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "execution_id": { "type": "string" },
                    "status": { "type": "string" },
                    "message": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" }
        }
      }
    },
    "/api/node-builder/execute_single_node": {
      "post": {
        "tags": ["Workflow"],
        "operationId": "executeSingleNode",
        "summary": "Execute (or retry) one node of a workflow",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "workflow": { "type": "object" },
                  "node_id": { "type": "string" }
                },
                "required": ["workflow", "node_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Single-node execution result.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessEnvelope" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/node-builder/execution/{execution_id}": {
      "get": {
        "tags": ["Workflow"],
        "operationId": "getExecution",
        "summary": "Poll a workflow execution",
        "description": "Poll every 10 s (default timeout 300 s). On `completed` read `result_urls` / per-node outputs; on `failed` inspect `failed_nodes` and `node_statuses`, then retry with execute_single_node.",
        "parameters": [
          { "$ref": "#/components/parameters/ExecutionId" }
        ],
        "responses": {
          "200": {
            "description": "Execution snapshot.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "execution_id": { "type": "string" },
                    "status": { "type": "string", "enum": ["pending", "running", "completed", "failed"] },
                    "progress": {},
                    "result_urls": { "type": "array", "items": { "type": "string", "format": "uri" } },
                    "node_statuses": { "type": "object" },
                    "failed_nodes": { "type": "array", "items": {} }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/director/v2/start": {
      "post": {
        "tags": ["Director"],
        "operationId": "directorStart",
        "summary": "Start a Director Mode session (SSE)",
        "description": "Opens a stateful creative session; the platform AI drives Stage 1 (script). Response is a Server-Sent Events stream: `session_start` (carries session_id + tab_id), `token`, `action`, `summary`, `required_config`, `done`. When the global config gate fires, a `required_config` event is emitted instead of generation (the turn is still billed): present `questions[]` to the user verbatim, then reply via chat with content `[REQUIRED_CONFIG]{\"config\":{...},\"original_message\":\"...\"}` using `original_message` from the event. `auto_generate=false` (recommended for agents) requires per-stage confirmation before points are spent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "description": { "type": "string", "description": "Creative brief, forwarded verbatim (length-capped)." },
                  "auto_generate": { "type": "boolean", "description": "Default true; agents should pass false for per-stage confirmation." },
                  "engine_type": { "type": "string", "description": "LLM engine override; omit for platform default." },
                  "tab_id": { "type": "string", "description": "Optional tab isolation id." },
                  "locale": { "type": "string", "description": "UI locale for localized backend strings, e.g. en / zh." }
                },
                "required": ["description"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SSE stream of the first creative turn.",
            "content": {
              "text/event-stream": {
                "schema": { "type": "string" },
                "examples": {
                  "sessionStart": { "value": "event: session_start\ndata: {\"session_id\": \"...\", \"tab_id\": \"...\"}\n\n" }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" }
        }
      }
    },
    "/api/director/v2/{session_id}/chat": {
      "post": {
        "tags": ["Director"],
        "operationId": "directorChat",
        "summary": "Advance a Director session conversationally (SSE)",
        "description": "Sends one user turn; the AI performs orchestration actions (add character, add storyboard, generate reference images, stage updates) and streams `token` / `action` / `summary` / `required_config` / `done` events. Also accepts the `[REQUIRED_CONFIG]{...}` instruction string verbatim as `content` to answer the global-config gate.",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" },
          { "$ref": "#/components/parameters/TabId" }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "content": { "type": "string" },
                  "tab_id": { "type": "string" }
                },
                "required": ["content"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "SSE stream of the turn.",
            "content": {
              "text/event-stream": { "schema": { "type": "string" } }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    },
    "/api/director/v2/{session_id}/status": {
      "get": {
        "tags": ["Director"],
        "operationId": "directorStatus",
        "summary": "Session stage status and per-stage data",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" },
          { "$ref": "#/components/parameters/TabId" }
        ],
        "responses": {
          "200": {
            "description": "Stage snapshot (stage 1 script, 2 characters & elements, 3 storyboard, 4 workflow/film).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "session_id": { "type": "string" },
                    "tab_id": { "type": "string" },
                    "status": { "type": "string", "description": "active / inactive (inactive = metadata lost, e.g. after server restart)." },
                    "current_stage": { "type": "integer" },
                    "auto_generate": { "type": "boolean" },
                    "stage_data": { "type": "object", "description": "Per-stage payloads keyed by stage number." },
                    "stage_statuses": { "type": "object", "description": "Per-stage status keyed by stage number, e.g. pending_confirmation." }
                  }
                }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/director/v2/{session_id}/full_state": {
      "get": {
        "tags": ["Director"],
        "operationId": "directorFullState",
        "summary": "Full session state (script, characters, storyboards, workflow)",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" },
          { "$ref": "#/components/parameters/TabId" }
        ],
        "responses": {
          "200": {
            "description": "Complete stage payloads for inspection.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessEnvelope" }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/director/v2/{session_id}/navigate": {
      "post": {
        "tags": ["Director"],
        "operationId": "directorNavigate",
        "summary": "Confirm a stage and advance (deterministic, no LLM points)",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "action": { "type": "string", "enum": ["confirm"] },
                  "stage": { "type": "integer", "description": "Stage number being confirmed (1-3)." },
                  "tab_id": { "type": "string" }
                },
                "required": ["action", "stage"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Navigation result; when next_action=auto_init, trigger next-stage generation via chat (may spend points).",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "session_id": { "type": "string" },
                    "confirmed_stage": { "type": "integer" },
                    "next_stage": { "type": "integer" },
                    "next_action": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/director/v2/{session_id}/modification/confirm": {
      "post": {
        "tags": ["Director"],
        "operationId": "directorConfirmModification",
        "summary": "Confirm an AI modification proposal",
        "description": "`proposal_id` (mp_…) is emitted inside chat replies; confirming applies the proposed modification.",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "proposal_id": { "type": "string" },
                  "tab_id": { "type": "string" }
                },
                "required": ["proposal_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Applied modification summary.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "strategy": { "type": "string" },
                    "modified_stages": { "type": "array", "items": { "type": "integer" } },
                    "summary": { "type": "string" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/director/v2/{session_id}/export-workflow": {
      "get": {
        "tags": ["Director"],
        "operationId": "directorExportWorkflow",
        "summary": "Export the session as an executable workflow (film route A)",
        "description": "Requires Stage 3 storyboard design to be complete, otherwise HTTP 400 `Stage 3 storyboard data is empty` (business gate — advance the stage instead of retrying). Returns `{nodes, edges}`; normalize ReactFlow edges into node-builder `connections` before POST /api/node-builder/execute.",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" },
          { "$ref": "#/components/parameters/TabId" }
        ],
        "responses": {
          "200": {
            "description": "Exported workflow graph.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": { "type": "boolean" },
                    "workflow": {
                      "type": "object",
                      "properties": {
                        "nodes": { "type": "array", "items": { "type": "object" } },
                        "edges": { "type": "array", "items": { "type": "object" } }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" }
        }
      }
    },
    "/api/director/v2/{session_id}/execute_storyboard_video": {
      "post": {
        "tags": ["Director"],
        "operationId": "directorExecuteStoryboardVideo",
        "summary": "Render one storyboard shot to video (film route B)",
        "description": "Creates a video generation task for the given storyboard; results flow through the task system — poll GET /api/tasks/{task_id} and download from there.",
        "parameters": [
          { "$ref": "#/components/parameters/SessionId" }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "storyboard_id": { "type": "string" },
                  "engine": { "type": "string", "description": "Optional video engine override." },
                  "prompt": { "type": "string", "description": "Optional prompt override." },
                  "output_format": { "type": "string" },
                  "draft_finalize": { "type": "boolean" },
                  "draft_task_id": { "type": "string" }
                },
                "required": ["storyboard_id"]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Video task created; poll /api/tasks/{task_id}.",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SuccessEnvelope" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/MembershipRequired" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "AccessKey (vooai_ prefix) or session JWT",
        "description": "Authorization: Bearer <token>. AccessKeys are issued at https://voooai.com/access-keys and require a paid membership; free VIP0 keys are rejected with 403 MEMBERSHIP_REQUIRED. Never hardcode keys; the official skill reads them from VOOOAI_ACCESS_KEY."
      }
    },
    "parameters": {
      "TaskId": {
        "name": "task_id",
        "in": "path",
        "required": true,
        "schema": { "type": "string" },
        "description": "Generation task id returned by POST /api/create-task."
      },
      "SessionId": {
        "name": "session_id",
        "in": "path",
        "required": true,
        "schema": { "type": "string" },
        "description": "Director session id from the session_start SSE event."
      },
      "ExecutionId": {
        "name": "execution_id",
        "in": "path",
        "required": true,
        "schema": { "type": "string" },
        "description": "Workflow execution id returned by POST /api/node-builder/execute."
      },
      "FileId": {
        "name": "file_id",
        "in": "path",
        "required": true,
        "schema": { "type": "string" },
        "description": "Uploaded file id from /api/cos/request-upload."
      },
      "TabId": {
        "name": "tab_id",
        "in": "query",
        "required": false,
        "schema": { "type": "string" },
        "description": "Optional tab isolation id used when the session was started."
      }
    },
    "schemas": {
      "SuccessEnvelope": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean" }
        },
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "properties": {
          "success": { "type": "boolean", "enum": [false] },
          "error_code": { "type": "string", "description": "e.g. MEMBERSHIP_REQUIRED, INSUFFICIENT_POINTS, RATE_LIMIT_EXCEEDED, DUPLICATE_REQUEST, ENGINE_TIMEOUT, CONTENT_MODERATION_FAILED, ENGINE_UNAVAILABLE." },
          "message": { "type": "string" },
          "error": { "type": "string" }
        },
        "required": ["success"]
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid parameters or business gate (e.g. missing description, Stage 3 storyboard empty).",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      },
      "Unauthorized": {
        "description": "Missing/invalid/expired bearer token or AccessKey.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      },
      "MembershipRequired": {
        "description": "AccessKey caller is a free VIP0 account (MEMBERSHIP_REQUIRED), or insufficient points (INSUFFICIENT_POINTS). Upgrade at https://voooai.com/subscription.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      },
      "NotFound": {
        "description": "Unknown task / session / execution / file id.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      },
      "RateLimited": {
        "description": "Rate limit or concurrency exceeded; retry after retry_after_seconds.",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/Error" } }
        }
      }
    }
  }
}