Skip to content

feat(sfx): add the VideoToSFX tool that scores a video through the gateway - #1843

Merged
edenreich merged 5 commits into
mainfrom
fix/issue-1839
Nov 15, 2026
Merged

edenreich merged 5 commits into
mainfrom
fix/issue-1839

Conversation

@inference-gateway-maintainer

@inference-gateway-maintainer inference-gateway-maintainer Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Resolves #1839

Summary

Adds the VideoToSFX agent tool: the chat model hands a clip from the working directory (or the TextToVideo output directory) to the gateway's POST /v1/audio/sfx as a multipart/form-data body with a video part, and the answered track is saved with the extension the response content type carries. Like TextToSFX and TextToVideo it holds no provider key (the gateway does), and it stays disabled until video_to_sfx.enabled is true because the user's footage is uploaded to a third party. While video_to_sfx.enabled is false the tool definition is not sent to the LLM at all.

Changes

  • VideoToSFXConfig (enabled, model defaulting to mirelo/sfx-2.0, output_dir defaulting to the sfx media shelf, require_approval) with config validation and the INFER_VIDEO_TO_SFX_* env overrides. The tool is registered only when video_to_sfx.enabled is true
  • New agent/domain.VideoSoundEffectService port and a GatewayEndpoint-backed service: the SDK's CreateSFX only posts JSON, so the service builds the multipart form itself (model, the video file part, optional prompt, duration_seconds, start_offset_seconds, preserve_speech, output) and sends the provider in the query like every other gateway call
  • The request deadline covers the upload plus the gateway's 150 s scoring budget. A 413 names the gateway's SERVER_MAX_REQUEST_BODY_SIZE and other failures pass the gateway's own error message through (string or nested envelope). The saved file's extension follows the response Content-Type
  • VideoToSFX tool with its manifest (video, prompt, seconds, start_seconds, track, preserve_speech, output_path), clip lookup via the shared media-input rule (working directory, then the TextToVideo output directory) and output confined to video_to_sfx.output_dir
  • Tests: config tests, tool unit tests, service tests with a stand-in gateway pinning the wire form (fields, provider query, bearer key), and a full-loop integration test layering the multipart route over the pinned tokenless chat gateway. The same test can move to tokenless scenarios once [FEATURE] Accept the multipart video form on POST /v1/audio/sfx tokenless#99 releases multipart SFX support
  • Golden tool definitions regenerated (51 built-ins) and all NewRegistry call sites updated
  • docs/tools-reference.md gains the VideoToSFX row and section, docs/configuration-reference.md the config block and env mirrors, cspell.yaml the provider name
  • fix: a file already at a named output_path is kept when the answered track carries another extension - the tool removes only the placeholder it allocated - and the clip streams into the multipart form instead of being held twice in memory
  • chore: github.com/inference-gateway/sdk v1.45.0 to v1.46.0, whose generated types document the video scoring fields and the Mirelo provider, sent as a separate deps commit

Downstream

  • inference-gateway/docs - the Audio API page and the CLI tools overview still need the multipart video form and the VideoToSFX tool ([DOCS] issue filed with this run)
  • [FEATURE] Accept the multipart video form on POST /v1/audio/sfx tokenless#99 - releases multipart acceptance on the canned POST /v1/audio/sfx, which unlocks the integration test moving from the in-test layer to the mock scenarios
  • inference-gateway/sdk - the generated client cannot express the multipart form (CreateSFX posts JSON only). The SDKs may want a multipart CreateSFX variant to mirror the gateway contract

v1.46.0 syncs the generated types with schemas v1.13.2 and documents the video scoring fields on CreateSFXRequest together with the Mirelo provider.
…teway

Adds the VideoToSFX agent tool over the gateway's POST /v1/audio/sfx multipart form: a clip from the working directory or the TextToVideo output directory is uploaded as the video part and the answered track is saved with the extension the response content type carries, with prompt, seconds, start_seconds, track, preserve_speech and output_path guiding or confining the request. The tool ships disabled behind video_to_sfx.enabled because the clip is uploaded to a third party, and while it is disabled the definition is not sent to the LLM. The request deadline covers the upload plus the gateway's 150 s scoring budget, a 413 names SERVER_MAX_REQUEST_BODY_SIZE, and other failures pass the gateway's own message through.
The service removed the resolved output path whenever the answered track
carried another extension. That is right for the empty timestamped
placeholder, but it also deleted an earlier track when the caller named
the output. The tool now owns all placeholder cleanup and removes it only
when it allocated one.

