/** * @license * Copyright 2026 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { BaseLlm } from './base_llm.js'; import { BaseLlmConnection } from './base_llm_connection.js'; import { LlmRequest } from './llm_request.js'; import { LlmResponse } from './llm_response.js'; /** * Type definition for a function that selects a model based on the request. */ export type LlmRouter = (models: Readonly>, request: LlmRequest, errorContext?: { failedKeys: ReadonlySet; lastError: unknown; }) => Promise | string | undefined; /** * A BaseLlm implementation that delegates to one of multiple models based on a router function. */ export declare class RoutedLlm extends BaseLlm { private readonly models; private readonly router; constructor({ models, router, modelName, }: { models: Readonly> | BaseLlm[]; router: LlmRouter; modelName?: string; }); /** * Generates content by delegating to the selected model. */ generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator; /** * Creates a live connection to the LLM by delegating to the selected model. * This live connection cannot be switched mid-stream, it is tied to the model * selected at the time of connection. */ connect(llmRequest: LlmRequest): Promise; }