Creates a new FallbackImageProxy wrapping the given provider chain.
Ordered list of image providers to try. Must contain at least one entry for operations to succeed (an empty chain always throws).
EventEmitter on which image:fallback events are
published so callers can observe the failover path.
const proxy = new FallbackImageProxy(
[openaiProvider, stabilityProvider],
new EventEmitter(),
);
Generate an image, falling back through the provider chain on failure.
The generation request forwarded to each provider.
The result from the first provider that succeeds.
When every provider in the chain fails.
When the chain is empty.
Edit an image, falling back through providers that support editing.
Providers that do not implement editImage or that throw a
*NotSupportedError are silently skipped.
The edit request forwarded to each capable provider.
The result from the first provider that succeeds.
When every provider fails or does not support editing.
Upscale an image, falling back through providers that support upscaling.
The upscale request forwarded to each capable provider.
The result from the first provider that succeeds.
When every provider fails or does not support upscaling.
Generate variations of an image, falling back through providers that support the operation.
The variation request forwarded to each capable provider.
The result from the first provider that succeeds.
When every provider fails or does not support variations.
Returns the model list from the first provider in the chain that
implements listAvailableModels. Returns an empty array when none do.
Readonly providerIdentifier derived from the first provider in the chain.
Readonly isAlways true — the proxy is ready as soon as it is constructed.
Optional Readonly defaultDefault model from the first provider, if set.
An IImageProvider that wraps an ordered chain of image 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:
image:fallbackevent is emitted and the next provider is tried.AggregateErrorcontaining every collected error is thrown.Error('No providers in image fallback chain')is thrown immediately.For optional operations (edit/upscale/variate), providers that do not implement the method or throw a
*NotSupportedErrorare silently skipped, since they are structurally incapable rather than transiently failing.