Skip to main content

Class: FallbackVideoProxy

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:108

An IVideoGenerator that wraps an ordered chain of video providers and implements automatic failover for every operation.

Retry chain logic

Providers are tried left-to-right (index 0 first). The first provider that succeeds returns immediately. When a provider throws:

  • If it is NOT the last provider: a video:generate:fallback event is emitted and the next provider is tried.
  • If it IS the last provider: an AggregateError containing every collected error is thrown.
  • If the chain is empty: an Error('No providers in video fallback chain') is thrown immediately.

For the optional imageToVideo operation, providers whose IVideoGenerator.supports returns false for 'image-to-video' are silently skipped, since they are structurally incapable rather than transiently failing.

Implements

Constructors

Constructor

new FallbackVideoProxy(chain, emitter): FallbackVideoProxy

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:134

Creates a new FallbackVideoProxy wrapping the given provider chain.

Parameters

chain

IVideoGenerator[]

Ordered list of video providers to try. Must contain at least one entry for operations to succeed (an empty chain always throws).

emitter

EventEmitter

EventEmitter on which video:generate:fallback events are published so callers can observe the failover path.

Returns

FallbackVideoProxy

Example

const proxy = new FallbackVideoProxy(
[runwayProvider, pikaProvider],
new EventEmitter(),
);

Properties

defaultModelId?

readonly optional defaultModelId: string

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:116

Default model from the first provider, if set.

Implementation of

IVideoGenerator.defaultModelId


isInitialized

readonly isInitialized: boolean = true

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:113

Always true — the proxy is ready as soon as it is constructed.

Implementation of

IVideoGenerator.isInitialized


providerId

readonly providerId: string

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:110

Identifier derived from the first provider in the chain.

Implementation of

IVideoGenerator.providerId

Methods

generateVideo()

generateVideo(request): Promise<VideoResult>

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:182

Generate a video from a text prompt, falling back through the provider chain on failure.

Parameters

request

VideoGenerateRequest

The generation request forwarded to each provider.

Returns

Promise<VideoResult>

The result from the first provider that succeeds.

Throws

When every provider in the chain fails.

Throws

When the chain is empty.

Implementation of

IVideoGenerator.generateVideo


imageToVideo()

imageToVideo(request): Promise<VideoResult>

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:204

Generate a video from a source image, falling back through providers that support image-to-video.

Providers whose IVideoGenerator.supports returns false for 'image-to-video' are silently skipped.

Parameters

request

ImageToVideoRequest

The image-to-video request forwarded to each capable provider.

Returns

Promise<VideoResult>

The result from the first provider that succeeds.

Throws

When every provider fails or does not support image-to-video.

Implementation of

IVideoGenerator.imageToVideo


initialize()

initialize(_config): Promise<void>

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:150

No-op initialisation — individual providers in the chain should already be initialised before being passed to the proxy.

Parameters

_config

Record<string, unknown>

Returns

Promise<void>

Implementation of

IVideoGenerator.initialize


shutdown()

shutdown(): Promise<void>

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:228

Shuts down all providers in the chain. Errors are caught per-provider so a single provider's failure does not prevent the others from cleaning up.

Returns

Promise<void>

Implementation of

IVideoGenerator.shutdown


supports()

supports(capability): boolean

Defined in: packages/agentos/src/core/video/FallbackVideoProxy.ts:165

Returns true if at least one provider in the chain supports the given capability.

Parameters

capability

The capability to query.

"text-to-video" | "image-to-video"

Returns

boolean

Implementation of

IVideoGenerator.supports