import { ModelContract } from "../contracts/model.contract.mjs"; import { FallbackModelContract, FallbackModelOptions } from "../contracts/fallback-model.contract.mjs"; //#region ../ai/src/model/fallback-model.d.ts /** * A `ModelContract` that wraps an ordered list of models and tries each * in turn, advancing to the next only when the current one fails with a * matching (transient) provider error. * * **Role.** A drop-in `ModelContract` for resilience: hand it to any * agent / workflow / supervisor in place of a single model and provider * outages, rate-limits, and timeouts transparently fail over to a * backup. Non-transient failures (bad key, oversized prompt, blocked * content) re-throw immediately rather than wastefully retrying. * * **What it owns / doesn't own.** Owns the ordered model list, the * retry decision, and per-call usage aggregation across attempted * models. Does NOT own retry/backoff timing (it advances instantly to * the next model — pair it with a backoff middleware if you want delay) * nor any provider I/O of its own; every call is delegated to a wrapped * model. * * **Streaming fall-over caveat.** `stream()` can only fail over while no * chunk has been emitted yet. Once the first `delta` / `tool-call` * reaches the consumer, the partial output cannot be un-sent, so a * mid-stream failure propagates instead of restarting on the next * model. * * @example * const model = fallbackModel([ * ai.openai.model({ name: "gpt-4o" }), * ai.anthropic.model({ name: "claude-3-5-sonnet" }), * ]); * const agent = ai.agent({ model }); * * @example * // custom retry predicate * const model = fallbackModel([primary, backup], { * retryOn: (error) => error instanceof ProviderError, * }); */ declare function fallbackModel(models: ModelContract[], options?: FallbackModelOptions): FallbackModelContract; //#endregion export { fallbackModel }; //# sourceMappingURL=fallback-model.d.mts.map