Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ This directory is the entry point for the repository's shared documentation. The
| [Business CLI](guides/cli.md) | Querying, editing, and generating through a terminal or Agent Shell | Commands, authorization, or receipt semantics change |
| [DeepSeek Harness plugin](../plugins/deepseek-harness/README.md) | Installing the DSH bundle and editing an OpenDirector project from DSH | Plugin setup, tools, or creation workflows change |
| [Video model capabilities](guides/video-model-capabilities.md) ([中文](guides/video-model-capabilities.zh-CN.md)) | Declaring output specifications supported by a service | Configuration fields or capability integration changes |
| [Video gateway](guides/video-gateway.md) ([中文](guides/video-gateway.zh-CN.md)) | Serving several H3 LoRA variants from one vLLM-Omni server through the gateway started with the application | Gateway configuration keys, startup, or rewrite behavior change |
| [Model availability / 模型可用状态](guides/model-availability.md) | Optional runtime declarations, automatic checks, shared admission and API/CLI/Agent queries | Capability protocol, refresh, or acceptance rules change |
| [OpenAI Images](guides/openai-images.md) | Wiring gpt-image as an optional image service, request shape and failures | Integration fields, capability scope, or the OpenAI interface change |
| [Kling video](guides/kling-video.md) ([中文](guides/kling-video.zh-CN.md)) | Optional Kling 4.0 and Flash setup, model-specific inputs, and recovery limits | Kling inputs, model declarations, or recovery behavior change |
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ opendirector canvas --help
opendirector canvas create-generation --help
```

`serve` 和 `dev` 在数据目录存在 `.opendirector/video-gateway.yaml` 时一并启动[视频转发层](video-gateway.zh-CN.md),也可用 `--video-gateway FILE` 指定配置文件。 / `serve` and `dev` also start the [video gateway](video-gateway.md) when `.opendirector/video-gateway.yaml` exists in the data directory, or when `--video-gateway FILE` names a configuration.

普通终端默认连接 `http://127.0.0.1:18000`。使用 `--url` 或 `OPENDIRECTOR_API_URL` 指定服务,使用 `--project` 或 `OPENDIRECTOR_PROJECT_ID` 选择工程。全局选项放在子命令前。

```bash
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ example vLLM's 4096 default) rejects every request with HTTP 400.

For vLLM-Omni video connections, enter fractional seconds directly, for example `6.583333`. The CLI accepts `opendirector video create --duration 6.583333` together with the other required options. Read `opendirector video create --help` and `opendirector model list` first; `inputRules.fractionalDuration` identifies support, and each output's duration list defines the allowed range. H3 can align output to its supported frame count, so inspect the actual result duration before assembling segments.

To use few-step H3 adapters such as Pika Flex Turbo, which need a LoRA and their own step count on every request, or to offer several such variants from one vLLM-Omni server, see the [video gateway](video-gateway.md) that starts with OpenDirector.

For detailed video settings, see [Video model capability configuration](video-model-capabilities.md). When no explicit output specification is provided, use **Auto** or **Service default duration**.

Automatic region selection in images and video matting require a model with segmentation capabilities. Image generation and editing still require the corresponding generation or editing model.
Expand Down
2 changes: 2 additions & 0 deletions docs/guides/user-guide.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ HTTP 400。

vLLM-Omni 视频连接支持直接输入小数秒,例如 `6.583333`。CLI 可使用 `opendirector video create --duration 6.583333` 并填写其余必需参数。先运行 `opendirector video create --help` 和 `opendirector model list`;`inputRules.fractionalDuration` 表示支持小数秒,各输出规格的时长列表定义允许范围。H3 可能按模型支持的帧数对齐,拼接分段前应核对结果的实际时长。

使用 Pika Flex Turbo 等少步数 H3 适配器(每个请求都需要 LoRA 和对应的步数),或想用一个 vLLM-Omni 服务提供多个这样的变体时,参见随 OpenDirector 一起启动的[视频转发层](video-gateway.zh-CN.md)。

## 制作第一支短片

建议先完成一个镜头的生成与导出,再扩展到多段素材。
Expand Down
94 changes: 94 additions & 0 deletions docs/guides/video-gateway.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# Serve several H3 variants from one vLLM-Omni server

[中文](video-gateway.zh-CN.md)

The video gateway is a small local service that OpenDirector starts together with the application. It sits between OpenDirector and your self-hosted [vLLM-Omni](https://github.com/vllm-project/vllm-omni) video servers and lets one server appear as several models, each with its own step count and LoRA, chosen by model name.

## When you need it

vLLM-Omni serves few-step MiniMax-H3 adapters, such as Pika Flex Turbo, from the base weights. Each request must name the adapter in a `lora` field and use that adapter's step count and flow shift, or the server rejects it. OpenDirector's FastH3-Omni video requests carry no `lora` and always ask for 8 steps, so these adapters cannot be used directly.

The gateway adds what the server needs to each request. You do not need it for FastH3 Omni or for base MiniMax-H3, which OpenDirector drives directly.

## Configure it

Create `.opendirector/video-gateway.yaml` in the OpenDirector data directory, beside `models.json`. Start from [`tools/video-gateway/video-gateway.example.yaml`](../../tools/video-gateway/video-gateway.example.yaml), which documents every key.

```yaml
listen:
host: 127.0.0.1
port: 8101

