Skip to content

Invoke is a leading creative engine that uses image and video generation models to empower professionals, artists, and enthusiasts to generate and create visual media using the latest AI-driven technologies. The solution offers an industry-leading application interface, and serves as the foundation for multiple commercial products.

feat(api): add an external video recall API

Lincoln Steind205ac8bfa3d
diff --git a/docs/src/content/docs/development/Architecture/media-metadata.mdx b/docs/src/content/docs/development/Architecture/media-metadata.mdx
index 63fbf494ff..66b633f7a4 100644
--- a/docs/src/content/docs/development/Architecture/media-metadata.mdx
+++ b/docs/src/content/docs/development/Architecture/media-metadata.mdx
@@ -128,6 +128,9 @@ graph builders write only the canonical ones.
- **Workflow and graph** load into the editor on any install, subject to the same model and
media resolution.
+The [Video Recall API](/development/guides/video-recall-api/) takes its parameters under these
+same key names from an external process, with models given by name.
+
## Evolving the record
1. Add a typed `Optional` field to `CoreMetadataInvocation` under its canonical name, stamp it from
diff --git a/docs/src/content/docs/development/Guides/recall-api.mdx b/docs/src/content/docs/development/Guides/recall-api.mdx
index bbf5e38bc2..7bbfed8673 100644
--- a/docs/src/content/docs/development/Guides/recall-api.mdx
+++ b/docs/src/content/docs/development/Guides/recall-api.mdx
@@ -4,6 +4,10 @@ title: Recall Parameters API
## Overview
+:::tip
+For the Video panel, see the [Video Recall API](/development/guides/video-recall-api/).
+:::
+
The Recall Parameters API is a REST endpoint on the InvokeAI backend that
lets external processes set recallable generation parameters on the
frontend. Supported parameters include:
@@ -37,10 +41,12 @@ Typical use cases:
3. **Resolution** — models are resolved from human-readable names to the
internal model keys used by the frontend, and image filenames are
validated against `{INVOKEAI_ROOT}/outputs/images`.
-4. **Broadcast** — a `recall_parameters_updated` event is emitted on the
- websocket room for `queue_id`.
-5. **Frontend update** — any connected client subscribed to that queue
- applies the update to its generation settings, so UI fields, LoRAs,
+4. **Broadcast** — a `recall_parameters_updated` event is emitted, once, to
+ the calling user's room and the administrators' room. webv2 ignores events
+ addressed to another user; the legacy frontend applies them, so an
+ administrator using it also receives other users' recalls.
+5. **Frontend update** — the calling user's connected clients
+ apply the update to their generation settings, so UI fields, LoRAs,
reference images and (in the legacy frontend) control layers populate
immediately. See [Frontend behavior](#frontend-behavior) for what each
frontend applies.
@@ -467,8 +473,9 @@ fetch(API_URL, {
## WebSocket Events
-Parameter updates emit a `recall_parameters_updated` event to the queue
-room. Connected frontend clients automatically:
+Parameter updates emit a `recall_parameters_updated` event to the calling
+user's room and the administrators' room. The calling user's connected frontend
+clients automatically:
1. Apply standard parameters (prompts, steps, dimensions, etc.).
2. Load and add LoRAs to the LoRA list.
diff --git a/docs/src/content/docs/development/Guides/video-recall-api.mdx b/docs/src/content/docs/development/Guides/video-recall-api.mdx
new file mode 100644
index 0000000000..a821f6820f
--- /dev/null
+++ b/docs/src/content/docs/development/Guides/video-recall-api.mdx
@@ -0,0 +1,256 @@
+---
+title: Video Recall API
+description: REST endpoints that let an external process recall or remix video generation parameters and place gallery or uploaded videos into a user's Video panel.
+---
+
+## Overview
+
+The Video Recall API is the video counterpart of the
+[Recall Parameters API](/development/guides/recall-api/). It lets an external process — a media
+browser, a script, another application — drive a user's open **Video** panel:
+
+- **Recall / Remix** — apply video generation parameters (prompts, model and
+ components, frames, steps, guidance, LoRAs, first/last frames, initial video,
+ Ref2VA references). Remix applies everything except the seed.
+- **Send Video** — place a video in the panel's **Initial Video** slot, the same
+ outcome as the gallery's *Extend in Video* action.
+- **Use as Ref Video** — append a video to the reference list of models that take
+ reference videos (today, MiniMax H3 Ref2VA).
+
+Send Video and Use as Ref Video take either the name of a video already in the
+gallery or a video file, which is uploaded into the gallery first.
+
+## How it works
+
+1. **Request** — the client POSTs to one of the endpoints below.
+2. **Validation and resolution** — model names are resolved to installed models,
+ gallery media is checked for existence and read access, and uploads are
+ ingested exactly as `POST /api/v1/videos/upload` ingests them.
+3. **Event** — the backend emits one `video_recall_requested` socket event to the
+ calling user's own room. Other users, including administrators, do not receive
+ it.
+4. **Frontend** — the user's open frontends apply the event to the Video panel.
+
+:::note
+The webv2 handler for `video_recall_requested` ships separately from these
+endpoints. Until it is present, the endpoints validate, upload and emit, but no
+client acts on the event.
+:::
+
+## Endpoints
+
+| Endpoint | Body | Action |
+|---|---|---|
+| `POST /api/v1/recall/video/{queue_id}` | JSON parameters | Recall / Remix |
+| `POST /api/v1/recall/video/{queue_id}/initial-video?video_name=…` | none | Send a gallery video |
+| `POST /api/v1/recall/video/{queue_id}/initial-video/upload` | multipart `file` | Upload, then send |
+| `POST /api/v1/recall/video/{queue_id}/reference-video?video_name=…` | none | Use a gallery video as a reference |
+| `POST /api/v1/recall/video/{queue_id}/reference-video/upload` | multipart `file` | Upload, then use as a reference |
+
+`queue_id` is the frontend's queue, normally `default`.
+
+### Recall / Remix
+
+`POST /api/v1/recall/video/{queue_id}`
+
+| Query parameter | Default | Meaning |
+|---|---|---|
+| `mode` | `recall` | `recall` sends every field; `remix` never sends `seed`, so the panel's own seed stands |
+| `strict` | `false` | Forwarded to the frontend. `false` asks it to change only the fields you send; `true` asks it to treat the body as a whole generation record, clearing LoRAs and media you do not send. |
+
+Fields naming a model or medium that cannot be used are dropped and listed in the
+response's `skipped`; the rest are sent. So are trim bounds or a conditioning role
+whose medium was dropped. A LoRA or reference list whose every entry was dropped
+is left out entirely rather than sent empty, so it cannot clear the panel's list.
+Unknown fields, and values outside the bounds below, are rejected with `422`.
+
+### Send Video and Use as Ref Video
+
+The name-only routes take `video_name` as a query parameter; the video must be in
+the gallery and readable by the caller.
+
+The `/upload` routes take a `multipart/form-data` body with the same shape as
+`POST /api/v1/videos/upload`: a `file` part and an optional `metadata` part (a
+stringified JSON object). The file is ingested into the gallery — converted when
+it is not already a browser-safe MP4, with any metadata embedded in an
+InvokeAI-produced MP4 preserved — and announced to open galleries before it is
+placed. They accept an optional `board_id` query parameter (the default is
+Uncategorized); uploading to a board requires permission to add media to it. They
+share the upload route's size limit and concurrency slots, so a busy server can
+answer `429` with a `Retry-After` header.
+
+Whether the video is usable depends on the model selected in the panel: an
+initial video needs a model that can extend a clip, and a reference video needs
+a model that takes reference videos.
+
+## Request schema
+
+Field names are the keys of the video metadata record described in
+[Media Metadata](/development/architecture/media-metadata/). The request is not a
+record, though: models are given by name, LoRAs as `model_name`, and record-only
+keys such as `generation_mode`, `metadata_version` or `app_version` are rejected.
+Every field is optional.
+
+### Scalars
+
+| Field | Type | Notes |
+|---|---|---|
+| `positive_prompt` | string | |
+| `negative_prompt` | string or `null` | An explicit `null` turns the negative prompt off |
+| `seed` | integer, 0 – 4294967295 | Never sent when `mode=remix` |
+| `num_frames` | integer ≥ 1 | |
+| `fps` | integer, 1 – 120 | |
+| `width`, `height` | integer ≥ 1 | |
+| `steps` | integer ≥ 1 | |
+| `cfg_scale` | number ≥ 1 | |
+| `wan_guidance_scale_low_noise` | number ≥ 1 | Wan A14B low-noise expert |
+| `ltx2_audio_cfg_scale`, `ltx2_modality_scale` | number ≥ 1 | LTX-2 guidance |
+| `ltx2_stg_scale` | number ≥ 0 | LTX-2 spatiotemporal guidance |
+| `ltx2_context_frames` | integer ≥ 1 | LTX-2 extension context |
+| `minimax_h3_hybrid_start_block` | integer ≥ 0 | MiniMax H3 Ref2VA hybrid |
+
+### Models
+
+Each model field takes an installed model's **key** or **name** (1–255
+characters). Only a model of the slot's type and family fills a slot: a name
+shared with models of other families resolves to the one that fits, and a model
+from the wrong family is skipped.
+
+| Field | Model type | Family |
+|---|---|---|
+| `model` | main | Wan, MiniMax H3 or LTX-2 |
+| `vae` | VAE | Wan |
+| `wan_t5_encoder_model` | Wan UMT5 encoder | any |
+| `wan_transformer_low_noise`, `wan_component_source` | main | Wan |
+| `minimax_h3_transformer_model`, `minimax_h3_component_source`, `minimax_h3_hybrid_base_model` | main | MiniMax H3 |
+| `minimax_h3_text_encoder_model` | Qwen3-VL encoder | MiniMax H3 |
+| `ltx2_component_source` | main | LTX-2 |
+| `ltx2_text_encoder_model` | Gemma-4 encoder | LTX-2 |
+| `loras` | up to 32 of `{ "model_name": str, "weight": number = 1.0 }` | Wan, MiniMax H3 or LTX-2 |
+
+An empty `loras` list asks for no LoRAs.
+
+### Media
+
+Media is named by its gallery name.
+
+| Field | Shape |
+|---|---|
+| `first_frame_image`, `last_frame_image` | `{ "image_name": str }` |
+| `source_video` | `{ "video_name": str }` — the initial video |
+| `source_video_start_frame`, `source_video_end_frame` | integers, both or neither, start ≤ end; inclusive trim of `source_video` |
+| `ltx2_conditioning_video` | `{ "video_name": str }`; requires `ltx2_conditioning_role` |
+| `ltx2_conditioning_role` | `"audio"` or `"video"`; requires `ltx2_conditioning_video` |
+| `minimax_h3_references` | in conditioning order, up to 3 of `{ "kind": "video", "video_name": str, "conditioning"?: "video_audio" \| "video" \| "audio", "start_frame"?: int, "end_frame"?: int }` (trim bounds both or neither) and up to 9 of `{ "kind": "image", "image_name": str, "detail"?: "max" \| "match" }`. An empty list asks for no references. |
+
+Referencing media the caller may not read is refused with `403`.
+
+## Examples
+
+### cURL
+
+```bash
+# Recall a Wan setup
+curl -X POST http://localhost:9090/api/v1/recall/video/default \
+ -H "Content-Type: application/json" \
+ -d '{
+ "positive_prompt": "a heron takes flight over a misty lake",
+ "model": "Wan 2.2 I2V A14B",
+ "num_frames": 81,
+ "steps": 30,
+ "seed": 1234,
+ "loras": [{"model_name": "Wan Lightning High Noise", "weight": 1.0}],
+ "first_frame_image": {"image_name": "0b6f…png"}
+ }'
+
+# Remix: the seed is never sent
+curl -X POST "http://localhost:9090/api/v1/recall/video/default?mode=remix" \
+ -H "Content-Type: application/json" \
+ -d '{"positive_prompt": "a heron lands on a misty lake", "model": "Wan 2.2 I2V A14B"}'
+
+# Send a gallery video to Initial Video
+curl -X POST "http://localhost:9090/api/v1/recall/video/default/initial-video?video_name=4c1e….mp4"
+
+# Upload a clip onto a board and use it as a Ref2VA reference
+curl -X POST "http://localhost:9090/api/v1/recall/video/default/reference-video/upload?board_id=<board-id>" \
+```
+
+In multi-user mode, add `-H "Authorization: Bearer <token>"`.
+
+### Python
+
+```python
+import requests
+
+BASE = "http://localhost:9090/api/v1/recall/video/default"
+
+response = requests.post(BASE, json={"positive_prompt": "neon city at night", "model": "LTX-2.3 Distilled"})
+print(response.json()["skipped"])
+
+with open("dance.mp4", "rb") as clip:
+ response = requests.post(f"{BASE}/reference-video/upload", files={"file": ("dance.mp4", clip, "video/mp4")})
+print(response.json()["video"]["video_name"])
+```
+
+## Responses
+
+Recall / Remix:
+
+```json
+{
+ "status": "success",
+ "queue_id": "default",
+ "parameters": { "positive_prompt": "…", "model": { "key": "…", "hash": "…", "name": "…", "base": "wan", "type": "main" } },
+ "skipped": ["loras[1]"]
+}
+```
+
+`status` is `no_parameters_provided` for an empty body and `nothing_resolved`
+when every field was dropped; no event is emitted in either case. `parameters` is
+exactly what the frontend receives.
+
+Send Video / Use as Ref Video:
+
+```json
+{ "status": "success", "queue_id": "default", "action": "reference_video", "video": { "video_name": "…", "…": "…" }, "uploaded": true }
+```
+
+`video` is the gallery video's full record.
+
+## Errors
+
+| Status | Cause |
+|---|---|
+| `401` | Multi-user mode without a valid token |
+| `400` | The upload ended before its body was complete |
+| `403` | The caller may not read a referenced image or video, or may not add media to `board_id` |
+| `404` | `video_name` (Send Video / Use as Ref Video) is not in the gallery, or `board_id` does not exist |
+| `409` | Image storage maintenance is running (Recall / Remix) |
+| `413` | The upload exceeds the video upload size limit |
+| `415` | The upload is not a supported video or audio file, or could not be converted |
+| `422` | Malformed JSON or multipart body, an unknown field, a value out of bounds, or `metadata` that is not a JSON object |
+| `429` | Too many concurrent video uploads |
+| `500` | The uploaded video could not be stored |
+
+## WebSocket event
+
+`video_recall_requested`, delivered once to the calling user's room:
+
+| Field | Type | Meaning |
+|---|---|---|
+| `queue_id` | string | From the request path |
+| `user_id` | string | The caller |
+| `action` | `"parameters"` \| `"initial_video"` \| `"reference_video"` | What to do |
+| `mode` | `"recall"` \| `"remix"` \| null | `parameters` only |
+| `strict` | boolean | `parameters` only |
+| `parameters` | object \| null | `parameters` only: the resolved fields, with models as `{key, hash, name, base, type}` |
+| `video` | object \| null | Placements only: `{video_name, width, height, duration, fps, media_origin}` |
+
+## Implementation
+
+- Router: `invokeai/app/api/routers/video_recall.py`
+- Upload ingest shared with `/videos/upload`: `ingest_uploaded_video` in `invokeai/app/api/routers/videos.py`
+- Upload limits: `VideoUploadLimitASGIMiddleware` in `invokeai/app/api_app.py`
+- Event: `VideoRecallRequestedEvent` in `invokeai/app/services/events/events_common.py`; routing in `invokeai/app/api/sockets.py`
+- Tests: `tests/app/routers/test_video_recall.py`
diff --git a/invokeai/app/api/routers/video_recall.py b/invokeai/app/api/routers/video_recall.py
new file mode 100644
index 0000000000..37d36770f7
--- /dev/null
+++ b/invokeai/app/api/routers/video_recall.py
@@ -0,0 +1,502 @@
+"""Router for pushing video generation parameters and media into a user's Video panel.
+
+The video counterpart of `recall_parameters.py`. Parameters are validated and resolved here, then
+delivered to the owner's open frontends as one `video_recall_requested` event; the frontend owns
+how they land in the panel.
+"""
+
+from typing import Annotated, Any, Literal, Optional, Union
+
+from fastapi import Body, HTTPException, Path, Query, Request
+from fastapi.routing import APIRouter
+from pydantic import BaseModel, ConfigDict, Field, StringConstraints, model_validator
+
+from invokeai.app.api.auth_dependencies import CurrentUserOrDefault
+from invokeai.app.api.dependencies import ApiDependencies
+from invokeai.app.api.routers._access import assert_image_read_access, assert_video_read_access
+from invokeai.app.api.routers.image_move_maintenance import assert_image_move_maintenance_inactive
+from invokeai.app.api.routers.videos import VIDEO_UPLOAD_OPENAPI_EXTRA, ingest_uploaded_video
+from invokeai.app.services.events.events_common import VideoRecallAction, VideoRecallMode, VideoRecallVideo
+from invokeai.app.services.image_records.image_records_common import ImageCategory
+from invokeai.app.services.model_records.model_records_base import UnknownModelException
+from invokeai.app.services.video_records.video_records_common import VideoRecordNotFoundException
+from invokeai.app.services.videos.videos_common import VideoDTO
+from invokeai.app.util.misc import SEED_MAX
+from invokeai.backend.model_manager.configs.factory import AnyModelConfig
+from invokeai.backend.model_manager.taxonomy import BaseModelType, ModelType
+
+video_recall_router = APIRouter(prefix="/v1/recall/video", tags=["recall"])
+
+VIDEO_BASES = frozenset({BaseModelType.Wan, BaseModelType.MiniMaxH3, BaseModelType.LTX2})
+
+# Each model slot's type and the bases the Video panel accepts in it (None: any base, for encoders
+# installed as base-agnostic). Keys are the video metadata record's own names, so the frontend reads
+# the resolved payload exactly as it reads a recorded one. The frontend applies recalled components
+# without re-checking them, so a slot must never be handed a model from another family.
+MODEL_SLOTS: dict[str, tuple[ModelType, Optional[frozenset[BaseModelType]]]] = {
+ "model": (ModelType.Main, VIDEO_BASES),
+ "vae": (ModelType.VAE, frozenset({BaseModelType.Wan})),
+ "wan_t5_encoder_model": (ModelType.WanT5Encoder, None),
+ "wan_transformer_low_noise": (ModelType.Main, frozenset({BaseModelType.Wan})),
+ "wan_component_source": (ModelType.Main, frozenset({BaseModelType.Wan})),
+ "minimax_h3_transformer_model": (ModelType.Main, frozenset({BaseModelType.MiniMaxH3})),
+ "minimax_h3_component_source": (ModelType.Main, frozenset({BaseModelType.MiniMaxH3})),
+ "minimax_h3_text_encoder_model": (ModelType.Qwen3VLEncoder, frozenset({BaseModelType.MiniMaxH3})),
+ "minimax_h3_hybrid_base_model": (ModelType.Main, frozenset({BaseModelType.MiniMaxH3})),
+ "ltx2_component_source": (ModelType.Main, frozenset({BaseModelType.LTX2})),
+ "ltx2_text_encoder_model": (ModelType.Gemma4Encoder, frozenset({BaseModelType.LTX2})),
+}
+
+# The frontend's caps on Ref2VA references.
+MAX_REFERENCE_VIDEOS = 3
+MAX_REFERENCE_IMAGES = 9
+MAX_LORAS = 32
+
+ModelName = Annotated[str, StringConstraints(min_length=1, max_length=255)]
+MediaName = Annotated[str, StringConstraints(min_length=1, max_length=255)]
+
+
+def _check_trim(start: Optional[int], end: Optional[int], what: str) -> None:
+ if (start is None) != (end is None):
+ raise ValueError(f"{what}: give both the start and end frame, or neither")
+ if start is not None and end is not None and start > end:
+ raise ValueError(f"{what}: the start frame is after the end frame")
+
+
+class VideoLoRARecallParameter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ model_name: ModelName = Field(description="The name (or key) of the LoRA model")
+ weight: float = Field(default=1.0, ge=-10, le=10, description="The weight for the LoRA")
+
+
+class ImageRefParameter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ image_name: MediaName = Field(description="The name of a gallery image")
+
+
+class VideoRefParameter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ video_name: MediaName = Field(description="The name of a gallery video")
+
+
+class ImageReferenceParameter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ kind: Literal["image"]
+ image_name: MediaName = Field(description="The name of a gallery image")
+ detail: Optional[Literal["max", "match"]] = Field(default=None, description="The reference image's detail mode")
+
+
+class VideoReferenceParameter(BaseModel):
+ model_config = ConfigDict(extra="forbid")
+
+ kind: Literal["video"]
+ video_name: MediaName = Field(description="The name of a gallery video")
+ conditioning: Optional[Literal["video_audio", "video", "audio"]] = Field(
+ default=None, description="Which of the clip's streams condition the generation"
+ )
+ start_frame: Optional[int] = Field(default=None, ge=0, description="First frame of the clip to use (inclusive)")
+ end_frame: Optional[int] = Field(default=None, ge=0, description="Last frame of the clip to use (inclusive)")
+
+ @model_validator(mode="after")
+ def _trim_is_whole(self) -> "VideoReferenceParameter":
+ _check_trim(self.start_frame, self.end_frame, "reference video trim")
+ return self
+
+
+ReferenceParameter = Annotated[Union[ImageReferenceParameter, VideoReferenceParameter], Field(discriminator="kind")]
+
+
+class VideoRecallParameter(BaseModel):
+ """Video generation parameters to apply to the Video panel.
+
+ Field names follow the video metadata record (see the Media Metadata architecture doc). Models
+ are given by name (or key) and resolved to installed models; media by gallery name. Bounds are
+ the ones the Video panel accepts, so a value it would ignore is refused here instead.
+ """
+
+ model_config = ConfigDict(extra="forbid")
+
+ positive_prompt: Optional[str] = Field(default=None, description="Positive prompt text")
+ negative_prompt: Optional[str] = Field(
+ default=None, description="Negative prompt text; an explicit null turns the negative prompt off"
+ )
+ seed: Optional[int] = Field(default=None, ge=0, le=SEED_MAX, description="Random seed; ignored when remixing")
+ num_frames: Optional[int] = Field(default=None, ge=1, description="Number of frames to generate")
+ fps: Optional[int] = Field(default=None, ge=1, le=120, description="Output frame rate")
+ width: Optional[int] = Field(default=None, ge=1, description="Output width in pixels")
+ height: Optional[int] = Field(default=None, ge=1, description="Output height in pixels")
+ steps: Optional[int] = Field(default=None, ge=1, description="Number of denoising steps")
+ cfg_scale: Optional[float] = Field(default=None, ge=1, description="CFG scale")
+ wan_guidance_scale_low_noise: Optional[float] = Field(
+ default=None, ge=1, description="Wan A14B: the low-noise expert's CFG scale"
+ )
+ ltx2_audio_cfg_scale: Optional[float] = Field(default=None, ge=1, description="LTX-2: audio CFG scale")
+ ltx2_stg_scale: Optional[float] = Field(default=None, ge=0, description="LTX-2: spatiotemporal guidance scale")
+ ltx2_modality_scale: Optional[float] = Field(default=None, ge=1, description="LTX-2: modality guidance scale")
+ ltx2_context_frames: Optional[int] = Field(
+ default=None, ge=1, description="LTX-2: frames of the initial video an extension continues from"
+ )
+ minimax_h3_hybrid_start_block: Optional[int] = Field(
+ default=None, ge=0, description="MiniMax H3 Ref2VA: first block taken from the hybrid FL2VA base"
+ )
+
+ model: Optional[ModelName] = Field(default=None, description="The main video model's name (or key)")
+ vae: Optional[ModelName] = Field(default=None, description="Wan: a standalone VAE's name (or key)")
+ wan_t5_encoder_model: Optional[ModelName] = Field(default=None, description="Wan: standalone UMT5 encoder")
+ wan_transformer_low_noise: Optional[ModelName] = Field(default=None, description="Wan A14B: low-noise expert")
+ wan_component_source: Optional[ModelName] = Field(default=None, description="Wan: Diffusers component source")
+ minimax_h3_transformer_model: Optional[ModelName] = Field(
+ default=None, description="MiniMax H3: transformer override"
+ )
+ minimax_h3_component_source: Optional[ModelName] = Field(
+ default=None, description="MiniMax H3: Diffusers component source"
+ )
+ minimax_h3_text_encoder_model: Optional[ModelName] = Field(default=None, description="MiniMax H3: Qwen3-VL encoder")
+ minimax_h3_hybrid_base_model: Optional[ModelName] = Field(default=None, description="MiniMax H3 Ref2VA: FL2VA base")
+ ltx2_component_source: Optional[ModelName] = Field(default=None, description="LTX-2: component source")
+ ltx2_text_encoder_model: Optional[ModelName] = Field(default=None, description="LTX-2: Gemma-4 encoder")
+ loras: Optional[list[VideoLoRARecallParameter]] = Field(
+ default=None, max_length=MAX_LORAS, description="LoRAs with their weights; an empty list asks for none"
+ )
+
+ first_frame_image: Optional[ImageRefParameter] = Field(default=None, description="First-frame image")
+ last_frame_image: Optional[ImageRefParameter] = Field(default=None, description="Last-frame image")
+ source_video: Optional[VideoRefParameter] = Field(default=None, description="Initial video to extend")
+ source_video_start_frame: Optional[int] = Field(
+ default=None, ge=0, description="First frame of the initial video to use (inclusive)"
+ )
+ source_video_end_frame: Optional[int] = Field(
+ default=None, ge=0, description="Last frame of the initial video to use (inclusive)"
+ )
+ ltx2_conditioning_video: Optional[VideoRefParameter] = Field(
+ default=None, description="LTX-2: a clip whose audio (or picture) conditions the whole generation"
+ )
+ ltx2_conditioning_role: Optional[Literal["audio", "video"]] = Field(
+ default=None, description="LTX-2: which stream of `ltx2_conditioning_video` is the condition; required with it"
+ )
+ minimax_h3_references: Optional[list[ReferenceParameter]] = Field(
+ default=None,
+ max_length=MAX_REFERENCE_VIDEOS + MAX_REFERENCE_IMAGES,
+ description=(
+ f"MiniMax H3 Ref2VA references in conditioning order: at most {MAX_REFERENCE_VIDEOS} videos and "
+ f"{MAX_REFERENCE_IMAGES} images; an empty list asks for none"
+ ),
+ )
+
+ @model_validator(mode="after")
+ def _qualifiers_are_consistent(self) -> "VideoRecallParameter":
+ _check_trim(self.source_video_start_frame, self.source_video_end_frame, "source video trim")
+ if (self.ltx2_conditioning_video is None) != (self.ltx2_conditioning_role is None):
+ raise ValueError("ltx2_conditioning_video and ltx2_conditioning_role must be given together")
+ if self.minimax_h3_references:
+ videos = sum(1 for reference in self.minimax_h3_references if reference.kind == "video")
+ if videos > MAX_REFERENCE_VIDEOS or len(self.minimax_h3_references) - videos > MAX_REFERENCE_IMAGES:
+ raise ValueError(
+ f"at most {MAX_REFERENCE_VIDEOS} reference videos and {MAX_REFERENCE_IMAGES} reference images"
+ )
+ return self
+
+ def provided(self) -> dict[str, Any]:
+ """The fields the caller sent. Null means "not sent", except that a null negative prompt turns it off."""
+ sent = self.model_dump(exclude_none=True)
+ if "negative_prompt" in self.model_fields_set and self.negative_prompt is None:
+ sent["negative_prompt"] = None
+ return sent
+
+
+class VideoRecallParametersResponse(BaseModel):
+ status: Literal["success", "no_parameters_provided", "nothing_resolved"]
+ queue_id: str
+ parameters: dict[str, Any] = Field(description="The resolved parameters sent to the frontend")
+ skipped: list[str] = Field(description="Requested fields dropped because their model or media could not be used")
+
+
+class VideoRecallMediaResponse(BaseModel):
+ status: Literal["success"]
+ queue_id: str
+ action: VideoRecallAction
+ video: VideoDTO
+ uploaded: bool = Field(description="Whether the video was uploaded into the gallery by this request")
+
+
+def _model_identifier(config: AnyModelConfig) -> dict[str, Any]:
+ return {
+ "key": config.key,
+ "hash": config.hash,
+ "name": config.name,
+ "base": config.base.value,
+ "type": config.type.value,
+ }
+
+
+def resolve_video_model(
+ name_or_key: str, model_type: ModelType, bases: Optional[frozenset[BaseModelType]]
+) -> Optional[dict[str, Any]]:
+ """Resolve a model key, else name, of the given type and bases to a metadata `ModelIdentifier`."""
+ store = ApiDependencies.invoker.services.model_manager.store
+
+ def usable(config: AnyModelConfig) -> bool:
+ return config.type == model_type and (bases is None or config.base in bases)
+
+ try:
+ by_key = store.get_model(name_or_key)
+ if usable(by_key):
+ return _model_identifier(by_key)
+ except UnknownModelException:
+ pass
+
+ for config in store.search_by_attr(model_name=name_or_key, model_type=model_type):
+ if usable(config):
+ return _model_identifier(config)
+ return None
+
+
+def _check_image(image_name: str, current_user: CurrentUserOrDefault) -> bool:
+ """False for an image that does not exist; raise if it exists but the caller may not read it."""
+ if not ApiDependencies.invoker.services.image_records.exists(image_name):
+ return False
+ assert_image_read_access(image_name, current_user)
+ return True
+
+
+def _check_video(video_name: str, current_user: CurrentUserOrDefault) -> bool:
+ """False for a video that does not exist; raise if it exists but the caller may not read it."""
+ if not ApiDependencies.invoker.services.video_records.exists(video_name):
+ return False
+ assert_video_read_access(video_name, current_user)
+ return True
+
+
+def resolve_video_recall_parameters(
+ parameters: VideoRecallParameter, mode: VideoRecallMode, current_user: CurrentUserOrDefault
+) -> tuple[dict[str, Any], list[str]]:
+ """Resolve models and media to their metadata shapes. Returns (resolved, skipped field names)."""
+ logger = ApiDependencies.invoker.services.logger
+ provided = parameters.provided()
+ if mode == "remix":
+ provided.pop("seed", None)
+
+ resolved: dict[str, Any] = {}
+ skipped: list[str] = []
+
+ def skip(field: str, reason: str) -> None:
+ logger.warning(f"Video recall: skipping {field}: {reason}")
+ skipped.append(field)
+
+ for key, value in provided.items():
+ if key in MODEL_SLOTS:
+ model_type, bases = MODEL_SLOTS[key]
+ identifier = resolve_video_model(value, model_type, bases)
+ if identifier is None:
+ skip(key, f"no usable {model_type.value} model {value!r}")
+ else:
+ resolved[key] = identifier
+ elif key == "loras":
+ loras: list[dict[str, Any]] = []
+ for index, lora in enumerate(value):
+ identifier = resolve_video_model(lora["model_name"], ModelType.LoRA, VIDEO_BASES)
+ if identifier is None:
+ skip(f"loras[{index}]", f"no video LoRA {lora['model_name']!r}")
+ else:
+ loras.append({"model": identifier, "weight": lora["weight"]})
+ # An empty request asks for no LoRAs; one whose every entry was dropped asks for nothing.
+ if loras or not value:
+ resolved["loras"] = loras
+ elif key in ("first_frame_image", "last_frame_image"):
+ if _check_image(value["image_name"], current_user):
+ resolved[key] = value
+ else:
+ skip(key, f"image {value['image_name']!r} not found")
+ elif key in ("source_video", "ltx2_conditioning_video"):
+ if _check_video(value["video_name"], current_user):
+ resolved[key] = value
+ else:
+ skip(key, f"video {value['video_name']!r} not found")
+ elif key == "minimax_h3_references":
+ references: list[dict[str, Any]] = []
+ for index, reference in enumerate(value):
+ found = (
+ _check_image(reference["image_name"], current_user)
+ if reference["kind"] == "image"
+ else _check_video(reference["video_name"], current_user)
+ )
+ if found:
+ references.append(reference)
+ else:
+ skip(f"minimax_h3_references[{index}]", "media not found")
+ if references or not value:
+ resolved["minimax_h3_references"] = references
+ else:
+ resolved[key] = value
+
+ # Trim bounds and the conditioning role qualify their medium; without it they mean nothing.
+ for medium, qualifiers in (
+ ("source_video", ("source_video_start_frame", "source_video_end_frame")),
+ ("ltx2_conditioning_video", ("ltx2_conditioning_role",)),
+ ):
+ if medium not in resolved:
+ for qualifier in qualifiers:
+ if resolved.pop(qualifier, None) is not None:
+ skip(qualifier, f"{medium} is not being recalled")
+
+ return resolved, skipped
+
+
+@video_recall_router.post(
+ "/{queue_id}",
+ operation_id="recall_video_parameters",
+ response_model=VideoRecallParametersResponse,
+)
+def recall_video_parameters(
+ current_user: CurrentUserOrDefault,
+ queue_id: str = Path(..., description="The queue id to perform this operation on"),
+ parameters: VideoRecallParameter = Body(..., description="Video parameters to recall"),
+ mode: VideoRecallMode = Query(
+ default="recall", description="`recall` applies every field; `remix` applies everything except the seed"
+ ),
+ strict: bool = Query(
+ default=False,
+ description=(
+ "When true, the parameters are treated as a whole generation record: LoRAs and media not "
+ "included are cleared from the Video panel. When false, only the included fields change."
+ ),
+ ),
+) -> VideoRecallParametersResponse:
+ """Apply video generation parameters to the current user's Video panel.
+
+ Models and media that cannot be used are dropped and listed in `skipped`; the rest are applied.
+ """
+ if not parameters.provided():
+ return VideoRecallParametersResponse(
+ status="no_parameters_provided", queue_id=queue_id, parameters={}, skipped=[]
+ )
+
+ assert_image_move_maintenance_inactive()
+ resolved, skipped = resolve_video_recall_parameters(parameters, mode, current_user)
+ if not resolved:
+ return VideoRecallParametersResponse(
+ status="nothing_resolved", queue_id=queue_id, parameters={}, skipped=skipped
+ )
+
+ ApiDependencies.invoker.services.events.emit_video_recall_requested(
+ queue_id, current_user.user_id, "parameters", mode=mode, strict=strict, parameters=resolved
+ )
+ return VideoRecallParametersResponse(status="success", queue_id=queue_id, parameters=resolved, skipped=skipped)
+
+
+def _emit_video_placement(
+ queue_id: str, user_id: str, action: VideoRecallAction, video: VideoDTO, uploaded: bool
+) -> VideoRecallMediaResponse:
+ ApiDependencies.invoker.services.events.emit_video_recall_requested(
+ queue_id,
+ user_id,
+ action,
+ video=VideoRecallVideo(
+ video_name=video.video_name,
+ width=video.width,
+ height=video.height,
+ duration=video.duration,
+ fps=video.fps,
+ media_origin=video.media_origin,
+ ),
+ )
+ return VideoRecallMediaResponse(status="success", queue_id=queue_id, action=action, video=video, uploaded=uploaded)
+
+
+def _place_gallery_video(
+ queue_id: str, action: VideoRecallAction, video_name: str, current_user: CurrentUserOrDefault
+) -> VideoRecallMediaResponse:
+ assert_video_read_access(video_name, current_user)
+ try:
+ video = ApiDependencies.invoker.services.videos.get_dto(video_name)
+ except VideoRecordNotFoundException:
+ raise HTTPException(status_code=404, detail="Video not found")
+ return _emit_video_placement(queue_id, current_user.user_id, action, video, uploaded=False)
+
+
+async def _place_uploaded_video(
+ request: Request,
+ queue_id: str,
+ action: VideoRecallAction,
+ board_id: Optional[str],
+ current_user: CurrentUserOrDefault,
+) -> VideoRecallMediaResponse:
+ video = await ingest_uploaded_video(
+ request, current_user, video_category=ImageCategory.GENERAL, is_intermediate=False, board_id=board_id
+ )
+ return _emit_video_placement(queue_id, current_user.user_id, action, video, uploaded=True)
+
+
+_VIDEO_NAME_QUERY = Query(..., min_length=1, max_length=255, description="The name of the gallery video")
+_BOARD_ID_QUERY = Query(default=None, description="The board to upload the video to; Uncategorized when omitted")
+_UPLOAD_RESPONSES: dict[int | str, dict[str, Any]] = {
+ 413: {"description": "The video exceeds the upload size limit"},
+ 415: {"description": "The file is not a supported video or audio file"},
+ 429: {"description": "Too many concurrent video uploads"},
+}
+
+
+@video_recall_router.post(
+ "/{queue_id}/initial-video",
+ operation_id="recall_initial_video",
+ response_model=VideoRecallMediaResponse,
+)
+def recall_initial_video(
+ current_user: CurrentUserOrDefault,
+ queue_id: str = Path(..., description="The queue id to perform this operation on"),
+ video_name: str = _VIDEO_NAME_QUERY,
+) -> VideoRecallMediaResponse:
+ """Place a gallery video in the current user's Video panel as the Initial Video."""
+ return _place_gallery_video(queue_id, "initial_video", video_name, current_user)
+
+
+@video_recall_router.post(
+ "/{queue_id}/initial-video/upload",
+ operation_id="recall_initial_video_upload",
+ response_model=VideoRecallMediaResponse,
+ responses=_UPLOAD_RESPONSES,
+ openapi_extra=VIDEO_UPLOAD_OPENAPI_EXTRA,
+)
+async def recall_initial_video_upload(
+ current_user: CurrentUserOrDefault,
+ request: Request,
+ queue_id: str = Path(..., description="The queue id to perform this operation on"),
+ board_id: Optional[str] = _BOARD_ID_QUERY,
+) -> VideoRecallMediaResponse:
+ """Upload a video into the gallery and place it in the current user's Video panel as the Initial Video."""
+ return await _place_uploaded_video(request, queue_id, "initial_video", board_id, current_user)
+
+
+@video_recall_router.post(
+ "/{queue_id}/reference-video",
+ operation_id="recall_reference_video",
+ response_model=VideoRecallMediaResponse,
+)
+def recall_reference_video(
+ current_user: CurrentUserOrDefault,
+ queue_id: str = Path(..., description="The queue id to perform this operation on"),
+ video_name: str = _VIDEO_NAME_QUERY,
+) -> VideoRecallMediaResponse:
+ """Append a gallery video to the current user's reference videos (models that take them, e.g. MiniMax H3 Ref2VA)."""
+ return _place_gallery_video(queue_id, "reference_video", video_name, current_user)
+
+
+@video_recall_router.post(
+ "/{queue_id}/reference-video/upload",
+ operation_id="recall_reference_video_upload",
+ response_model=VideoRecallMediaResponse,
+ responses=_UPLOAD_RESPONSES,
+ openapi_extra=VIDEO_UPLOAD_OPENAPI_EXTRA,
+)
+async def recall_reference_video_upload(
+ current_user: CurrentUserOrDefault,
+ request: Request,
+ queue_id: str = Path(..., description="The queue id to perform this operation on"),
+ board_id: Optional[str] = _BOARD_ID_QUERY,
+) -> VideoRecallMediaResponse:
+ """Upload a video into the gallery and append it to the current user's reference videos."""
+ return await _place_uploaded_video(request, queue_id, "reference_video", board_id, current_user)
diff --git a/invokeai/app/api/routers/videos.py b/invokeai/app/api/routers/videos.py
index 94fb7a8fc4..7c22738f56 100644
--- a/invokeai/app/api/routers/videos.py
+++ b/invokeai/app/api/routers/videos.py
@@ -5,7 +5,7 @@ import tempfile
import traceback
from collections.abc import Iterator
from pathlib import Path
-from typing import Annotated, BinaryIO, Optional
+from typing import Annotated, Any, BinaryIO, Optional
from fastapi import Body, HTTPException, Query, Request, Response
from fastapi import Path as PathParam
@@ -392,65 +392,57 @@ def _probe_decodable_video(path: Path) -> tuple[tuple[int, int, float, Optional[
return metadata, first_frame
-@videos_router.post(
- "/upload",
- operation_id="upload_video",
- responses={
- 201: {"description": "The video was uploaded successfully"},
- 415: {"description": "Video upload failed"},
- },
- status_code=201,
- response_model=VideoDTO,
- # The body is parsed by hand (see _stream_video_upload) so the file lands in exactly
- # one temp file, which means FastAPI cannot infer the request schema from the
- # signature. This spells out the same multipart body the `file` + `metadata`
- # parameters used to generate, so the documented contract is unchanged.
- openapi_extra={
- "requestBody": {
- "required": True,
- "content": {
- "multipart/form-data": {
- "schema": {
- "properties": {
- # Key order and shape mirror what FastAPI generates for the sibling
- # upload routes (see Body_upload_image), so the documented contract
- # stays byte-identical to what `file` + `metadata` produced.
- "file": {
- "type": "string",
- "contentMediaType": "application/octet-stream",
- "title": "File",
- },
- "metadata": {
- "anyOf": [{"type": "string"}, {"type": "null"}],
- "title": "Metadata",
- "description": "The metadata to associate with the video, must be a stringified JSON dict",
- },
+# The body of a video upload is parsed by hand (see _stream_video_upload) so the file lands in
+# exactly one temp file, which means FastAPI cannot infer the request schema from the route
+# signature. This spells out the same multipart body the `file` + `metadata` parameters used to
+# generate, so the documented contract is unchanged. Every route that ingests through
+# `ingest_uploaded_video` documents its body with it.
+VIDEO_UPLOAD_OPENAPI_EXTRA: dict[str, Any] = {
+ "requestBody": {
+ "required": True,
+ "content": {
+ "multipart/form-data": {
+ "schema": {
+ "properties": {
+ # Key order and shape mirror what FastAPI generates for the sibling
+ # upload routes (see Body_upload_image), so the documented contract
+ # stays byte-identical to what `file` + `metadata` produced.
+ "file": {
+ "type": "string",
+ "contentMediaType": "application/octet-stream",
+ "title": "File",
+ },
+ "metadata": {
+ "anyOf": [{"type": "string"}, {"type": "null"}],
+ "title": "Metadata",
+ "description": "The metadata to associate with the video, must be a stringified JSON dict",
},
- "type": "object",
- "required": ["file"],
- "title": "Body_upload_video",
- }
+ },
+ "type": "object",
+ "required": ["file"],
+ "title": "Body_upload_video",
}
- },
- }
- },
-)
-async def upload_video(
- current_user: CurrentUserOrDefault,
+ }
+ },
+ }
+}
+
+
+async def ingest_uploaded_video(
request: Request,
- response: Response,
- video_category: ImageCategory = Query(description="The category of the video"),
- is_intermediate: bool = Query(description="Whether this is an intermediate video"),
- board_id: Optional[str] = Query(default=None, description="The board to add this video to, if any"),
- session_id: Optional[str] = Query(default=None, description="The session ID associated with this upload, if any"),
- project_id: Optional[str] = Query(
- default=None,
- min_length=1,
- max_length=255,
- description="The caller's project this upload originates in, if any; recorded for intermediates cleanup",
- ),
+ current_user: CurrentUserOrDefault,
+ *,
+ video_category: ImageCategory,
+ is_intermediate: bool,
+ board_id: Optional[str],
+ session_id: Optional[str] = None,
+ project_id: Optional[str] = None,
) -> VideoDTO:
- """Uploads a video for the current user."""
+ """Stream a multipart video upload from `request` into the gallery and announce it.
+
+ Callers must be routes that `VideoUploadLimitASGIMiddleware` matches: the ingress size cap
+ and the concurrency slots are enforced there, before this runs.
+ """
# Check board access for uploads to a specific board.
board = await run_in_threadpool(_assert_board_write_access, board_id, current_user)
await run_in_threadpool(assert_project_owned, project_id, current_user)
@@ -567,8 +559,6 @@ async def upload_video(
video_dto, user_id=current_user.user_id, board=board, shared_user_ids=shared_user_ids
)
- response.status_code = 201
- response.headers["Location"] = video_dto.video_url
return video_dto
finally:
# If create() succeeded the file was moved; this unlink is a no-op then.
@@ -582,6 +572,47 @@ async def upload_video(
pass
+@videos_router.post(
+ "/upload",
+ operation_id="upload_video",
+ responses={
+ 201: {"description": "The video was uploaded successfully"},
+ 415: {"description": "Video upload failed"},
+ },
+ status_code=201,
+ response_model=VideoDTO,
+ openapi_extra=VIDEO_UPLOAD_OPENAPI_EXTRA,
+)
+async def upload_video(
+ current_user: CurrentUserOrDefault,
+ request: Request,
+ response: Response,
+ video_category: ImageCategory = Query(description="The category of the video"),
+ is_intermediate: bool = Query(description="Whether this is an intermediate video"),
+ board_id: Optional[str] = Query(default=None, description="The board to add this video to, if any"),
+ session_id: Optional[str] = Query(default=None, description="The session ID associated with this upload, if any"),
+ project_id: Optional[str] = Query(
+ default=None,
+ min_length=1,
+ max_length=255,
+ description="The caller's project this upload originates in, if any; recorded for intermediates cleanup",
+ ),
+) -> VideoDTO:
+ """Uploads a video for the current user."""
+ video_dto = await ingest_uploaded_video(
+ request,
+ current_user,
+ video_category=video_category,
+ is_intermediate=is_intermediate,
+ board_id=board_id,
+ session_id=session_id,
+ project_id=project_id,
+ )
+ response.status_code = 201
+ response.headers["Location"] = video_dto.video_url
+ return video_dto
+
+
# Declared sync (`def`, not `async def`) so FastAPI runs it in the threadpool: every call
# below is blocking SQLite/filesystem work, which would stall the event loop — and with it
# every other request and socket event — for the duration of the delete. The batch
diff --git a/invokeai/app/api/sockets.py b/invokeai/app/api/sockets.py
index 489ceb47c4..9263cf51c4 100644
--- a/invokeai/app/api/sockets.py
+++ b/invokeai/app/api/sockets.py
@@ -59,6 +59,7 @@ from invokeai.app.services.events.events_common import (
QueueItemStatusChangedEvent,
RecallParametersUpdatedEvent,
UserAccessChangedEvent,
+ VideoRecallRequestedEvent,
VideoUploadedEvent,
WorkflowAccessRevokedEvent,
WorkflowCreatedEvent,
@@ -114,6 +115,7 @@ QUEUE_EVENTS = {
QueueItemsCanceledEvent,
QueueClearedEvent,
RecallParametersUpdatedEvent,
+ VideoRecallRequestedEvent,
}
MODEL_EVENTS = {
@@ -967,7 +969,7 @@ class SocketIO:
per-session side effects.
InvocationEventBase events stay private (owner + admins only). RecallParametersUpdatedEvent
- is also private. QueueClearedEvent is broadcast to the queue room when unscoped (an admin or
+ is also private, and VideoRecallRequestedEvent goes to the owner alone. QueueClearedEvent is broadcast to the queue room when unscoped (an admin or
single-user clear that deleted every user's items); a user-scoped clear goes full to
owner + admins with a sanitized companion to the rest of the queue room, so other users
refresh their queue lists without treating the clear as their own.
@@ -1081,6 +1083,15 @@ class SocketIO:
)
logger.debug(f"Emitted private recall_parameters_updated event to user room {user_room} and admin room")
+ # VideoRecallRequestedEvent goes to the owner only. Unlike image recall no admin UI
+ # consumes it, and its payload names the owner's media. One room also means one
+ # delivery, which matters: a reference-video recall appends.
+ elif isinstance(event_data, VideoRecallRequestedEvent):
+ await self._sio.emit(
+ event=event_name, data=event_data.model_dump(mode="json"), room=f"user:{event_data.user_id}"
+ )
+ logger.debug(f"Emitted private video_recall_requested event to user room user:{event_data.user_id}")
+
# BatchEnqueuedEvent: full to owner+admin, sanitized to everyone else in the queue
# room so their badge total and queue list pick up the new items.
elif isinstance(event_data, BatchEnqueuedEvent):
diff --git a/invokeai/app/api_app.py b/invokeai/app/api_app.py
index 2da5974ec5..a7f948531b 100644
--- a/invokeai/app/api_app.py
+++ b/invokeai/app/api_app.py
@@ -1,6 +1,7 @@
import asyncio
import inspect
import logging
+import re
from collections.abc import Awaitable, Callable
from contextlib import asynccontextmanager
from pathlib import Path
@@ -42,6 +43,7 @@ from invokeai.app.api.routers import (
style_presets,
system_prompts,
utilities,
+ video_recall,
videos,
virtual_boards,
wildcards,
@@ -408,7 +410,14 @@ class RequestBodyLimitASGIMiddleware:
return await self.app(scope, receive, send)
# Behind a sub-path proxy the public path carries the prefix (see SubPathASGIMiddleware).
route_path: str = scope.get("path", "").removeprefix(scope.get("root_path", ""))
- if not self.matches_request(scope.get("method", ""), route_path):
+ # Starlette matches routes with `^...$`, and `$` also matches before a final newline, so a
+ # request for `/upload%0A` reaches the `/upload` route. Test both spellings: the newline may
+ # be the route's terminator (`/upload\n`) or a path parameter's only character
+ # (`/projects/\n`), and either way the request must not reach the route unbounded.
+ method = scope.get("method", "")
+ if not (
+ self.matches_request(method, route_path) or self.matches_request(method, route_path.removesuffix("\n"))
+ ):
return await self.app(scope, receive, send)
# `connection` is a hop-by-hop header and illegal in HTTP/2+, so every use below is
@@ -533,6 +542,18 @@ class RequestBodyLimitASGIMiddleware:
self._active_by_user.pop(per_user_key, None)
+# The video-recall routes that take an upload ingest it exactly as /videos/upload does, so they
+# share its ingress cap and concurrency slots. Their name-only siblings take no body and stay
+# outside the limiter, so a caller mid-upload is never refused a slot for a bodyless request.
+_VIDEO_RECALL_UPLOAD_PATH = re.compile(r"/api/v1/recall/video/[^/]+/(?:initial-video|reference-video)/upload")
+
+
+def _is_video_upload(method: str, path: str) -> bool:
+ return method == "POST" and (
+ path == "/api/v1/videos/upload" or _VIDEO_RECALL_UPLOAD_PATH.fullmatch(path) is not None
+ )
+
+
class VideoUploadLimitASGIMiddleware(RequestBodyLimitASGIMiddleware):
"""Bound video-upload ingress before FastAPI's multipart parser runs."""
@@ -548,7 +569,7 @@ class VideoUploadLimitASGIMiddleware(RequestBodyLimitASGIMiddleware):
) -> None:
super().__init__(
app=app,
- matches_request=lambda method, path: method == "POST" and path == "/api/v1/videos/upload",
+ matches_request=_is_video_upload,
too_large_detail=lambda _actual, limit: f"Video upload exceeds maximum request size ({limit} bytes)",
capacity_refusal_detail=lambda per_user: (
"Too many concurrent video uploads for this user; try again shortly"
@@ -737,6 +758,7 @@ app.include_router(system_prompts.system_prompts_router, prefix="/api")
app.include_router(client_state.client_state_router, prefix="/api")
app.include_router(projects.projects_router, prefix="/api")
app.include_router(recall_parameters.recall_parameters_router, prefix="/api")
+app.include_router(video_recall.video_recall_router, prefix="/api")
app.include_router(custom_nodes.custom_nodes_router, prefix="/api")
app.openapi = get_openapi_func(app)
diff --git a/invokeai/app/services/events/events_base.py b/invokeai/app/services/events/events_base.py
index 1a5603fcab..994be4555b 100644
--- a/invokeai/app/services/events/events_base.py
+++ b/invokeai/app/services/events/events_base.py
@@ -42,6 +42,10 @@ from invokeai.app.services.events.events_common import (
QueueItemStatusChangedEvent,
RecallParametersUpdatedEvent,
UserAccessChangedEvent,
+ VideoRecallAction,
+ VideoRecallMode,
+ VideoRecallRequestedEvent,
+ VideoRecallVideo,
VideoUploadedEvent,
WorkflowCreatedEvent,
WorkflowDeletedEvent,
@@ -153,6 +157,19 @@ class EventServiceBase:
"""Emitted when recall parameters are updated"""
self.dispatch(RecallParametersUpdatedEvent.build(queue_id, user_id, parameters))
+ def emit_video_recall_requested(
+ self,
+ queue_id: str,
+ user_id: str,
+ action: VideoRecallAction,
+ mode: VideoRecallMode | None = None,
+ strict: bool = False,
+ parameters: dict | None = None,
+ video: VideoRecallVideo | None = None,
+ ) -> None:
+ """Emitted when an external caller asks for a user's Video panel to be updated"""
+ self.dispatch(VideoRecallRequestedEvent.build(queue_id, user_id, action, mode, strict, parameters, video))
+
# endregion
# region Workflow library
diff --git a/invokeai/app/services/events/events_common.py b/invokeai/app/services/events/events_common.py
index 8b88bb700f..80fee5c022 100644
--- a/invokeai/app/services/events/events_common.py
+++ b/invokeai/app/services/events/events_common.py
@@ -925,6 +925,67 @@ class RecallParametersUpdatedEvent(QueueEventBase):
return cls(queue_id=queue_id, user_id=user_id, parameters=parameters)
+VideoRecallAction: TypeAlias = Literal["parameters", "initial_video", "reference_video"]
+VideoRecallMode: TypeAlias = Literal["recall", "remix"]
+
+
+class VideoRecallVideo(BaseModel):
+ """The gallery video a video recall places into the Video panel."""
+
+ video_name: str = Field(description="The name of the gallery video")
+ width: int = Field(description="The video's width in pixels")
+ height: int = Field(description="The video's height in pixels")
+ duration: float = Field(description="The video's duration in seconds")
+ fps: Optional[float] = Field(default=None, description="The video's frame rate, when known")
+ media_origin: Optional[str] = Field(
+ default=None, description="How the video entered the gallery, e.g. `audio_upload` for wrapped audio"
+ )
+
+
+@payload_schema.register
+class VideoRecallRequestedEvent(QueueEventBase):
+ """Event model for video_recall_requested"""
+
+ __event_name__ = "video_recall_requested"
+
+ user_id: str = Field(description="The ID of the user whose Video panel the recall targets")
+ action: VideoRecallAction = Field(description="What the frontend should do with the payload")
+ mode: Optional[VideoRecallMode] = Field(
+ default=None, description="For `parameters`: `remix` applies everything except the seed"
+ )
+ strict: bool = Field(
+ default=False,
+ description="For `parameters`: treat the payload as a whole generation record, clearing omitted LoRAs and media",
+ )
+ parameters: Optional[dict[str, Any]] = Field(
+ default=None, description="For `parameters`: recall fields, keyed like the video metadata record"
+ )
+ video: Optional[VideoRecallVideo] = Field(
+ default=None, description="For `initial_video` and `reference_video`: the video to place"
+ )
+
+ @classmethod
+ def build(
+ cls,
+ queue_id: str,
+ user_id: str,
+ action: VideoRecallAction,
+ mode: Optional[VideoRecallMode] = None,
+ strict: bool = False,
+ parameters: Optional[dict[str, Any]] = None,
+ video: Optional[VideoRecallVideo] = None,
+ ) -> "VideoRecallRequestedEvent":
+ return cls(
+ queue_id=queue_id,
+ user_id=user_id,
+ action=action,
+ mode=mode,
+ strict=strict,
+ parameters=parameters,
+ video=video,
+ )
+
+
class ImageIndexEventBase(EventBase):
"""Base class for image index events"""
diff --git a/invokeai/frontend/web/openapi.json b/invokeai/frontend/web/openapi.json
index 7eec53dab2..4fdbddd44c 100644
--- a/invokeai/frontend/web/openapi.json
+++ b/invokeai/frontend/web/openapi.json
@@ -15452,6 +15452,424 @@
}
}
},
+ "/api/v1/recall/video/{queue_id}": {
+ "post": {
+ "tags": ["recall"],
+ "summary": "Recall Video Parameters",
+ "description": "Apply video generation parameters to the current user's Video panel.\n\nModels and media that cannot be used are dropped and listed in `skipped`; the rest are applied.",
+ "operationId": "recall_video_parameters",
+ "security": [
+ {
+ "HTTPBearer": []
+ }
+ ],
+ "parameters": [
+ {
+ "name": "queue_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "description": "The queue id to perform this operation on",
+ "title": "Queue Id"
+ },
+ "description": "The queue id to perform this operation on"
+ },
+ {
+ "name": "mode",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "enum": ["recall", "remix"],
+ "type": "string",
+ "description": "`recall` applies every field; `remix` applies everything except the seed",
+ "default": "recall",
+ "title": "Mode"
+ },
+ "description": "`recall` applies every field; `remix` applies everything except the seed"
+ },
+ {
+ "name": "strict",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "type": "boolean",
+ "description": "When true, the parameters are treated as a whole generation record: LoRAs and media not included are cleared from the Video panel. When false, only the included fields change.",
+ "default": false,
+ "title": "Strict"
+ },
+ "description": "When true, the parameters are treated as a whole generation record: LoRAs and media not included are cleared from the Video panel. When false, only the included fields change."
+ }
+ ],
+ "requestBody": {
+ "required": true,
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallParameter",
+ "description": "Video parameters to recall"
+ }
+ }
+ }
+ },
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallParametersResponse"
+ }
+ }
+ }
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/recall/video/{queue_id}/initial-video": {
+ "post": {
+ "tags": ["recall"],
+ "summary": "Recall Initial Video",
+ "description": "Place a gallery video in the current user's Video panel as the Initial Video.",
+ "operationId": "recall_initial_video",
+ "security": [
+ {
+ "HTTPBearer": []
+ }
+ ],
+ "parameters": [
+ {
+ "name": "queue_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "description": "The queue id to perform this operation on",
+ "title": "Queue Id"
+ },
+ "description": "The queue id to perform this operation on"
+ },
+ {
+ "name": "video_name",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 255,
+ "description": "The name of the gallery video",
+ "title": "Video Name"
+ },
+ "description": "The name of the gallery video"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallMediaResponse"
+ }
+ }
+ }
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/recall/video/{queue_id}/initial-video/upload": {
+ "post": {
+ "tags": ["recall"],
+ "summary": "Recall Initial Video Upload",
+ "description": "Upload a video into the gallery and place it in the current user's Video panel as the Initial Video.",
+ "operationId": "recall_initial_video_upload",
+ "security": [
+ {
+ "HTTPBearer": []
+ }
+ ],
+ "parameters": [
+ {
+ "name": "queue_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "description": "The queue id to perform this operation on",
+ "title": "Queue Id"
+ },
+ "description": "The queue id to perform this operation on"
+ },
+ {
+ "name": "board_id",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The board to upload the video to; Uncategorized when omitted",
+ "title": "Board Id"
+ },
+ "description": "The board to upload the video to; Uncategorized when omitted"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallMediaResponse"
+ }
+ }
+ }
+ },
+ "413": {
+ "description": "The video exceeds the upload size limit"
+ },
+ "415": {
+ "description": "The file is not a supported video or audio file"
+ },
+ "429": {
+ "description": "Too many concurrent video uploads"
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ }
+ }
+ },
+ "requestBody": {
+ "required": true,
+ "content": {
+ "multipart/form-data": {
+ "schema": {
+ "properties": {
+ "file": {
+ "type": "string",
+ "contentMediaType": "application/octet-stream",
+ "title": "File"
+ },
+ "metadata": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Metadata",
+ "description": "The metadata to associate with the video, must be a stringified JSON dict"
+ }
+ },
+ "type": "object",
+ "required": ["file"],
+ "title": "Body_upload_video"
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/recall/video/{queue_id}/reference-video": {
+ "post": {
+ "tags": ["recall"],
+ "summary": "Recall Reference Video",
+ "description": "Append a gallery video to the current user's reference videos (models that take them, e.g. MiniMax H3 Ref2VA).",
+ "operationId": "recall_reference_video",
+ "security": [
+ {
+ "HTTPBearer": []
+ }
+ ],
+ "parameters": [
+ {
+ "name": "queue_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "description": "The queue id to perform this operation on",
+ "title": "Queue Id"
+ },
+ "description": "The queue id to perform this operation on"
+ },
+ {
+ "name": "video_name",
+ "in": "query",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "minLength": 1,
+ "maxLength": 255,
+ "description": "The name of the gallery video",
+ "title": "Video Name"
+ },
+ "description": "The name of the gallery video"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallMediaResponse"
+ }
+ }
+ }
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ }
+ }
+ }
+ }
+ },
+ "/api/v1/recall/video/{queue_id}/reference-video/upload": {
+ "post": {
+ "tags": ["recall"],
+ "summary": "Recall Reference Video Upload",
+ "description": "Upload a video into the gallery and append it to the current user's reference videos.",
+ "operationId": "recall_reference_video_upload",
+ "security": [
+ {
+ "HTTPBearer": []
+ }
+ ],
+ "parameters": [
+ {
+ "name": "queue_id",
+ "in": "path",
+ "required": true,
+ "schema": {
+ "type": "string",
+ "description": "The queue id to perform this operation on",
+ "title": "Queue Id"
+ },
+ "description": "The queue id to perform this operation on"
+ },
+ {
+ "name": "board_id",
+ "in": "query",
+ "required": false,
+ "schema": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "The board to upload the video to; Uncategorized when omitted",
+ "title": "Board Id"
+ },
+ "description": "The board to upload the video to; Uncategorized when omitted"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "Successful Response",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/VideoRecallMediaResponse"
+ }
+ }
+ }
+ },
+ "413": {
+ "description": "The video exceeds the upload size limit"
+ },
+ "415": {
+ "description": "The file is not a supported video or audio file"
+ },
+ "429": {
+ "description": "Too many concurrent video uploads"
+ },
+ "422": {
+ "description": "Validation Error",
+ "content": {
+ "application/json": {
+ "schema": {
+ "$ref": "#/components/schemas/HTTPValidationError"
+ }
+ }
+ }
+ }
+ },
+ "requestBody": {
+ "required": true,
+ "content": {
+ "multipart/form-data": {
+ "schema": {
+ "properties": {
+ "file": {
+ "type": "string",
+ "contentMediaType": "application/octet-stream",
+ "title": "File"
+ },
+ "metadata": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Metadata",
+ "description": "The metadata to associate with the video, must be a stringified JSON dict"
+ }
+ },
+ "type": "object",
+ "required": ["file"],
+ "title": "Body_upload_video"
+ }
+ }
+ }
+ }
+ }
+ },
"/api/v2/custom_nodes/": {
"get": {
"tags": ["custom_nodes"],
@@ -47482,6 +47900,54 @@
"title": "ImageRecordChanges",
"description": "A set of changes to apply to an image record.\n\nOnly limited changes are valid:\n - `image_category`: change the category of an image\n - `session_id`: change the session associated with an image\n - `is_intermediate`: change the image's `is_intermediate` flag\n - `starred`: change whether the image is starred"
},
+ "ImageRefParameter": {
+ "properties": {
+ "image_name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1,
+ "title": "Image Name",
+ "description": "The name of a gallery image"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": ["image_name"],
+ "title": "ImageRefParameter"
+ },
+ "ImageReferenceParameter": {
+ "properties": {
+ "kind": {
+ "type": "string",
+ "const": "image",
+ "title": "Kind"
+ },
+ "image_name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1,
+ "title": "Image Name",
+ "description": "The name of a gallery image"
+ },
+ "detail": {
+ "anyOf": [
+ {
+ "type": "string",
+ "enum": ["max", "match"]
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Detail",
+ "description": "The reference image's detail mode"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": ["kind", "image_name"],
+ "title": "ImageReferenceParameter"
+ },
"ImageResizeInvocation": {
"category": "image",
"class": "invocation",
@@ -105046,6 +105512,29 @@
"$ref": "#/components/schemas/VideoOutput"
}
},
+ "VideoLoRARecallParameter": {
+ "properties": {
+ "model_name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1,
+ "title": "Model Name",
+ "description": "The name (or key) of the LoRA model"
+ },
+ "weight": {
+ "type": "number",
+ "maximum": 10.0,
+ "minimum": -10.0,
+ "title": "Weight",
+ "description": "The weight for the LoRA",
+ "default": 1.0
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": ["model_name"],
+ "title": "VideoLoRARecallParameter"
+ },
"VideoNamesBatch": {
"properties": {
"video_names": {
@@ -105146,6 +105635,680 @@
"title": "VideoOutput",
"type": "object"
},
+ "VideoRecallMediaResponse": {
+ "properties": {
+ "status": {
+ "type": "string",
+ "const": "success",
+ "title": "Status"
+ },
+ "queue_id": {
+ "type": "string",
+ "title": "Queue Id"
+ },
+ "action": {
+ "type": "string",
+ "enum": ["parameters", "initial_video", "reference_video"],
+ "title": "Action"
+ },
+ "video": {
+ "$ref": "#/components/schemas/VideoDTO"
+ },
+ "uploaded": {
+ "type": "boolean",
+ "title": "Uploaded",
+ "description": "Whether the video was uploaded into the gallery by this request"
+ }
+ },
+ "type": "object",
+ "required": ["status", "queue_id", "action", "video", "uploaded"],
+ "title": "VideoRecallMediaResponse"
+ },
+ "VideoRecallParameter": {
+ "properties": {
+ "positive_prompt": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Positive Prompt",
+ "description": "Positive prompt text"
+ },
+ "negative_prompt": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Negative Prompt",
+ "description": "Negative prompt text; an explicit null turns the negative prompt off"
+ },
+ "seed": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "maximum": 4294967295.0,
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Seed",
+ "description": "Random seed; ignored when remixing"
+ },
+ "num_frames": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Num Frames",
+ "description": "Number of frames to generate"
+ },
+ "fps": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "maximum": 120.0,
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Fps",
+ "description": "Output frame rate"
+ },
+ "width": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Width",
+ "description": "Output width in pixels"
+ },
+ "height": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Height",
+ "description": "Output height in pixels"
+ },
+ "steps": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Steps",
+ "description": "Number of denoising steps"
+ },
+ "cfg_scale": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Cfg Scale",
+ "description": "CFG scale"
+ },
+ "wan_guidance_scale_low_noise": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Wan Guidance Scale Low Noise",
+ "description": "Wan A14B: the low-noise expert's CFG scale"
+ },
+ "ltx2_audio_cfg_scale": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Audio Cfg Scale",
+ "description": "LTX-2: audio CFG scale"
+ },
+ "ltx2_stg_scale": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Stg Scale",
+ "description": "LTX-2: spatiotemporal guidance scale"
+ },
+ "ltx2_modality_scale": {
+ "anyOf": [
+ {
+ "type": "number",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Modality Scale",
+ "description": "LTX-2: modality guidance scale"
+ },
+ "ltx2_context_frames": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 1.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Context Frames",
+ "description": "LTX-2: frames of the initial video an extension continues from"
+ },
+ "minimax_h3_hybrid_start_block": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 Hybrid Start Block",
+ "description": "MiniMax H3 Ref2VA: first block taken from the hybrid FL2VA base"
+ },
+ "model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Model",
+ "description": "The main video model's name (or key)"
+ },
+ "vae": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Vae",
+ "description": "Wan: a standalone VAE's name (or key)"
+ },
+ "wan_t5_encoder_model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Wan T5 Encoder Model",
+ "description": "Wan: standalone UMT5 encoder"
+ },
+ "wan_transformer_low_noise": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Wan Transformer Low Noise",
+ "description": "Wan A14B: low-noise expert"
+ },
+ "wan_component_source": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Wan Component Source",
+ "description": "Wan: Diffusers component source"
+ },
+ "minimax_h3_transformer_model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 Transformer Model",
+ "description": "MiniMax H3: transformer override"
+ },
+ "minimax_h3_component_source": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 Component Source",
+ "description": "MiniMax H3: Diffusers component source"
+ },
+ "minimax_h3_text_encoder_model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 Text Encoder Model",
+ "description": "MiniMax H3: Qwen3-VL encoder"
+ },
+ "minimax_h3_hybrid_base_model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 Hybrid Base Model",
+ "description": "MiniMax H3 Ref2VA: FL2VA base"
+ },
+ "ltx2_component_source": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Component Source",
+ "description": "LTX-2: component source"
+ },
+ "ltx2_text_encoder_model": {
+ "anyOf": [
+ {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Text Encoder Model",
+ "description": "LTX-2: Gemma-4 encoder"
+ },
+ "loras": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/components/schemas/VideoLoRARecallParameter"
+ },
+ "type": "array",
+ "maxItems": 32
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Loras",
+ "description": "LoRAs with their weights; an empty list asks for none"
+ },
+ "first_frame_image": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ImageRefParameter"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "First-frame image"
+ },
+ "last_frame_image": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/ImageRefParameter"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Last-frame image"
+ },
+ "source_video": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/VideoRefParameter"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "Initial video to extend"
+ },
+ "source_video_start_frame": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Source Video Start Frame",
+ "description": "First frame of the initial video to use (inclusive)"
+ },
+ "source_video_end_frame": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Source Video End Frame",
+ "description": "Last frame of the initial video to use (inclusive)"
+ },
+ "ltx2_conditioning_video": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/VideoRefParameter"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "description": "LTX-2: a clip whose audio (or picture) conditions the whole generation"
+ },
+ "ltx2_conditioning_role": {
+ "anyOf": [
+ {
+ "type": "string",
+ "enum": ["audio", "video"]
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Ltx2 Conditioning Role",
+ "description": "LTX-2: which stream of `ltx2_conditioning_video` is the condition; required with it"
+ },
+ "minimax_h3_references": {
+ "anyOf": [
+ {
+ "items": {
+ "oneOf": [
+ {
+ "$ref": "#/components/schemas/ImageReferenceParameter"
+ },
+ {
+ "$ref": "#/components/schemas/VideoReferenceParameter"
+ }
+ ],
+ "discriminator": {
+ "propertyName": "kind",
+ "mapping": {
+ "image": "#/components/schemas/ImageReferenceParameter",
+ "video": "#/components/schemas/VideoReferenceParameter"
+ }
+ }
+ },
+ "type": "array",
+ "maxItems": 12
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Minimax H3 References",
+ "description": "MiniMax H3 Ref2VA references in conditioning order: at most 3 videos and 9 images; an empty list asks for none"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "title": "VideoRecallParameter",
+ "description": "Video generation parameters to apply to the Video panel.\n\nField names follow the video metadata record (see the Media Metadata architecture doc). Models\nare given by name (or key) and resolved to installed models; media by gallery name. Bounds are\nthe ones the Video panel accepts, so a value it would ignore is refused here instead."
+ },
+ "VideoRecallParametersResponse": {
+ "properties": {
+ "status": {
+ "type": "string",
+ "enum": ["success", "no_parameters_provided", "nothing_resolved"],
+ "title": "Status"
+ },
+ "queue_id": {
+ "type": "string",
+ "title": "Queue Id"
+ },
+ "parameters": {
+ "additionalProperties": true,
+ "type": "object",
+ "title": "Parameters",
+ "description": "The resolved parameters sent to the frontend"
+ },
+ "skipped": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array",
+ "title": "Skipped",
+ "description": "Requested fields dropped because their model or media could not be used"
+ }
+ },
+ "type": "object",
+ "required": ["status", "queue_id", "parameters", "skipped"],
+ "title": "VideoRecallParametersResponse"
+ },
+ "VideoRecallRequestedEvent": {
+ "description": "Event model for video_recall_requested",
+ "properties": {
+ "timestamp": {
+ "description": "The timestamp of the event",
+ "title": "Timestamp",
+ "type": "integer"
+ },
+ "queue_id": {
+ "description": "The ID of the queue",
+ "title": "Queue Id",
+ "type": "string"
+ },
+ "user_id": {
+ "description": "The ID of the user whose Video panel the recall targets",
+ "title": "User Id",
+ "type": "string"
+ },
+ "action": {
+ "description": "What the frontend should do with the payload",
+ "enum": ["parameters", "initial_video", "reference_video"],
+ "title": "Action",
+ "type": "string"
+ },
+ "mode": {
+ "anyOf": [
+ {
+ "enum": ["recall", "remix"],
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "For `parameters`: `remix` applies everything except the seed",
+ "title": "Mode"
+ },
+ "strict": {
+ "default": false,
+ "description": "For `parameters`: treat the payload as a whole generation record, clearing omitted LoRAs and media",
+ "title": "Strict",
+ "type": "boolean"
+ },
+ "parameters": {
+ "anyOf": [
+ {
+ "additionalProperties": true,
+ "type": "object"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "For `parameters`: recall fields, keyed like the video metadata record",
+ "title": "Parameters"
+ },
+ "video": {
+ "anyOf": [
+ {
+ "$ref": "#/components/schemas/VideoRecallVideo"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "For `initial_video` and `reference_video`: the video to place"
+ }
+ },
+ "required": ["timestamp", "queue_id", "user_id", "action", "mode", "strict", "parameters", "video"],
+ "title": "VideoRecallRequestedEvent",
+ "type": "object"
+ },
+ "VideoRecallVideo": {
+ "description": "The gallery video a video recall places into the Video panel.",
+ "properties": {
+ "video_name": {
+ "description": "The name of the gallery video",
+ "title": "Video Name",
+ "type": "string"
+ },
+ "width": {
+ "description": "The video's width in pixels",
+ "title": "Width",
+ "type": "integer"
+ },
+ "height": {
+ "description": "The video's height in pixels",
+ "title": "Height",
+ "type": "integer"
+ },
+ "duration": {
+ "description": "The video's duration in seconds",
+ "title": "Duration",
+ "type": "number"
+ },
+ "fps": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The video's frame rate, when known",
+ "title": "Fps"
+ },
+ "media_origin": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "How the video entered the gallery, e.g. `audio_upload` for wrapped audio",
+ "title": "Media Origin"
+ }
+ },
+ "required": ["video_name", "width", "height", "duration"],
+ "title": "VideoRecallVideo",
+ "type": "object"
+ },
"VideoRecordChanges": {
"properties": {
"video_category": {
@@ -105201,6 +106364,80 @@
"title": "VideoRecordChanges",
"description": "Allowed mutations on a video record."
},
+ "VideoRefParameter": {
+ "properties": {
+ "video_name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1,
+ "title": "Video Name",
+ "description": "The name of a gallery video"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": ["video_name"],
+ "title": "VideoRefParameter"
+ },
+ "VideoReferenceParameter": {
+ "properties": {
+ "kind": {
+ "type": "string",
+ "const": "video",
+ "title": "Kind"
+ },
+ "video_name": {
+ "type": "string",
+ "maxLength": 255,
+ "minLength": 1,
+ "title": "Video Name",
+ "description": "The name of a gallery video"
+ },
+ "conditioning": {
+ "anyOf": [
+ {
+ "type": "string",
+ "enum": ["video_audio", "video", "audio"]
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Conditioning",
+ "description": "Which of the clip's streams condition the generation"
+ },
+ "start_frame": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "Start Frame",
+ "description": "First frame of the clip to use (inclusive)"
+ },
+ "end_frame": {
+ "anyOf": [
+ {
+ "type": "integer",
+ "minimum": 0.0
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "title": "End Frame",
+ "description": "Last frame of the clip to use (inclusive)"
+ }
+ },
+ "additionalProperties": false,
+ "type": "object",
+ "required": ["kind", "video_name"],
+ "title": "VideoReferenceParameter"
+ },
"VideoUploadedEvent": {
"description": "Event model for video_uploaded",
"properties": {
diff --git a/invokeai/frontend/web/src/services/api/schema.ts b/invokeai/frontend/web/src/services/api/schema.ts
index 411e539cda..9f48c30dc1 100644
--- a/invokeai/frontend/web/src/services/api/schema.ts
+++ b/invokeai/frontend/web/src/services/api/schema.ts
@@ -4008,6 +4008,108 @@ export type paths = {
patch?: never;
trace?: never;
};
+ "/api/v1/recall/video/{queue_id}": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Recall Video Parameters
+ * @description Apply video generation parameters to the current user's Video panel.
+ *
+ * Models and media that cannot be used are dropped and listed in `skipped`; the rest are applied.
+ */
+ post: operations["recall_video_parameters"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/v1/recall/video/{queue_id}/initial-video": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Recall Initial Video
+ * @description Place a gallery video in the current user's Video panel as the Initial Video.
+ */
+ post: operations["recall_initial_video"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/v1/recall/video/{queue_id}/initial-video/upload": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Recall Initial Video Upload
+ * @description Upload a video into the gallery and place it in the current user's Video panel as the Initial Video.
+ */
+ post: operations["recall_initial_video_upload"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/v1/recall/video/{queue_id}/reference-video": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Recall Reference Video
+ * @description Append a gallery video to the current user's reference videos (models that take them, e.g. MiniMax H3 Ref2VA).
+ */
+ post: operations["recall_reference_video"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
+ "/api/v1/recall/video/{queue_id}/reference-video/upload": {
+ parameters: {
+ query?: never;
+ header?: never;
+ path?: never;
+ cookie?: never;
+ };
+ get?: never;
+ put?: never;
+ /**
+ * Recall Reference Video Upload
+ * @description Upload a video into the gallery and append it to the current user's reference videos.
+ */
+ post: operations["recall_reference_video_upload"];
+ delete?: never;
+ options?: never;
+ head?: never;
+ patch?: never;
+ trace?: never;
+ };
"/api/v2/custom_nodes/": {
parameters: {
query?: never;
@@ -19715,6 +19817,32 @@ export type components = {
} & {
[key: string]: unknown;
};
+ /** ImageRefParameter */
+ ImageRefParameter: {
+ /**
+ * Image Name
+ * @description The name of a gallery image
+ */
+ image_name: string;
+ };
+ /** ImageReferenceParameter */
+ ImageReferenceParameter: {
+ /**
+ * @description discriminator enum property added by openapi-typescript
+ * @enum {string}
+ */
+ kind: "image";
+ /**
+ * Image Name
+ * @description The name of a gallery image
+ */
+ image_name: string;
+ /**
+ * Detail
+ * @description The reference image's detail mode
+ */
+ detail?: ("max" | "match") | null;
+ };
/**
* Resize Image
* @description Resizes an image to specific dimensions
@@ -47181,6 +47309,20 @@ export type components = {
*/
type: "video";
};
+ /** VideoLoRARecallParameter */
+ VideoLoRARecallParameter: {
+ /**
+ * Model Name
+ * @description The name (or key) of the LoRA model
+ */
+ model_name: string;
+ /**
+ * Weight
+ * @description The weight for the LoRA
+ * @default 1
+ */
+ weight?: number;
+ };
/** VideoNamesBatch */
VideoNamesBatch: {
/**
@@ -47249,6 +47391,312 @@ export type components = {
*/
type: "video_output";
};
+ /** VideoRecallMediaResponse */
+ VideoRecallMediaResponse: {
+ /**
+ * Status
+ * @constant
+ */
+ status: "success";
+ /** Queue Id */
+ queue_id: string;
+ /**
+ * Action
+ * @enum {string}
+ */
+ action: "parameters" | "initial_video" | "reference_video";
+ video: components["schemas"]["VideoDTO"];
+ /**
+ * Uploaded
+ * @description Whether the video was uploaded into the gallery by this request
+ */
+ uploaded: boolean;
+ };
+ /**
+ * VideoRecallParameter
+ * @description Video generation parameters to apply to the Video panel.
+ *
+ * Field names follow the video metadata record (see the Media Metadata architecture doc). Models
+ * are given by name (or key) and resolved to installed models; media by gallery name. Bounds are
+ * the ones the Video panel accepts, so a value it would ignore is refused here instead.
+ */
+ VideoRecallParameter: {
+ /**
+ * Positive Prompt
+ * @description Positive prompt text
+ */
+ positive_prompt?: string | null;
+ /**
+ * Negative Prompt
+ * @description Negative prompt text; an explicit null turns the negative prompt off
+ */
+ negative_prompt?: string | null;
+ /**
+ * Seed
+ * @description Random seed; ignored when remixing
+ */
+ seed?: number | null;
+ /**
+ * Num Frames
+ * @description Number of frames to generate
+ */
+ num_frames?: number | null;
+ /**
+ * Fps
+ * @description Output frame rate
+ */
+ fps?: number | null;
+ /**
+ * Width
+ * @description Output width in pixels
+ */
+ width?: number | null;
+ /**
+ * Height
+ * @description Output height in pixels
+ */
+ height?: number | null;
+ /**
+ * Steps
+ * @description Number of denoising steps
+ */
+ steps?: number | null;
+ /**
+ * Cfg Scale
+ * @description CFG scale
+ */
+ cfg_scale?: number | null;
+ /**
+ * Wan Guidance Scale Low Noise
+ * @description Wan A14B: the low-noise expert's CFG scale
+ */
+ wan_guidance_scale_low_noise?: number | null;
+ /**
+ * Ltx2 Audio Cfg Scale
+ * @description LTX-2: audio CFG scale
+ */
+ ltx2_audio_cfg_scale?: number | null;
+ /**
+ * Ltx2 Stg Scale
+ * @description LTX-2: spatiotemporal guidance scale
+ */
+ ltx2_stg_scale?: number | null;
+ /**
+ * Ltx2 Modality Scale
+ * @description LTX-2: modality guidance scale
+ */
+ ltx2_modality_scale?: number | null;
+ /**
+ * Ltx2 Context Frames
+ * @description LTX-2: frames of the initial video an extension continues from
+ */
+ ltx2_context_frames?: number | null;
+ /**
+ * Minimax H3 Hybrid Start Block
+ * @description MiniMax H3 Ref2VA: first block taken from the hybrid FL2VA base
+ */
+ minimax_h3_hybrid_start_block?: number | null;
+ /**
+ * Model
+ * @description The main video model's name (or key)
+ */
+ model?: string | null;
+ /**
+ * Vae
+ * @description Wan: a standalone VAE's name (or key)
+ */
+ vae?: string | null;
+ /**
+ * Wan T5 Encoder Model
+ * @description Wan: standalone UMT5 encoder
+ */
+ wan_t5_encoder_model?: string | null;
+ /**
+ * Wan Transformer Low Noise
+ * @description Wan A14B: low-noise expert
+ */
+ wan_transformer_low_noise?: string | null;
+ /**
+ * Wan Component Source
+ * @description Wan: Diffusers component source
+ */
+ wan_component_source?: string | null;
+ /**
+ * Minimax H3 Transformer Model
+ * @description MiniMax H3: transformer override
+ */
+ minimax_h3_transformer_model?: string | null;
+ /**
+ * Minimax H3 Component Source
+ * @description MiniMax H3: Diffusers component source
+ */
+ minimax_h3_component_source?: string | null;
+ /**
+ * Minimax H3 Text Encoder Model
+ * @description MiniMax H3: Qwen3-VL encoder
+ */
+ minimax_h3_text_encoder_model?: string | null;
+ /**
+ * Minimax H3 Hybrid Base Model
+ * @description MiniMax H3 Ref2VA: FL2VA base
+ */
+ minimax_h3_hybrid_base_model?: string | null;
+ /**
+ * Ltx2 Component Source
+ * @description LTX-2: component source
+ */
+ ltx2_component_source?: string | null;
+ /**
+ * Ltx2 Text Encoder Model
+ * @description LTX-2: Gemma-4 encoder
+ */
+ ltx2_text_encoder_model?: string | null;
+ /**
+ * Loras
+ * @description LoRAs with their weights; an empty list asks for none
+ */
+ loras?: components["schemas"]["VideoLoRARecallParameter"][] | null;
+ /** @description First-frame image */
+ first_frame_image?: components["schemas"]["ImageRefParameter"] | null;
+ /** @description Last-frame image */
+ last_frame_image?: components["schemas"]["ImageRefParameter"] | null;
+ /** @description Initial video to extend */
+ source_video?: components["schemas"]["VideoRefParameter"] | null;
+ /**
+ * Source Video Start Frame
+ * @description First frame of the initial video to use (inclusive)
+ */
+ source_video_start_frame?: number | null;
+ /**
+ * Source Video End Frame
+ * @description Last frame of the initial video to use (inclusive)
+ */
+ source_video_end_frame?: number | null;
+ /** @description LTX-2: a clip whose audio (or picture) conditions the whole generation */
+ ltx2_conditioning_video?: components["schemas"]["VideoRefParameter"] | null;
+ /**
+ * Ltx2 Conditioning Role
+ * @description LTX-2: which stream of `ltx2_conditioning_video` is the condition; required with it
+ */
+ ltx2_conditioning_role?: ("audio" | "video") | null;
+ /**
+ * Minimax H3 References
+ * @description MiniMax H3 Ref2VA references in conditioning order: at most 3 videos and 9 images; an empty list asks for none
+ */
+ minimax_h3_references?: (components["schemas"]["ImageReferenceParameter"] | components["schemas"]["VideoReferenceParameter"])[] | null;
+ };
+ /** VideoRecallParametersResponse */
+ VideoRecallParametersResponse: {
+ /**
+ * Status
+ * @enum {string}
+ */
+ status: "success" | "no_parameters_provided" | "nothing_resolved";
+ /** Queue Id */
+ queue_id: string;
+ /**
+ * Parameters
+ * @description The resolved parameters sent to the frontend
+ */
+ parameters: {
+ [key: string]: unknown;
+ };
+ /**
+ * Skipped
+ * @description Requested fields dropped because their model or media could not be used
+ */
+ skipped: string[];
+ };
+ /**
+ * VideoRecallRequestedEvent
+ * @description Event model for video_recall_requested
+ */
+ VideoRecallRequestedEvent: {
+ /**
+ * Timestamp
+ * @description The timestamp of the event
+ */
+ timestamp: number;
+ /**
+ * Queue Id
+ * @description The ID of the queue
+ */
+ queue_id: string;
+ /**
+ * User Id
+ * @description The ID of the user whose Video panel the recall targets
+ */
+ user_id: string;
+ /**
+ * Action
+ * @description What the frontend should do with the payload
+ * @enum {string}
+ */
+ action: "parameters" | "initial_video" | "reference_video";
+ /**
+ * Mode
+ * @description For `parameters`: `remix` applies everything except the seed
+ * @default null
+ */
+ mode: ("recall" | "remix") | null;
+ /**
+ * Strict
+ * @description For `parameters`: treat the payload as a whole generation record, clearing omitted LoRAs and media
+ * @default false
+ */
+ strict: boolean;
+ /**
+ * Parameters
+ * @description For `parameters`: recall fields, keyed like the video metadata record
+ * @default null
+ */
+ parameters: {
+ [key: string]: unknown;
+ } | null;
+ /**
+ * @description For `initial_video` and `reference_video`: the video to place
+ * @default null
+ */
+ video: components["schemas"]["VideoRecallVideo"] | null;
+ };
+ /**
+ * VideoRecallVideo
+ * @description The gallery video a video recall places into the Video panel.
+ */
+ VideoRecallVideo: {
+ /**
+ * Video Name
+ * @description The name of the gallery video
+ */
+ video_name: string;
+ /**
+ * Width
+ * @description The video's width in pixels
+ */
+ width: number;
+ /**
+ * Height
+ * @description The video's height in pixels
+ */
+ height: number;
+ /**
+ * Duration
+ * @description The video's duration in seconds
+ */
+ duration: number;
+ /**
+ * Fps
+ * @description The video's frame rate, when known
+ * @default null
+ */
+ fps?: number | null;
+ /**
+ * Media Origin
+ * @description How the video entered the gallery, e.g. `audio_upload` for wrapped audio
+ * @default null
+ */
+ media_origin?: string | null;
+ };
/**
* VideoRecordChanges
* @description Allowed mutations on a video record.
@@ -47274,6 +47722,42 @@ export type components = {
} & {
[key: string]: unknown;
};
+ /** VideoRefParameter */
+ VideoRefParameter: {
+ /**
+ * Video Name
+ * @description The name of a gallery video
+ */
+ video_name: string;
+ };
+ /** VideoReferenceParameter */
+ VideoReferenceParameter: {
+ /**
+ * @description discriminator enum property added by openapi-typescript
+ * @enum {string}
+ */
+ kind: "video";
+ /**
+ * Video Name
+ * @description The name of a gallery video
+ */
+ video_name: string;
+ /**
+ * Conditioning
+ * @description Which of the clip's streams condition the generation
+ */
+ conditioning?: ("video_audio" | "video" | "audio") | null;
+ /**
+ * Start Frame
+ * @description First frame of the clip to use (inclusive)
+ */
+ start_frame?: number | null;
+ /**
+ * End Frame
+ * @description Last frame of the clip to use (inclusive)
+ */
+ end_frame?: number | null;
+ };
/**
* VideoUploadedEvent
* @description Event model for video_uploaded
@@ -58099,6 +58583,253 @@ export interface operations {
};
};
};
+ recall_video_parameters: {
+ parameters: {
+ query?: {
+ /** @description `recall` applies every field; `remix` applies everything except the seed */
+ mode?: "recall" | "remix";
+ /** @description When true, the parameters are treated as a whole generation record: LoRAs and media not included are cleared from the Video panel. When false, only the included fields change. */
+ strict?: boolean;
+ };
+ header?: never;
+ path: {
+ /** @description The queue id to perform this operation on */
+ queue_id: string;
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "application/json": components["schemas"]["VideoRecallParameter"];
+ };
+ };
+ responses: {
+ /** @description Successful Response */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["VideoRecallParametersResponse"];
+ };
+ };
+ /** @description Validation Error */
+ 422: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["HTTPValidationError"];
+ };
+ };
+ };
+ };
+ recall_initial_video: {
+ parameters: {
+ query: {
+ /** @description The name of the gallery video */
+ video_name: string;
+ };
+ header?: never;
+ path: {
+ /** @description The queue id to perform this operation on */
+ queue_id: string;
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Successful Response */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["VideoRecallMediaResponse"];
+ };
+ };
+ /** @description Validation Error */
+ 422: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["HTTPValidationError"];
+ };
+ };
+ };
+ };
+ recall_initial_video_upload: {
+ parameters: {
+ query?: {
+ /** @description The board to upload the video to; Uncategorized when omitted */
+ board_id?: string | null;
+ };
+ header?: never;
+ path: {
+ /** @description The queue id to perform this operation on */
+ queue_id: string;
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "multipart/form-data": {
+ /** File */
+ file: Blob;
+ /**
+ * Metadata
+ * @description The metadata to associate with the video, must be a stringified JSON dict
+ */
+ metadata?: string | null;
+ };
+ };
+ };
+ responses: {
+ /** @description Successful Response */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["VideoRecallMediaResponse"];
+ };
+ };
+ /** @description The video exceeds the upload size limit */
+ 413: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ /** @description The file is not a supported video or audio file */
+ 415: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ /** @description Validation Error */
+ 422: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["HTTPValidationError"];
+ };
+ };
+ /** @description Too many concurrent video uploads */
+ 429: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
+ recall_reference_video: {
+ parameters: {
+ query: {
+ /** @description The name of the gallery video */
+ video_name: string;
+ };
+ header?: never;
+ path: {
+ /** @description The queue id to perform this operation on */
+ queue_id: string;
+ };
+ cookie?: never;
+ };
+ requestBody?: never;
+ responses: {
+ /** @description Successful Response */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["VideoRecallMediaResponse"];
+ };
+ };
+ /** @description Validation Error */
+ 422: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["HTTPValidationError"];
+ };
+ };
+ };
+ };
+ recall_reference_video_upload: {
+ parameters: {
+ query?: {
+ /** @description The board to upload the video to; Uncategorized when omitted */
+ board_id?: string | null;
+ };
+ header?: never;
+ path: {
+ /** @description The queue id to perform this operation on */
+ queue_id: string;
+ };
+ cookie?: never;
+ };
+ requestBody: {
+ content: {
+ "multipart/form-data": {
+ /** File */
+ file: Blob;
+ /**
+ * Metadata
+ * @description The metadata to associate with the video, must be a stringified JSON dict
+ */
+ metadata?: string | null;
+ };
+ };
+ };
+ responses: {
+ /** @description Successful Response */
+ 200: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["VideoRecallMediaResponse"];
+ };
+ };
+ /** @description The video exceeds the upload size limit */
+ 413: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ /** @description The file is not a supported video or audio file */
+ 415: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ /** @description Validation Error */
+ 422: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content: {
+ "application/json": components["schemas"]["HTTPValidationError"];
+ };
+ };
+ /** @description Too many concurrent video uploads */
+ 429: {
+ headers: {
+ [name: string]: unknown;
+ };
+ content?: never;
+ };
+ };
+ };
list_custom_node_packs: {
parameters: {
query?: never;
diff --git a/tests/app/api/test_video_upload_limits.py b/tests/app/api/test_video_upload_limits.py
index 5aeaba32a8..6d7a6118db 100644
--- a/tests/app/api/test_video_upload_limits.py
+++ b/tests/app/api/test_video_upload_limits.py
@@ -167,6 +167,74 @@ def test_other_routes_unaffected():
assert calls == ["other"]
+ ("path", "bounded"),
+ [
+ ("/api/v1/recall/video/default/initial-video/upload", True),
+ ("/api/v1/recall/video/default/reference-video/upload", True),
+ # The name-only siblings carry no body, so they must not compete for upload slots.
+ ("/api/v1/recall/video/default/initial-video", False),
+ ("/api/v1/recall/video/default/reference-video", False),
+ ],
+)
+def test_video_recall_uploads_share_the_video_upload_bound(path: str, bounded: bool):
+ app = FastAPI()
+ calls: list[str] = []
+
+ @app.post(path)
+ async def route() -> dict[str, bool]:
+ calls.append(path)
+ return {"ok": True}
+
+ client = TestClient(VideoUploadLimitASGIMiddleware(app, max_body_bytes=MAX_BODY, max_concurrent=MAX_CONCURRENT))
+
+ response = client.post(path, content=b"x" * (MAX_BODY + 1))
+
+ assert response.status_code == (413 if bounded else 200)
+ assert calls == ([] if bounded else [path])
+
+
+ "path", ["/api/v1/videos/upload", "/api/v1/recall/video/default/reference-video/upload"], ids=["upload", "recall"]
+)
+def test_a_trailing_encoded_newline_does_not_slip_past_the_bound(path: str):
+ """Starlette's `^...$` route regex matches `/upload\n`, so the bound must match it too."""
+ app = FastAPI()
+ calls: list[str] = []
+
+ @app.post(path)
+ async def route() -> dict[str, bool]:
+ calls.append(path)
+ return {"ok": True}
+
+ client = TestClient(VideoUploadLimitASGIMiddleware(app, max_body_bytes=MAX_BODY, max_concurrent=MAX_CONCURRENT))
+
+ assert client.post(f"{path}%0A", content=b"x" * 10).status_code == 200, "the route must still be reachable"
+ response = client.post(f"{path}%0A", content=b"x" * (MAX_BODY + 1))
+
+ assert response.status_code == 413
+ assert calls == [path]
+
+
+def test_a_path_parameter_that_is_only_a_newline_stays_bounded():
+ """`PUT /projects/%0A` routes with project_id "\n"; stripping the newline must not unbound it."""
+ app = FastAPI()
+ calls: list[str] = []
+
+ @app.put("/api/v1/projects/{project_id}")
+ async def update(project_id: str) -> dict[str, bool]:
+ calls.append(project_id)
+ return {"ok": True}
+
+ client = TestClient(api_app.ProjectWriteLimitASGIMiddleware(app, max_body_bytes=MAX_BODY, max_concurrent=2))
+
+ assert client.put("/api/v1/projects/%0A", content=b"x").status_code == 200, "the route must still be reachable"
+ response = client.put("/api/v1/projects/%0A", content=b"x" * (MAX_BODY + 1))
+
+ assert response.status_code == 413
+ assert calls == ["\n"]
+
+
def test_concurrency_bound_returns_429():
app, calls = _build_app()
middleware = VideoUploadLimitASGIMiddleware(app, max_body_bytes=MAX_BODY, max_concurrent=MAX_CONCURRENT)
diff --git a/tests/app/routers/conftest.py b/tests/app/routers/conftest.py
index f9ccfe546c..08de579f71 100644
--- a/tests/app/routers/conftest.py
+++ b/tests/app/routers/conftest.py
@@ -66,6 +66,7 @@ _PATCHED_API_DEPENDENCIES_MODULES = (
"invokeai.app.api.routers.projects",
"invokeai.app.api.routers.boards",
"invokeai.app.api.routers.videos",
+ "invokeai.app.api.routers.video_recall",
)
diff --git a/tests/app/routers/test_multiuser_authorization.py b/tests/app/routers/test_multiuser_authorization.py
index 52e0673bba..9996a89a7e 100644
--- a/tests/app/routers/test_multiuser_authorization.py
+++ b/tests/app/routers/test_multiuser_authorization.py
@@ -3325,6 +3325,30 @@ class TestWebSocketAuth:
# And never to the shared queue room, which would leak to other users.
assert "default" not in room
+ def test_video_recall_is_emitted_once_to_the_owner_only(self, socketio: Any) -> None:
+ """A video recall names the owner's media and no admin UI consumes it, so it goes to the
+ owner's room alone, in one emit: a reference-video recall appends, so a second delivery
+ would add the video twice."""
+ import asyncio
+ from unittest.mock import AsyncMock
+
+ from invokeai.app.services.events.events_common import VideoRecallRequestedEvent, VideoRecallVideo
+
+ event = VideoRecallRequestedEvent.build(
+ queue_id="default",
+ user_id="owner-video",
+ action="reference_video",
+ video=VideoRecallVideo(video_name="clip.mp4", width=832, height=480, duration=5.0),
+ )
+
+ mock_emit = AsyncMock()
+ socketio._sio.emit = mock_emit
+
+ asyncio.run(socketio._handle_queue_event(("video_recall_requested", event)))
+
+ assert mock_emit.call_count == 1
+ assert mock_emit.call_args.kwargs.get("room") == "user:owner-video"
+
class TestCustomNodesAuthorization:
"""Tests that custom_nodes endpoints enforce AdminUserOrDefault.
diff --git a/tests/app/routers/test_upload_events.py b/tests/app/routers/test_upload_events.py
index a251fffe09..4708720958 100644
--- a/tests/app/routers/test_upload_events.py
+++ b/tests/app/routers/test_upload_events.py
@@ -306,6 +306,7 @@ def test_video_upload_announces_the_upload_with_its_board_visibility(
response = _post_video(client, is_intermediate=False)
assert response.status_code == 201
+ assert response.headers["location"] == "/videos/upload.mp4"
events = _upload_events(mock_invoker)
assert len(events) == 1
event = events[0]
diff --git a/tests/app/routers/test_video_recall.py b/tests/app/routers/test_video_recall.py
new file mode 100644
index 0000000000..15460a21b8
--- /dev/null
+++ b/tests/app/routers/test_video_recall.py
@@ -0,0 +1,753 @@
+"""Tests for the video recall router (`/api/v1/recall/video`).
+
+Media records live in the real SQLite stores; the model manager is replaced by a small in-memory
+store because building installable model configs is beside the point here. Each test reads the
+`video_recall_requested` event the router emits, which is the contract the frontend consumes.
+"""
+
+from types import SimpleNamespace
+from typing import Any
+from unittest.mock import MagicMock
+
+import pytest
+from fastapi import status
+from fastapi.testclient import TestClient
+
+from invokeai.app.api.dependencies import ApiDependencies
+from invokeai.app.api.routers import videos
+from invokeai.app.services.board_records.board_records_common import BoardChanges, BoardVisibility
+from invokeai.app.services.events.events_common import VideoRecallRequestedEvent, VideoUploadedEvent
+from invokeai.app.services.image_records.image_records_common import ImageCategory, ResourceOrigin
+from invokeai.app.services.invoker import Invoker
+from invokeai.app.services.model_records.model_records_base import UnknownModelException
+from invokeai.app.services.users.users_common import UserCreateRequest
+from invokeai.app.services.video_records.video_records_common import VideoRecordNotFoundException
+from invokeai.app.services.videos.videos_common import VideoDTO
+from invokeai.backend.model_manager.taxonomy import BaseModelType, ModelType
+
+MP4_BYTES = b"\x00\x00\x00\x18ftypmp42" + b"\x00" * 12
+
+
+class MockApiDependencies(ApiDependencies):
+ invoker: Invoker
+
+ def __init__(self, invoker: Invoker) -> None:
+ self.invoker = invoker
+
+
+def _model(key: str, name: str, base: BaseModelType, model_type: ModelType) -> SimpleNamespace:
+ return SimpleNamespace(key=key, hash=f"blake3:{key}", name=name, base=base, type=model_type)
+
+
+class FakeModelStore:
+ """The two lookups the router makes, over a fixed catalog in install order."""
+
+ def __init__(self, models: list[SimpleNamespace]) -> None:
+ self._models = models
+
+ def get_model(self, key: str) -> SimpleNamespace:
+ for model in self._models:
+ if model.key == key:
+ return model
+ raise UnknownModelException(key)
+
+ def search_by_attr(self, model_name: str, model_type: ModelType) -> list[SimpleNamespace]:
+ return [model for model in self._models if model.name == model_name and model.type == model_type]
+
+
+CATALOG = [
+ # Installed first, so an unguided name lookup would pick the SDXL LoRA over the Wan one.
+ _model("sdxl-lora", "detail", BaseModelType.StableDiffusionXL, ModelType.LoRA),
+ _model("wan-lora", "detail", BaseModelType.Wan, ModelType.LoRA),
+ _model("wan-main", "Wan 2.2 I2V", BaseModelType.Wan, ModelType.Main),
+ _model("wan-t5", "UMT5 XXL", BaseModelType.Any, ModelType.WanT5Encoder),
+ _model("h3-ref2va", "MiniMax H3 Ref2VA", BaseModelType.MiniMaxH3, ModelType.Main),
+ _model("h3-qwen", "Qwen3-VL", BaseModelType.MiniMaxH3, ModelType.Qwen3VLEncoder),
+ # Generic encoders install as base "any"; the H3 and LTX-2 slots must not take them.
+ _model("any-qwen", "Qwen3-VL Generic", BaseModelType.Any, ModelType.Qwen3VLEncoder),
+ _model("any-gemma", "Gemma Generic", BaseModelType.Any, ModelType.Gemma4Encoder),
+ _model("ltx-main", "LTX-2.3", BaseModelType.LTX2, ModelType.Main),
+ _model("ltx-gemma", "Gemma 4", BaseModelType.LTX2, ModelType.Gemma4Encoder),
+ _model("sdxl-vae", "fp16 VAE", BaseModelType.StableDiffusionXL, ModelType.VAE),
+ _model("wan-vae", "Wan VAE", BaseModelType.Wan, ModelType.VAE),
+ _model("sdxl-main", "SDXL Base", BaseModelType.StableDiffusionXL, ModelType.Main),
+ # Two mains sharing a name: the SDXL one is installed first.
+ _model("sdxl-shared", "Shared", BaseModelType.StableDiffusionXL, ModelType.Main),
+ _model("ltx-shared", "Shared", BaseModelType.LTX2, ModelType.Main),
+]
+
+
+def _video_dto(video_name: str, **update: Any) -> VideoDTO:
+ return VideoDTO(
+ video_name=video_name,
+ video_origin=ResourceOrigin.EXTERNAL,
+ video_category=ImageCategory.GENERAL,
+ width=832,
+ height=480,
+ duration=5.0,
+ fps=16.0,
+ created_at="None",
+ updated_at="None",
+ is_intermediate=False,
+ starred=False,
+ has_workflow=False,
+ video_url=f"/videos/{video_name}",
+ thumbnail_url=f"/thumbnails/{video_name}.webp",
+ board_id=None,
+ ).model_copy(update=update)
+
+
+def _save_image(invoker: Invoker, image_name: str, user_id: str = "system") -> None:
+ invoker.services.image_records.save(
+ image_name=image_name,
+ image_origin=ResourceOrigin.INTERNAL,
+ image_category=ImageCategory.GENERAL,
+ width=64,
+ height=64,
+ has_workflow=False,
+ user_id=user_id,
+ )
+
+
+def _save_video(invoker: Invoker, video_name: str, user_id: str = "system") -> None:
+ invoker.services.video_records.save(
+ video_name=video_name,
+ video_origin=ResourceOrigin.INTERNAL,
+ video_category=ImageCategory.GENERAL,
+ width=832,
+ height=480,
+ duration=5.0,
+ fps=16.0,
+ has_workflow=False,
+ user_id=user_id,
+ )
+
+
+def invoker(monkeypatch: Any, mock_invoker: Invoker) -> Invoker:
+ mock_invoker.services.model_manager = SimpleNamespace(store=FakeModelStore(CATALOG)) # type: ignore[assignment]
+ mock_invoker.services.image_moves = MagicMock()
+ mock_invoker.services.image_moves.is_maintenance_active.return_value = False
+
+ def get_dto(video_name: str) -> VideoDTO:
+ if not mock_invoker.services.video_records.exists(video_name):
+ raise VideoRecordNotFoundException(video_name)
+ return _video_dto(video_name)
+
+ mock_invoker.services.videos = MagicMock()
+ mock_invoker.services.videos.get_dto.side_effect = get_dto
+
+ dependencies = MockApiDependencies(mock_invoker)
+ for target in (
+ "invokeai.app.api.routers.video_recall.ApiDependencies",
+ "invokeai.app.api.routers.auth.ApiDependencies",
+ "invokeai.app.api.routers.videos.ApiDependencies",
+ "invokeai.app.api.routers._access.ApiDependencies",
+ "invokeai.app.api.routers.image_move_maintenance.ApiDependencies",
+ "invokeai.app.api.auth_dependencies.ApiDependencies",
+ "invokeai.app.api_app.ApiDependencies",
+ ):
+ monkeypatch.setattr(target, dependencies)
+ return mock_invoker
+
+
+def _recall_events(invoker: Invoker) -> list[VideoRecallRequestedEvent]:
+ return [
+ event
+ for event in invoker.services.events.events # type: ignore[attr-defined]
+ if isinstance(event, VideoRecallRequestedEvent)
+ ]
+
+
+def _only_recall_event(invoker: Invoker) -> VideoRecallRequestedEvent:
+ events = _recall_events(invoker)
+ assert len(events) == 1
+ return events[0]
+
+
+def _identifier(key: str) -> dict[str, Any]:
+ model = next(model for model in CATALOG if model.key == key)
+ return {"key": key, "hash": f"blake3:{key}", "name": model.name, "base": model.base.value, "type": model.type.value}
+
+
+class TestParameterRecall:
+ def test_models_resolve_to_the_identifiers_a_metadata_record_carries(
+ self, invoker: Invoker, client: TestClient
+ ) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default",
+ json={
+ "positive_prompt": "a heron takes flight",
+ "seed": 42,
+ "num_frames": 81,
+ "model": "Wan 2.2 I2V",
+ "wan_t5_encoder_model": "UMT5 XXL",
+ "loras": [{"model_name": "detail", "weight": 0.6}],
+ },
+ )
+
+ assert response.status_code == 200
+ body = response.json()
+ assert body["status"] == "success"
+ assert body["skipped"] == []
+ event = _only_recall_event(invoker)
+ assert event.action == "parameters"
+ assert event.mode == "recall"
+ assert event.strict is False
+ assert event.user_id == "system"
+ assert event.parameters == {
+ "positive_prompt": "a heron takes flight",
+ "seed": 42,
+ "num_frames": 81,
+ "model": _identifier("wan-main"),
+ "wan_t5_encoder_model": _identifier("wan-t5"),
+ # The Wan LoRA wins over the same-named SDXL LoRA installed before it.
+ "loras": [{"model": _identifier("wan-lora"), "weight": 0.6}],
+ }
+ assert body["parameters"] == event.parameters
+
+ def test_a_model_key_is_accepted_in_place_of_a_name(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post("/api/v1/recall/video/default", json={"model": "h3-ref2va"})
+
+ assert response.status_code == 200
+ assert _only_recall_event(invoker).parameters == {"model": _identifier("h3-ref2va")}
+
+ def test_a_key_of_the_wrong_model_type_does_not_fill_the_slot(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post("/api/v1/recall/video/default", json={"model": "wan-lora", "positive_prompt": "p"})
+
+ assert response.json()["skipped"] == ["model"]
+ assert _only_recall_event(invoker).parameters == {"positive_prompt": "p"}
+
+ def test_unresolvable_models_are_skipped_and_the_rest_applied(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default",
+ json={
+ "positive_prompt": "p",
+ "model": "Not Installed",
+ "loras": [{"model_name": "missing"}, {"model_name": "detail", "weight": 1.2}],
+ },
+ )
+
+ body = response.json()
+ assert body["status"] == "success"
+ assert body["skipped"] == ["model", "loras[0]"]
+ assert _only_recall_event(invoker).parameters == {
+ "positive_prompt": "p",
+ "loras": [{"model": _identifier("wan-lora"), "weight": 1.2}],
+ }
+
+ @pytest.mark.parametrize(
+ ("slot", "value", "expected_key"),
+ [
+ ("model", "Shared", "ltx-shared"),
+ ("vae", "Wan VAE", "wan-vae"),
+ ("minimax_h3_text_encoder_model", "Qwen3-VL", "h3-qwen"),
+ ("minimax_h3_component_source", "MiniMax H3 Ref2VA", "h3-ref2va"),
+ ("ltx2_component_source", "LTX-2.3", "ltx-main"),
+ ("ltx2_text_encoder_model", "Gemma 4", "ltx-gemma"),
+ ],
+ )
+ def test_each_slot_resolves_a_model_of_its_own_family(
+ self, invoker: Invoker, client: TestClient, slot: str, value: str, expected_key: str
+ ) -> None:
+ response = client.post("/api/v1/recall/video/default", json={slot: value})
+
+ assert response.json()["skipped"] == []
+ assert _only_recall_event(invoker).parameters == {slot: _identifier(expected_key)}
+
+ @pytest.mark.parametrize(
+ ("slot", "value"),
+ [
+ ("model", "SDXL Base"),
+ ("model", "sdxl-main"),
+ ("vae", "fp16 VAE"),
+ ("wan_component_source", "LTX-2.3"),
+ ("minimax_h3_hybrid_base_model", "Wan 2.2 I2V"),
+ ("ltx2_component_source", "ltx-shared-missing"),
+ ("wan_t5_encoder_model", "Gemma 4"),
+ ("minimax_h3_text_encoder_model", "Qwen3-VL Generic"),
+ ("ltx2_text_encoder_model", "Gemma Generic"),
+ ("ltx2_component_source", "MiniMax H3 Ref2VA"),
+ ("wan_transformer_low_noise", "LTX-2.3"),
+ ],
+ ids=[
+ "non-video-main",
+ "non-video-main-key",
+ "sdxl-vae",
+ "ltx-as-wan-source",
+ "wan-as-h3-base",
+ "missing",
+ "wrong-type",
+ "generic-qwen-as-h3-encoder",
+ "generic-gemma-as-ltx2-encoder",
+ "h3-as-ltx2-source",
+ "ltx2-as-wan-low-noise",
+ ],
+ )
+ def test_a_model_from_another_family_is_skipped_not_delivered(
+ self, invoker: Invoker, client: TestClient, slot: str, value: str
+ ) -> None:
+ response = client.post("/api/v1/recall/video/default", json={slot: value, "positive_prompt": "p"})
+
+ assert response.json()["skipped"] == [slot]
+ assert _only_recall_event(invoker).parameters == {"positive_prompt": "p"}
+
+ def test_a_lora_of_another_family_is_skipped(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default", json={"loras": [{"model_name": "sdxl-lora"}, {"model_name": "wan-lora"}]}
+ )
+
+ assert response.json()["skipped"] == ["loras[0]"]
+ assert _only_recall_event(invoker).parameters == {"loras": [{"model": _identifier("wan-lora"), "weight": 1.0}]}
+
+ @pytest.mark.parametrize(
+ "field",
+ [
+ {"loras": [{"model_name": "missing"}]},
+ {"minimax_h3_references": [{"kind": "image", "image_name": "gone.png"}]},
+ ],
+ ids=["loras", "references"],
+ )
+ def test_a_list_whose_every_entry_was_dropped_leaves_the_panel_list_alone(
+ self, invoker: Invoker, client: TestClient, field: dict[str, Any]
+ ) -> None:
+ """Asking to add a missing LoRA must not turn into "clear every LoRA"."""
+ response = client.post("/api/v1/recall/video/default", json={"positive_prompt": "p", **field})
+
+ assert response.json()["skipped"] == [f"{next(iter(field))}[0]"]
+ assert _only_recall_event(invoker).parameters == {"positive_prompt": "p"}
+
+ def test_an_explicit_null_negative_prompt_is_delivered_to_turn_it_off(
+ self, invoker: Invoker, client: TestClient
+ ) -> None:
+ client.post("/api/v1/recall/video/default", json={"negative_prompt": None})
+
+ assert _only_recall_event(invoker).parameters == {"negative_prompt": None}
+
+ @pytest.mark.parametrize("field", ["loras", "minimax_h3_references"])
+ def test_an_empty_list_is_delivered_as_a_request_for_none(
+ self, invoker: Invoker, client: TestClient, field: str
+ ) -> None:
+ client.post("/api/v1/recall/video/default", json={field: []})
+
+ assert _only_recall_event(invoker).parameters == {field: []}
+
+ def test_remix_never_delivers_the_seed(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default", params={"mode": "remix"}, json={"positive_prompt": "p", "seed": 7}
+ )
+
+ assert response.json()["parameters"] == {"positive_prompt": "p"}
+ event = _only_recall_event(invoker)
+ assert event.mode == "remix"
+ assert event.parameters == {"positive_prompt": "p"}
+
+ def test_strict_is_carried_to_the_frontend(self, invoker: Invoker, client: TestClient) -> None:
+ client.post("/api/v1/recall/video/default", params={"strict": True}, json={"positive_prompt": "p"})
+
+ assert _only_recall_event(invoker).strict is True
+
+ def test_gallery_media_is_delivered_and_missing_media_skipped_with_its_qualifiers(
+ self, invoker: Invoker, client: TestClient
+ ) -> None:
+ _save_image(invoker, "last.png")
+ _save_image(invoker, "ref.png")
+ _save_video(invoker, "ref.mp4")
+
+ response = client.post(
+ "/api/v1/recall/video/default",
+ json={
+ "first_frame_image": {"image_name": "gone.png"},
+ "last_frame_image": {"image_name": "last.png"},
+ "source_video": {"video_name": "gone.mp4"},
+ "source_video_start_frame": 0,
+ "source_video_end_frame": 40,
+ "minimax_h3_references": [
+ {
+ "kind": "video",
+ "video_name": "ref.mp4",
+ "conditioning": "video",
+ "start_frame": 0,
+ "end_frame": 8,
+ },
+ {"kind": "image", "image_name": "gone.png"},
+ {"kind": "image", "image_name": "ref.png", "detail": "max"},
+ ],
+ },
+ )
+
+ assert response.json()["skipped"] == [
+ "first_frame_image",
+ "source_video",
+ "minimax_h3_references[1]",
+ "source_video_start_frame",
+ "source_video_end_frame",
+ ]
+ assert _only_recall_event(invoker).parameters == {
+ "last_frame_image": {"image_name": "last.png"},
+ "minimax_h3_references": [
+ {"kind": "video", "video_name": "ref.mp4", "conditioning": "video", "start_frame": 0, "end_frame": 8},
+ {"kind": "image", "image_name": "ref.png", "detail": "max"},
+ ],
+ }
+
+ def test_trims_and_roles_travel_with_their_media(self, invoker: Invoker, client: TestClient) -> None:
+ _save_video(invoker, "source.mp4")
+ _save_video(invoker, "song.mp4")
+
+ response = client.post(
+ "/api/v1/recall/video/default",
+ json={
+ "source_video": {"video_name": "source.mp4"},
+ "source_video_start_frame": 8,
+ "source_video_end_frame": 40,
+ "ltx2_conditioning_video": {"video_name": "song.mp4"},
+ "ltx2_conditioning_role": "audio",
+ },
+ )
+
+ assert response.json()["skipped"] == []
+ assert _only_recall_event(invoker).parameters == {
+ "source_video": {"video_name": "source.mp4"},
+ "source_video_start_frame": 8,
+ "source_video_end_frame": 40,
+ "ltx2_conditioning_video": {"video_name": "song.mp4"},
+ "ltx2_conditioning_role": "audio",
+ }
+
+ def test_a_missing_conditioning_video_takes_its_role_with_it(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default",
+ json={
+ "positive_prompt": "p",
+ "ltx2_conditioning_video": {"video_name": "gone.mp4"},
+ "ltx2_conditioning_role": "video",
+ },
+ )
+
+ assert response.json()["skipped"] == ["ltx2_conditioning_video", "ltx2_conditioning_role"]
+ assert _only_recall_event(invoker).parameters == {"positive_prompt": "p"}
+
+ def test_trims_sent_without_their_video_are_reported_as_skipped(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default", json={"source_video_start_frame": 0, "source_video_end_frame": 8}
+ )
+
+ assert response.json()["status"] == "nothing_resolved"
+ assert response.json()["skipped"] == ["source_video_start_frame", "source_video_end_frame"]
+ assert _recall_events(invoker) == []
+
+ def test_the_event_carries_the_requested_queue(self, invoker: Invoker, client: TestClient) -> None:
+ client.post("/api/v1/recall/video/queue-b", json={"positive_prompt": "p"})
+
+ assert _only_recall_event(invoker).queue_id == "queue-b"
+
+ def test_an_empty_request_emits_nothing(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post("/api/v1/recall/video/default", json={})
+
+ assert response.status_code == 200
+ assert response.json()["status"] == "no_parameters_provided"
+ assert _recall_events(invoker) == []
+
+ def test_a_request_whose_every_field_was_dropped_emits_nothing(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post("/api/v1/recall/video/default", json={"model": "Not Installed"})
+
+ assert response.json() == {
+ "status": "nothing_resolved",
+ "queue_id": "default",
+ "parameters": {},
+ "skipped": ["model"],
+ }
+ assert _recall_events(invoker) == []
+
+ @pytest.mark.parametrize(
+ "body",
+ [
+ {"cfg_rescale_multiplier": 0.7},
+ {"minimax_h3_references": [{"kind": "audio", "video_name": "x.mp4"}]},
+ {"minimax_h3_references": [{"kind": "image", "video_name": "x.mp4"}]},
+ {"minimax_h3_references": [{"kind": "image", "image_name": f"{i}.png"} for i in range(10)]},
+ {"minimax_h3_references": [{"kind": "video", "video_name": f"{i}.mp4"} for i in range(4)]},
+ {"minimax_h3_references": [{"kind": "video", "video_name": "x.mp4", "start_frame": 0}]},
+ {"source_video": {"video_name": "x.mp4"}, "source_video_start_frame": 9, "source_video_end_frame": 3},
+ {"ltx2_conditioning_video": {"video_name": "x.mp4"}},
+ {"model": ""},
+ {"loras": [{"model_name": "detail"}] * 33},
+ {"seed": 2**32},
+ {"cfg_scale": 0.5},
+ {"fps": 240},
+ ],
+ ids=[
+ "unknown-field",
+ "unknown-reference-kind",
+ "reference-kind-mismatch",
+ "too-many-reference-images",
+ "too-many-reference-videos",
+ "half-a-reference-trim",
+ "inverted-source-trim",
+ "conditioning-video-without-role",
+ "empty-model-name",
+ "too-many-loras",
+ "seed-too-large",
+ "cfg-below-the-panel-floor",
+ "fps-above-the-panel-ceiling",
+ ],
+ )
+ def test_malformed_requests_are_rejected(self, invoker: Invoker, client: TestClient, body: dict[str, Any]) -> None:
+ response = client.post("/api/v1/recall/video/default", json=body)
+
+ assert response.status_code == 422
+ assert _recall_events(invoker) == []
+
+ def test_blocked_during_image_move_maintenance(self, invoker: Invoker, client: TestClient) -> None:
+ invoker.services.image_moves.is_maintenance_active.return_value = True # type: ignore[attr-defined]
+
+ response = client.post("/api/v1/recall/video/default", json={"positive_prompt": "p"})
+
+ assert response.status_code == 409
+ assert _recall_events(invoker) == []
+
+
+class TestGalleryVideoPlacement:
+ @pytest.mark.parametrize(
+ ("path", "action"),
+ [("initial-video", "initial_video"), ("reference-video", "reference_video")],
+ )
+ def test_a_gallery_video_is_delivered_with_the_facts_the_panel_needs(
+ self, invoker: Invoker, client: TestClient, path: str, action: str
+ ) -> None:
+ _save_video(invoker, "clip.mp4")
+
+ response = client.post(f"/api/v1/recall/video/queue-b/{path}", params={"video_name": "clip.mp4"})
+
+ assert response.status_code == 200
+ body = response.json()
+ assert body["queue_id"] == "queue-b"
+ assert body["action"] == action
+ assert body["uploaded"] is False
+ assert body["video"]["video_name"] == "clip.mp4"
+ event = _only_recall_event(invoker)
+ assert event.action == action
+ assert event.queue_id == "queue-b"
+ assert event.parameters is None
+ assert event.video is not None
+ assert event.video.model_dump() == {
+ "video_name": "clip.mp4",
+ "width": 832,
+ "height": 480,
+ "duration": 5.0,
+ "fps": 16.0,
+ "media_origin": None,
+ }
+
+ def test_the_media_origin_travels_with_the_video(self, invoker: Invoker, client: TestClient) -> None:
+ """`audio_upload` tells the panel to default the reference to audio-only conditioning."""
+ _save_video(invoker, "song.mp4")
+ invoker.services.videos.get_dto.side_effect = lambda name: _video_dto(name, media_origin="audio_upload") # type: ignore[attr-defined]
+
+ client.post("/api/v1/recall/video/default/reference-video", params={"video_name": "song.mp4"})
+
+ event = _only_recall_event(invoker)
+ assert event.video is not None and event.video.media_origin == "audio_upload"
+
+ def test_an_unknown_video_is_a_404(self, invoker: Invoker, client: TestClient) -> None:
+ response = client.post("/api/v1/recall/video/default/initial-video", params={"video_name": "nope.mp4"})
+
+ assert response.status_code == 404
+ assert _recall_events(invoker) == []
+
+
+def _create_board(invoker: Invoker, owner_id: str, visibility: BoardVisibility) -> str:
+ board = invoker.services.board_records.save("Board", owner_id)
+ invoker.services.board_records.update(board.board_id, BoardChanges(board_visibility=visibility))
+ return board.board_id
+
+
+def upload_ready(monkeypatch: Any, invoker: Invoker) -> MagicMock:
+ """Stub the ffmpeg-backed probes; returns the `videos.create` mock."""
+ monkeypatch.setattr(
+ videos, "probe_media_streams", lambda path: SimpleNamespace(video_codec="h264", audio_codec="aac")
+ )
+ monkeypatch.setattr(videos, "_probe_decodable_video", lambda path: ((832, 480, 5.0, 16.0), None))
+ create = invoker.services.videos.create # type: ignore[attr-defined]
+ create.return_value = _video_dto("uploaded.mp4")
+ return create
+
+
+class TestUploadedVideoPlacement:
+ def test_an_upload_lands_in_the_gallery_on_the_board_and_is_then_placed(
+ self, invoker: Invoker, client: TestClient, upload_ready: MagicMock
+ ) -> None:
+ board_id = _create_board(invoker, "system", BoardVisibility.Private)
+ upload_ready.return_value = _video_dto("uploaded.mp4", board_id=board_id)
+
+ response = client.post(
+ "/api/v1/recall/video/default/reference-video/upload",
+ params={"board_id": board_id},
+ files={"file": ("clip.mp4", MP4_BYTES, "video/mp4")},
+ )
+
+ assert response.status_code == 200
+ body = response.json()
+ assert body["uploaded"] is True
+ assert body["video"]["video_name"] == "uploaded.mp4"
+ created = upload_ready.call_args.kwargs
+ assert created["board_id"] == board_id
+ assert created["video_category"] == ImageCategory.GENERAL
+ assert created["is_intermediate"] is False
+ events = invoker.services.events.events # type: ignore[attr-defined]
+ uploaded = [event for event in events if isinstance(event, VideoUploadedEvent)]
+ assert [event.video_name for event in uploaded] == ["uploaded.mp4"]
+ recall = _only_recall_event(invoker)
+ assert recall.action == "reference_video"
+ assert recall.video is not None and recall.video.video_name == "uploaded.mp4"
+ # The gallery hears about the video before the panel is asked to use it.
+ assert events.index(uploaded[0]) < events.index(recall)
+
+ def test_an_upload_without_a_board_goes_to_uncategorized(
+ self, invoker: Invoker, client: TestClient, upload_ready: MagicMock
+ ) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default/initial-video/upload",
+ files={"file": ("clip.mp4", MP4_BYTES, "video/mp4")},
+ )
+
+ assert response.status_code == 200
+ assert upload_ready.call_args.kwargs["board_id"] is None
+ assert _only_recall_event(invoker).action == "initial_video"
+
+ def test_a_rejected_upload_places_nothing(
+ self, invoker: Invoker, client: TestClient, upload_ready: MagicMock
+ ) -> None:
+ response = client.post(
+ "/api/v1/recall/video/default/initial-video/upload",
+ files={"file": ("notes.txt", b"hello", "text/plain")},
+ )
+
+ assert response.status_code == 415
+ upload_ready.assert_not_called()
+ assert _recall_events(invoker) == []
+
+
+# --- Multi-user ---------------------------------------------------------------------------------
+
+
+def multiuser(setup_jwt_secret: None, invoker: Invoker, client: TestClient) -> dict[str, Any]:
+ """Enable multi-user mode; returns each user's id and bearer headers."""
+ invoker.services.configuration.multiuser = True
+ users: dict[str, Any] = {}
+ for email, is_admin in (("[email protected]", True), ("[email protected]", False), ("[email protected]", False)):
+ user = invoker.services.users.create(
+ UserCreateRequest(email=email, display_name=email, password="TestPass123", is_admin=is_admin)
+ )
+ login = client.post(
+ "/api/v1/auth/login", json={"email": email, "password": "TestPass123", "remember_me": False}
+ )
+ assert login.status_code == 200
+ users[email.split("@")[0]] = {
+ "id": user.user_id,
+ "headers": {"Authorization": f"Bearer {login.json()['token']}"},
+ }
+ return users
+
+
+class TestMultiUserAccess:
+ @pytest.mark.parametrize(
+ ("method_path", "kwargs"),
+ [
+ ("/api/v1/recall/video/default", {"json": {"positive_prompt": "p"}}),
+ ("/api/v1/recall/video/default/initial-video", {"params": {"video_name": "clip.mp4"}}),
+ ("/api/v1/recall/video/default/reference-video", {"params": {"video_name": "clip.mp4"}}),
+ ("/api/v1/recall/video/default/initial-video/upload", {"files": {"file": ("c.mp4", MP4_BYTES)}}),
+ ("/api/v1/recall/video/default/reference-video/upload", {"files": {"file": ("c.mp4", MP4_BYTES)}}),
+ ],
+ ids=["parameters", "initial-video", "reference-video", "initial-upload", "reference-upload"],
+ )
+ def test_every_route_requires_authentication(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any], method_path: str, kwargs: dict
+ ) -> None:
+ response = client.post(method_path, **kwargs)
+
+ assert response.status_code == status.HTTP_401_UNAUTHORIZED
+ assert _recall_events(invoker) == []
+
+ def test_another_users_private_video_cannot_be_placed(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any]
+ ) -> None:
+ _save_video(invoker, "private.mp4", multiuser["owner"]["id"])
+
+ response = client.post(
+ "/api/v1/recall/video/default/reference-video",
+ params={"video_name": "private.mp4"},
+ headers=multiuser["other"]["headers"],
+ )
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert _recall_events(invoker) == []
+
+ @pytest.mark.parametrize(
+ "body",
+ [
+ {"source_video": {"video_name": "private.mp4"}},
+ {"first_frame_image": {"image_name": "private.png"}},
+ {"last_frame_image": {"image_name": "private.png"}},
+ {"ltx2_conditioning_video": {"video_name": "private.mp4"}, "ltx2_conditioning_role": "audio"},
+ {"minimax_h3_references": [{"kind": "video", "video_name": "private.mp4"}]},
+ {"minimax_h3_references": [{"kind": "image", "image_name": "private.png"}]},
+ ],
+ ids=["source-video", "first-frame", "last-frame", "conditioning-video", "reference-video", "reference-image"],
+ )
+ def test_another_users_private_media_cannot_be_recalled(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any], body: dict[str, Any]
+ ) -> None:
+ _save_video(invoker, "private.mp4", multiuser["owner"]["id"])
+ _save_image(invoker, "private.png", multiuser["owner"]["id"])
+
+ response = client.post("/api/v1/recall/video/default", json=body, headers=multiuser["other"]["headers"])
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ assert _recall_events(invoker) == []
+
+ def test_a_video_on_a_shared_board_can_be_placed_by_another_user(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any]
+ ) -> None:
+ _save_video(invoker, "shared.mp4", multiuser["owner"]["id"])
+ board_id = _create_board(invoker, multiuser["owner"]["id"], BoardVisibility.Shared)
+ invoker.services.board_video_records.add_video_to_board(board_id, "shared.mp4")
+
+ response = client.post(
+ "/api/v1/recall/video/default/initial-video",
+ params={"video_name": "shared.mp4"},
+ headers=multiuser["other"]["headers"],
+ )
+
+ assert response.status_code == 200
+ assert _only_recall_event(invoker).user_id == multiuser["other"]["id"]
+
+ def test_an_upload_to_another_users_board_is_refused_before_ingest(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any], upload_ready: MagicMock
+ ) -> None:
+ # Shared boards are visible to everyone but accept uploads only from their owner.
+ board_id = _create_board(invoker, multiuser["owner"]["id"], BoardVisibility.Shared)
+
+ response = client.post(
+ "/api/v1/recall/video/default/initial-video/upload",
+ params={"board_id": board_id},
+ files={"file": ("clip.mp4", MP4_BYTES, "video/mp4")},
+ headers=multiuser["other"]["headers"],
+ )
+
+ assert response.status_code == status.HTTP_403_FORBIDDEN
+ upload_ready.assert_not_called()
+ assert _recall_events(invoker) == []
+
+ def test_the_event_is_addressed_to_the_caller(
+ self, invoker: Invoker, client: TestClient, multiuser: dict[str, Any]
+ ) -> None:
+ client.post(
+ "/api/v1/recall/video/default", json={"positive_prompt": "p"}, headers=multiuser["other"]["headers"]
+ )
+
+ assert _only_recall_event(invoker).user_id == multiuser["other"]["id"]