Class FallbackVideoProxy

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

  • 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<DefaultEventMap>

      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(),
    );

Methods

Properties

providerId: string

Identifier derived from the first provider in the chain.

isInitialized: boolean = true

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

defaultModelId?: string

Default model from the first provider, if set.