# Requests whose model is not listed below are forwarded here unchanged.
default_backend: http://127.0.0.1:8091

models:
Pika-Labs/Pika-H3-Flex-Turbo-4step:
backend: http://127.0.0.1:8091
backend_model: MiniMaxAI/MiniMax-H3
set:
num_inference_steps: 4
guidance_scale: 1
flow_shift: 12
extra_params:
audio_flow_shift: 3
lora:
name: pika-h3-flex-turbo-4step
path: /path/to/loras/pika_h3_flex_turbo_4step_ref2va.safetensors
scale: 1.0
```

| Key | Meaning |
| --- | --- |
| `backend` | Base URL of the vLLM-Omni server that runs this model |
| `backend_model` | The name that server was started with (`--served-model-name`); defaults to the entry's name |
| `set` | Form fields forced to these values, replacing what the client sent |
| `defaults` | Form fields added only when the client did not send them |
| `extra_params` | Keys forced inside the request's `extra_params` JSON |
| `lora` | `{name, path, scale}` sent as the request's `lora`. `lora: null` removes one the client sent; leaving the key out passes the client's own through |

`lora.path` is a path on the vLLM-Omni server, which may be another machine. The gateway sends it without checking it; the server reports a missing or mismatched file when a request arrives. Start that server with `--lora-backend peft` so that it accepts a per-request `lora`.

Because OpenDirector always sends 8 steps, an entry whose weights need another step count must force it under `set`.

## Start it

`opendirector serve` starts the gateway whenever the configuration file exists, and stops it when the application stops:

```text
Video gateway / 视频转发层: http://127.0.0.1:8101/v1 (.../.opendirector/video-gateway.yaml)
OpenDirector: http://127.0.0.1:8000 (Ctrl+C 退出)
```

To use a file somewhere else, pass it explicitly: `opendirector serve --video-gateway /path/to/video-gateway.yaml`. `opendirector dev` accepts the same option. Without a configuration, no gateway is started.

An invalid file or a busy `listen.port` stops the start with a message that names the problem; nothing is left running. The gateway listens on `127.0.0.1` by default and adds no authentication, so keep it on the loopback address or behind your own access control.

## Connect OpenDirector

In **Settings → Model connections → Video → Add service**, select **vLLM-Omni video API**:

- URL: the gateway, for example `http://127.0.0.1:8101/v1`
- Model ID: a name from `models`
- Request format: **FastH3-Omni (8 steps, multi-asset reference)**

Add one model for each configured name. A model name that is not in the file still works through the gateway when the default backend serves it under that name.

## What the gateway does to a request

- A video creation request (`POST /v1/videos` or `POST /v1/videos/sync`) whose `model` is listed is rewritten as configured and sent to that entry's backend. Uploaded files are carried through unchanged.
- A request for any other model name goes to `default_backend` exactly as it arrived.
- Status queries, downloads and cancellation are relayed to the backend that created the job. After a gateway restart, the backend that answers for a job is looked up again with the caller's credentials.
- Backends are reached directly. Proxy settings in the environment, such as `HTTP_PROXY`, are not applied to them.
- `GET /v1/models` lists the configured names, then the default backend's own.
- Each rewrite is logged with the fields it changed, in the same terminal as the application.

