Skip to main content

Interface: IModelRouter

Defined in: packages/agentos/src/core/llm/routing/IModelRouter.ts:117

Interface for the Model Router. Implementations are responsible for selecting an appropriate AI model and provider based on the given parameters and context.

Properties​

policyTier?​

readonly optional policyTier: "safe" | "standard" | "mature" | "private-adult"

Defined in: packages/agentos/src/core/llm/routing/IModelRouter.ts:126

The content policy tier this router applies when a request carries none. Fallback walkers build a routed call's chain for it. Routers without a default leave it undefined.


routerId​

readonly routerId: string

Defined in: packages/agentos/src/core/llm/routing/IModelRouter.ts:119

A unique identifier for this specific router implementation.

Methods​

initialize()​

initialize(config, providerManager, promptEngine?): Promise<void>

Defined in: packages/agentos/src/core/llm/routing/IModelRouter.ts:140

Async

Initializes the model router with its configuration and necessary dependencies, such as the AIModelProviderManager for accessing information about available models and providers.

Parameters​

config​

Record<string, any>

Router-specific configuration (e.g., rules, model preferences).

providerManager​

any

An instance of AIModelProviderManager or a similar service that provides access to available models and providers.

promptEngine?​

any

Optional: An instance of PromptEngine, if the router uses LLM-based routing decisions.

Returns​

Promise<void>

A promise that resolves upon successful initialization.

Throws​

If initialization fails (e.g., invalid configuration).


selectModel()​

selectModel(params, availableModels?): Promise<ModelRouteResult | null>

Defined in: packages/agentos/src/core/llm/routing/IModelRouter.ts:157

Async

Selects an AI model and provider based on the provided parameters and the router's internal logic.

Parameters​

params​

ModelRouteParams

The parameters and context for the routing decision.

availableModels?​

ModelInfo[]

Optional: A pre-fetched list of available models. If not provided, the router may need to fetch this list from its providerManager.

Returns​

Promise<ModelRouteResult | null>

A promise that resolves with the routing decision, or null if no suitable model/provider could be found that meets the criteria.

Throws​

If a critical error occurs during the selection process.