agentai-video
Video generation for AgentAI.
Video APIs are asynchronous: VideoProvider::submit sends a request and returns a VideoJob, you follow it
with VideoProvider::status and, when it is JobStatus::Completed, fetch the video with
VideoProvider::download. Polling is up to you.
use Duration;
use ;
// The provider comes from the prefix of the model name, its settings from environment
// variables (`COMFY_SERVE_BASE_URL` here)
let provider = from_model?;
let job = provider
.submit
.await?;
loop
let video = provider.download.await?; // a `Media`, base64 or a URL
- A
VideoJobcan be stored (serde) and given back, possibly to a new provider, after a restart. A job does not record which provider made it, so store the provider and model name next to it. - Three input modes in
VideoInputs: none (text-to-video),Frames { first, last }(image-to-video) andReferences(VideoReferences)(reference images, videos and audio). A provider that cannot send an input returnsUnsupported. - Unset options (duration, resolution, aspect ratio, seed) are not sent and values are not checked here: the API reports the ones it does not accept.
list_modelsreturnsVideoModels with what a model accepts.Nonein a list means the provider does not say, not that the option is unsupported;Some(vec![])means there is nothing to choose.
| Prefix | Settings | Cancel | Inputs |
|---|---|---|---|
comfy-serve |
COMFY_SERVE_BASE_URL (required), COMFY_SERVE_API_KEY (optional) |
yes | first and last frames; image, video and audio references; files are uploaded as multipart |
openrouter |
OPENROUTER_API_KEY (required), OPENROUTER_BASE_URL (optional) |
no | first and last frames and image references, sent as URLs or data URLs |
To change timeouts or the proxy, build the provider yourself (ComfyServeVideoProvider::new(model, api_key, base_url)) and give it your own client with with_http_client(ReqwestClient::from_client(client)).
ReqwestClient, HttpClient and the other HTTP types are re-exported from agentai_video, as are Media and
mime, so you need no direct agentai-core dependency. Implement VideoProvider for other APIs.
Files: mime::from_path("first.jpg") guesses the type of an input file for Media::from_bytes, and
video.extension() gives the file extension of a downloaded video's type (for example mp4 or webm).
Limits: files travel in memory as Media (base64 or a URL); there is no waiting helper, no retries and no
timeouts of its own; there are no agent tools, the crate does not depend on agentai.
TLS features as in agentai: rustls-ring (default), rustls-aws-lc, native-tls, system-proxy.
See the generate_video example: it prints what the model accepts, takes an optional first frame and the
optional AGENTAI_VIDEO_RESOLUTION and AGENTAI_VIDEO_DURATION (seconds), and saves the video in video/.