Repository navigation
feat(tools): add TextToVideo tool for gateway video generation with lip-synced avatars - #1270
Merged
Merged
Conversation
…ip-synced avatars
Renders a video clip through the gateway's unified Videos API (POST /v1/videos, GET /v1/videos/{id}, GET /v1/videos/{id}/content) behind an opt-in text_to_video config section, defaulting to elevenlabs/creatify-aurora. Avatar plus audio renders lip-sync a portrait to a .wav or .mp3 clip; text-only renders take prompt, seconds and size passthroughs. The service polls the async job every poll_interval until completed or failed and downloads the MP4 content into text_to_video.output_dir; combined avatar plus audio uploads over the gateway's 10 MiB body limit are rejected before sending.
8 tasks
edenreich
reviewed
Sep 22, 2026
…oVideo The gateway serves /v1/videos only with VIDEOS_ENABLED=true, so a CLI-started gateway answered every TextToVideo render with a 404. Set it next to IMAGES_ENABLED for both the container and the binary.
newEnvWithScenarios lost env.gateway when newEnvWithHandler was split out, so every test asserting on gateway requests hit a nil pointer.
…ideo - text_to_video.model (default elevenlabs/veo-3.1-fast-generate-001) renders prompts; text_to_video.avatar_model (default elevenlabs/creatify-aurora) renders lip-synced clips. The default model used to be the avatar-only creatify-aurora, so text-only prompts failed. - Avatars are folders under ~/.infer/avatars/<name>/ holding one or more portrait images; lip-sync models get the first in sort order. A bare image file name still resolves in the working directory. - infer avatars list [--format json] and infer avatars delete <name>. - An unknown avatar name fails with the list of available avatars. - Config validation rejects a negative timeout or poll_interval.
This was referenced Sep 22, 2026
edenreich
marked this pull request as ready for review
September 22, 2026 22:17
…system CodeQL (go/path-injection) could not see through the validName helper, so the tool-argument avatar name reached os.ReadDir and, via the primary image path, os.ReadFile as tainted. Check the name inline in Get, join with filepath.Base(name), and let Delete remove the sanitized name Get returns. Also reject "." explicitly so delete can never target the library root.
4 tasks
…hoto infer avatars create <name> --from <photo> copies the photo in as the primary 01-front image and generates the requested views (default: both three-quarter views; left/right profiles on request) in parallel through the gateway's image edit API with tools.image_edit.model. --quality (default high) and --size (default 1024x1536 portrait) pass through to the provider. An existing avatar is never overwritten, a failed view removes the half-built folder, and the gateway only starts once the name, photo and angles are validated.
edenreich
reviewed
Sep 22, 2026
6 tasks
This was referenced Sep 22, 2026
…rs (#1272) A library avatar in a TextToVideo render without audio now sends every image in its folder as reference_images, so the prompt model keeps the person consistent. Lip-sync renders and one-off image files keep the single input_reference. The gateway rejects the two together, so reference renders send no input_reference at all. The 10 MiB body check counts the reference images.
Phone photos are often stored sideways with an EXIF Orientation tag, and carry camera and GPS metadata. avatars.Create now decodes a JPEG, applies its orientation and re-encodes it, so the library and every provider get an upright image without metadata. Angles are now edited from the stored front image instead of the caller's original file.
CreateAvatar lets the agent build a library avatar from a photo, over the same avatars.Create as infer avatars create: a generated portrait, a selfie sent over a channel, or a Content project's presenter. It is registered only when text_to_video.enabled and the new text_to_video.create_avatar opt-in are both true, and requires approval unless text_to_video.require_approval is set. The photo is a bare file name resolved in the sandboxed working directory, then the session's artifacts directory. It never overwrites, and there is no delete tool.
Closed
4 tasks
8 tasks
CodeQL flagged go/path-injection: the CreateAvatar tool's angles argument reached the generated file name through fmt.Sprintf. Unknown angles were already rejected, but the name was still built from caller input. avatars.Create now swaps each requested angle for the matching Angles key, so file names come only from the library's own angle names.
Contributor
|
🎉 This PR is included in version 0.206.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1257
Resolves #1271
Resolves #1272
Summary
Adds the
TextToVideoagent tool. It renders a video clip through the gateway's Videos API (POST /v1/videos,GET /v1/videos/{id},GET /v1/videos/{id}/content, gateway v0.54+). Given a portrait plus an audio clip, it renders a lip-synced talking clip instead. The tool follows the TextToSFX/TextToMusic template:text_to_videoconfig, off by default because avatar renders send the user's face and voice to a third-party providerVideoServicedomain port with a gateway infrastructure implementationtext_to_video.output_dirOn top of that, the PR ships the avatar library, which also feeds prompt renders as
reference_images(#1272), and aCreateAvatartool (#1271).Changes
CreateVideoRequest.ReferenceImages.text_to_videosection withenabled,model,avatar_model,size,output_dir,timeout,poll_interval,create_avatarandrequire_approval.model(defaultelevenlabs/veo-3.1-fast-generate-001) renders prompts and first-frame shots.avatar_model(defaultelevenlabs/creatify-aurora) renders lip-sync clips.VideoRequest.IsAvatar()picks between them, using the gateway's own rule: audio present means an avatar render.provider/modelids and rejects a negativetimeoutorpoll_interval.INFER_TEXT_TO_VIDEO_*overrides come from the reflective loader.VIDEOS_ENABLED=truewhile the tool is enabled. The gateway only serves/v1/videoswith that flag.VideoServiceport with aVideoRequestvalue.internal/agent/infrastructure/video_service.godoes the rest:RetrieveVideounder thetimeout-bounded contexterror.messageDownloadVideoContentinternal/avatars): each avatar is a folder~/.infer/avatars/<name>/holding one or more portrait images, such as several angles.input_reference.reference_images([FEATURE] Send avatar folder extra images as reference_images #1272), somodelkeeps the person consistent. It sends noinput_referencethen: the gateway rejects the two together (feat(videos): map reference_images to elevenlabs images inference-gateway#689), so this departs from the issue's "remaining images" wording..png/.jpg/.jpeg/.webpfile name still resolves in the working directory for one-off portraits, and stays the first frame./resetdoes not touch the library.avatars.Createdecodes a JPEG, applies its EXIF orientation and re-encodes it.infer avatars create <name> --from <photo>,infer avatars list [--format json]andinfer avatars delete <name>. The desktop uses these instead of re-implementing them ([FEATURE] Avatars: record once, reuse a talking avatar in Content projects desktop#311).createstores the photo as01-frontand generates extra views in parallel through the gateway's image edit API withtools.image_edit.model(defaultopenai/gpt-image-2).--angles ""only copies the photo.--qualitydefaults tohighand--sizeto1024x1536(portrait); both pass through to the provider.internal/agent/tools/create_avatar.go, a thin wrapper overavatars.Create. It covers generated portraits, selfies sent over a channel and Content projects.text_to_video.enabledandtext_to_video.create_avatarare both true.text_to_video.require_approvaloverrides.photois a bare file name resolved in the sandboxed working directory, then the session's artifacts directory, via the sharedresolveMediaInputPath.internal/agent/tools/text_to_video.go): inputs areprompt,seconds,size,avatar,audioandoutput_path, validated as [FEATURE] TextToVideo tool: generate a video clip, optionally lip-synced from a portrait and an audio clip, through the gateway #1257 requires. Input lookups shareresolveMediaInputPath, extracted from TextToSpeech.angles: [], image edit disabled, registry gating, approval default.internal/avatars: list, get, delete and create (including traversal names), EXIF parsing in both byte orders, all 8 orientations, and a sideways photo stored upright without metadata.newEnvWithScenarios, which had dropped the mock-gateway handle.docs/text-to-video.md(models, avatar library, reference images, CreateAvatar, gateway requirements),tools-reference.md,configuration-reference.md,directory-structure.mdand README.Avatars and ElevenLabs
ElevenLabs has no public avatar API yet ("planned for future release"), and
/v1/flows/videohas no avatar id. This PR inlines the images as base64 on each render, so nothing is created at the provider that could be listed or deleted. The only avatars are the local folders managed byinfer avatars. ElevenLabs' Assets API (/v1/assetsupload/list/delete) would allow upload-once-reference-by-id, but that needs schemas, gateway and SDK work first.Cross-repo impact
infer avatars create(angles) and ImageEdit need a gateway release with it.application/octet-stream, the gateway sniffsTextToSpeech's WAV asaudio/wave, and ElevenLabs rejects it with a 422. The out-of-the-box TextToSpeech-to-TextToVideo flow needs that fix; ID3-tagged MP3 works today.TextToVideo,infer avatars).Verification
task precommit:runpasses: mod:tidy, mocks, fmt, lint:imports, golangci-lint (0 issues), markdownlint.task testpasses, andgo test -racepasses oninternal/avatars,internal/agent/tools,internal/agent/infrastructureandconfig.infer avatars create --angles ""stored01-front.jpegupright at 2316x3088 with no EXIF/GPS, in 0.3 s.infer avatars createwith the default angles on v0.55.0 got a 400unsupported_file_mimetypefrom OpenAI (after a key refresh), and the half-built folder was removed.application/octet-stream, and the gateway forwarded that unchanged.infer avatars createproduced01-front.jpeg,02-three-quarter-left.pngand03-three-quarter-right.png(1024x1536, same person, upright, mouth closed) in about 2 minutes.infer avatars createneeds a gateway release with [BUG] !! direct-tool autocomplete shows Agent() with no arguments to pass #690.TextToSpeech"hello world, this is a test" → 1.5 s WAV.TextToVideolip-sync with that WAV returned a 422Input should be 'audio/mpeg' or 'audio/wav', inputaudio/wave, which is [DOCS] Fix docs/ drift found by README-to-codebase audit (phantom refs, broken links, stale config) #686. With an ID3-tagged MP3 it passed validation and got a 402paid_plan_required("This endpoint requires a Pro plan or above") from ElevenLabs.TextToVideoreference render (veo-3.1-fast) with the library avatar reached ElevenLabs and got the same 402, so the gateway accepted thereference_images-only body. A 4-image avatar got the gateway'smodel "veo-3.1-fast-generate-001" accepts at most 3 'reference_images', got 4, which confirms the repeated parts arrive and are parsed.CreateAvatarviainfer tools execute:create_avatarapproval_required: trueby default../and absolute photo paths rejectedangles: []created the avatar with the photo stored uprightgo/path-injectionalerts on the avatar name are fixed (inline guard plusfilepath.Base).