The model table is re-read when the file changes, so you can add a model or change a step count without a restart. A file that fails to load keeps the previous table and logs the reason. A changed `listen` address takes effect at the next start.

## Limits

- The gateway cannot make a server accept a name or an adapter it does not support: the backend still validates what it receives.
- Switching between LoRAs on one server takes extra time the first time each adapter is used.
- A request is held in memory while it is rewritten, up to 768 MiB.
- Only vLLM-Omni video creation is rewritten. Image, audio and chat services do not go through the gateway.
- `opendirector serve` and `opendirector dev` start the gateway; the desktop application does not. To run it on its own, for example beside the desktop application, use `python -m opendirector.video_gateway /path/to/video-gateway.yaml`.
94 changes: 94 additions & 0 deletions docs/guides/video-gateway.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# 用一个 vLLM-Omni 服务提供多个 H3 变体

[English](video-gateway.md)

视频转发层是一个随 OpenDirector 一起启动的本地小服务。它位于 OpenDirector 和自部署的 [vLLM-Omni](https://github.com/vllm-project/vllm-omni) 视频服务之间,让一个服务以多个模型的名义出现,每个模型有自己的步数和 LoRA,按模型名选择。

## 什么时候需要

vLLM-Omni 在原版权重上提供少步数的 MiniMax-H3 适配器,例如 Pika Flex Turbo。每个请求都必须在 `lora` 字段里指明适配器,并使用该适配器对应的步数和流偏移,否则服务会拒绝。OpenDirector 的 FastH3-Omni 视频请求不带 `lora`,步数固定为 8,所以无法直接使用这些适配器。

转发层为每个请求补上服务需要的内容。FastH3 Omni 和原版 MiniMax-H3 不需要它,OpenDirector 可以直接驱动。

## 配置

在 OpenDirector 数据目录中创建 `.opendirector/video-gateway.yaml`,与 `models.json` 放在一起。可以从 [`tools/video-gateway/video-gateway.example.yaml`](../../tools/video-gateway/video-gateway.example.yaml) 开始,其中说明了每个配置项。

```yaml
listen:
host: 127.0.0.1
port: 8101

# 模型名不在下面列表中的请求,原样转发到这里。
default_backend: http://127.0.0.1:8091

models:
Pika-Labs/Pika-H3-Flex-Turbo-4step:
backend: http://127.0.0.1:8091
backend_model: MiniMaxAI/MiniMax-H3
set:
num_inference_steps: 4
guidance_scale: 1
flow_shift: 12
extra_params:
audio_flow_shift: 3
lora:
name: pika-h3-flex-turbo-4step
path: /path/to/loras/pika_h3_flex_turbo_4step_ref2va.safetensors
scale: 1.0
```

| 配置项 | 含义 |
| --- | --- |
| `backend` | 运行该模型的 vLLM-Omni 服务地址 |
| `backend_model` | 该服务启动时使用的名字(`--served-model-name`);默认与条目名相同 |
| `set` | 强制设为这些值的表单字段,覆盖客户端发送的值 |
| `defaults` | 仅在客户端未发送时才补上的表单字段 |
| `extra_params` | 强制写入请求 `extra_params` JSON 的键 |
| `lora` | 作为请求 `lora` 发送的 `{name, path, scale}`。`lora: null` 会去掉客户端发送的 `lora`;不写这一项则保留客户端自己的 |

`lora.path` 是 vLLM-Omni 服务器上的路径,该服务器可能是另一台机器。转发层只发送这个路径,不做检查;文件缺失或不匹配时,由服务在收到请求时报告。该服务需以 `--lora-backend peft` 启动,才会接受请求里的 `lora`。

OpenDirector 发出的步数固定为 8,所以权重需要其他步数的条目必须在 `set` 里强制指定。

## 启动

只要配置文件存在,`opendirector serve` 就会一并启动转发层,并在应用退出时停止它:

```text
Video gateway / 视频转发层: http://127.0.0.1:8101/v1 (.../.opendirector/video-gateway.yaml)
OpenDirector: http://127.0.0.1:8000 (Ctrl+C 退出)
```

配置文件放在别处时,可以显式指定:`opendirector serve --video-gateway /path/to/video-gateway.yaml`。`opendirector dev` 支持同一个选项。没有配置时不会启动转发层。

配置文件无效或 `listen.port` 被占用时,启动会停止并说明原因,不会留下任何进程。转发层默认监听 `127.0.0.1`,不做鉴权,请保持在本机回环地址上,或放在你自己的访问控制之后。

## 接入 OpenDirector

在 **设置 → 模型接入 → 视频 → 添加服务** 中选择 **vLLM-Omni 视频接口**:

- 地址:转发层,例如 `http://127.0.0.1:8101/v1`
- Model ID:`models` 里的一个名字
- 请求格式:**FastH3-Omni(8 步、多素材参考)**

每个配置的名字添加一个模型。不在配置文件里的模型名,只要默认后端以该名字提供服务,经过转发层同样可用。

## 转发层对请求做了什么

- 视频创建请求(`POST /v1/videos` 或 `POST /v1/videos/sync`)的 `model` 在配置里时,按配置改写后发给该条目的后端。上传的文件原样传递。
- 其他模型名的请求原样转给 `default_backend`。
- 状态查询、下载和取消会转给创建该任务的后端。转发层重启后,会带着调用方的凭证重新查找任务所在的后端。
- 转发层直连后端,不使用环境变量里的代理设置(例如 `HTTP_PROXY`)。
- `GET /v1/models` 先列出配置里的名字,再列出默认后端自己的。
- 每次改写都会记录改动了哪些字段,日志与应用在同一个终端里。

配置文件变化时会重新读取模型列表,因此添加模型或修改步数不需要重启。加载失败时继续使用上一份列表,并在日志里说明原因。修改 `listen` 地址在下次启动时生效。

## 限制

- 转发层不能让服务接受它不支持的模型名或适配器:后端仍会校验收到的请求。
- 同一个服务上切换 LoRA,每个适配器第一次使用时会多花一些时间。
- 改写请求时,请求体会完整读入内存,上限 768 MiB。
- 只改写 vLLM-Omni 视频创建请求。图片、音频和对话服务不经过转发层。
- `opendirector serve` 和 `opendirector dev` 会启动转发层,桌面应用不会。需要单独运行时(例如配合桌面应用),使用 `python -m opendirector.video_gateway /path/to/video-gateway.yaml`。
15 changes: 11 additions & 4 deletions packages/core/src/opendirector/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ class LogLevel(str, Enum):

PortOption = Annotated[int, typer.Option(min=1, max=65535, help="Local API port.")]
WebPortOption = Annotated[int, typer.Option(min=1, max=65535, help="Vite development port.")]
VideoGatewayOption = Annotated[Path | None, typer.Option(
"--video-gateway", exists=True, dir_okay=False, readable=True,
help="Video gateway configuration to start with the application; defaults to .opendirector/video-gateway.yaml in the "
"data directory when that file exists. / 随应用启动的视频转发层配置;默认使用数据目录中已存在的 "
".opendirector/video-gateway.yaml。")]


@app.command("desktop", help="Open the desktop application installed with this terminal command. / 打开此终端命令所属的桌面应用。")
Expand All @@ -362,15 +367,17 @@ def desktop():


@app.command("serve", help="Start the API and serve the built application.")
def serve(port: PortOption = 8000, web_port: WebPortOption = 5173, log_level: LogLevel = LogLevel.info):
def serve(port: PortOption = 8000, web_port: WebPortOption = 5173, log_level: LogLevel = LogLevel.info,
video_gateway: VideoGatewayOption = None):
from opendirector.launcher import start
raise typer.Exit(start("serve", port, web_port, log_level.value))
raise typer.Exit(start("serve", port, web_port, log_level.value, video_gateway))


@app.command("dev", help="Start the API and Vite development server.")
def dev(port: PortOption = 8000, web_port: WebPortOption = 5173, log_level: LogLevel = LogLevel.info):
def dev(port: PortOption = 8000, web_port: WebPortOption = 5173, log_level: LogLevel = LogLevel.info,
video_gateway: VideoGatewayOption = None):
from opendirector.launcher import start
raise typer.Exit(start("dev", port, web_port, log_level.value))
raise typer.Exit(start("dev", port, web_port, log_level.value, video_gateway))


def emit(value):
Expand Down
Loading
Loading