Also stream the clip into the multipart form instead of holding it twice
in memory, list VideoToSFX on the sfx media shelf in the directory docs,
and bring the new doc comments and tests in line with AGENTS.md.
The scored track was a bare string checked against literals in the tool.
It is now the domain's SoundEffectTrack with a catalog and Valid, and the
manifest offers the same values as a JSON schema enum.

The rest of the new code drops its literals too: the multipart form
fields, the route and provider query parameter, the argument names, the
shortest scored window, the output file prefix and default extension, the
media type to extension table and the sfx media shelf. The model id is
split with the existing config.ParseModel.
The domain declared its own SoundEffectTrack with the same three values
the SDK already generates as CreateSFXRequestOutput, Valid included. The
request now carries the SDK type and the duplicate enum, its catalog and
its Valid method are gone.
@edenreich
edenreich merged commit 321e7de into main Nov 15, 2026
1 check passed
@edenreich
edenreich deleted the fix/issue-1839 branch November 15, 2026 13:11
edenreich added a commit that referenced this pull request Nov 15, 2026
…s API (#1844)

Resolves #1840

## Summary

Adds the DubVideo agent tool: a Mirelo model dub of an existing clip
through the gateway's Videos API. The tool posts the multipart create to
POST /v1/videos, polls the job with the TextToVideo polling code and its
timeout and poll_interval knobs, and downloads the finished MP4 from
/content. It is registered only when both video_to_sfx.enabled and
video_to_sfx.dub are true - the switch pattern CreateAvatar uses under
text_to_video - and its description states Mirelo's limit that only the
generated mix is laid onto the clip, so it offers no track parameter.

The video_to_sfx block itself landed on main with the VideoToSFX tool
(#1843) while this PR was open. This PR now adds only the dub switch to
it, so video_to_sfx.enabled registers VideoToSFX as on main and DubVideo
needs enabled and dub together.

The SDK (v1.46.0) carries the dubbing fields in CreateVideoRequest but
its hand-written CreateVideo encoder drops them, so the dub create rides
a small CLI-side gateway (agentinfra.DubGateway) that posts the same
multipart form with bearer auth and provider routing. The SDK client
keeps covering retrieve and content download, and go.mod ends this PR
byte-identical to main.

## Changes

- config: a dub switch on the existing video_to_sfx block, next to
enabled, model, output_dir and require_approval
- agent domain: VideoDubRequest and a Dub method on the VideoService
interface
- agent infrastructure: Dub creates the job through the injected
DubGateway (multipart create with the video part and preserve_speech),
then shares TextToVideo's finishVideoJob (poll, download, write). The
clip is checked against the gateway's 10 MiB body limit before sending
- container: wires DubGateway from the gatewayEndpoint that VideoToSFX
already uses (base URL, bearer key and the propagated gateway transport)
- gateway supervisor: the auto-started gateway also gets
VIDEOS_ENABLED=true while the dub switch is on
- tools: DubVideo.yaml manifest, DubVideoTool (video looked up in the
working directory, then the TextToVideo output directory, bare
output_path into text_to_video.output_dir), ToolDubVideo constant,
registry gating, the videoExtensions list shared with VideoToSFX, and
the golden tool definitions snapshot (52 tools)
- tests: a whitespace-trimming case and a table-driven validation test
in the video_to_sfx config tests, infrastructure Dub tests against a
stubbed Videos API, tool unit and registry tests, and a full-loop
integration test (DubVideoToolAgainstMockGateway)
- docs: DubVideo row and section in tools-reference.md, a Dubbing
section in text-to-video.md, and the dub key and INFER_VIDEO_TO_SFX_DUB
in the video_to_sfx section of configuration-reference.md, which now
covers both tools

## Downstream impact

- inference-gateway/sdk: CreateVideo drops the video part and
preserve_speech/start_offset_seconds that schemas v1.14.0 added (sync PR
inference-gateway/sdk#253 regenerated the types only) - filed
inference-gateway/sdk#254. Once a release forwards these fields, the CLI
can route the dub create back through sdk.Client.CreateVideo and retire
the small gateway.
- inference-gateway/gateway: dubbing shipped in v0.66.0 and nothing is
needed there beyond VIDEOS_ENABLED=true, which the CLI now sets for the
auto-started gateway while the dub switch is on.
- docs site ticket: inference-gateway/docs#1219 (the in-repo docs are
already part of this PR).

---------

Co-authored-by: inference-gateway-maintainer[bot] <246577062+inference-gateway-maintainer[bot]@users.noreply.github.com>
Co-authored-by: Eden Reich <[email protected]>
@edenreich edenreich moved this from Todo to Done in 2026 Nov 15, 2026
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.262.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@inference-gateway-releaser inference-gateway-releaser Bot added the released Shipped in a release label Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[FEATURE] Add a VideoToSFX tool that scores a video through the gateway

1 participant