AxMultiServiceRouter
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L43
Type Parameters
| Type Parameter | Default type |
|---|---|
TServices extends readonly ( | AxAIService | AxAIServiceListItem<any, any, any>)[] | readonly AxAIService[] |
TModelKey | ExtractAllModelKeys<TServices> |
Implements
AxAIService<unknown,unknown,TModelKey>
Constructors
Constructor
new AxMultiServiceRouter<TServices, TModelKey>(services: TServices): AxMultiServiceRouter<TServices, TModelKey>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L69
Constructs a new multi-service router. It validates that each service provides a unique set of model keys, then builds a lookup (map) for routing the chat/embed requests.
Parameters
| Parameter | Type |
|---|---|
services | TServices |
Returns
AxMultiServiceRouter<TServices, TModelKey>
Methods
chat()
chat(req: Readonly<AxChatRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<
| AxChatResponse
| ReadableStream<AxChatResponse>>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L157
Delegates the chat call to the service matching the provided model key.
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxChatRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<
| AxChatResponse
| ReadableStream<AxChatResponse>>
Implementation of
embed()
embed(req: Readonly<AxEmbedRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxEmbedResponse>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L184
Delegates the embed call to the service matching the provided embed model key.
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxEmbedRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxEmbedResponse>
Implementation of
getFeatures()
getFeatures(model?: TModelKey): AxAIFeatures;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L248
If a model key is provided, delegate to the corresponding service’s features. Otherwise, returns a default feature set.
Parameters
| Parameter | Type |
|---|---|
model? | TModelKey |
Returns
Implementation of
getId()
getId(): string;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L214
Returns a composite ID built from the IDs of the underlying services.
Returns
string
Implementation of
getLastUsedChatModel()
getLastUsedChatModel(): unknown;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L144
Returns
unknown
Implementation of
AxAIService.getLastUsedChatModel
getLastUsedEmbedModel()
getLastUsedEmbedModel(): unknown;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L147
Returns
unknown
Implementation of
AxAIService.getLastUsedEmbedModel
getLastUsedModelConfig()
getLastUsedModelConfig(): undefined | AxModelConfig;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L150
Returns
undefined | AxModelConfig
Implementation of
AxAIService.getLastUsedModelConfig
getLogger()
getLogger(): AxLoggerFunction;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L333
Returns the logger from the last used service, or falls back to the first service if none has been used.
Returns
Implementation of
getMetrics()
getMetrics(): AxAIServiceMetrics;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L292
Returns aggregated metrics from the underlying service. Uses the metrics from the last service that was used, or falls back to the first service if none has been used.
Returns
Implementation of
getModelList()
getModelList(): AxAIModelList<TModelKey>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L230
Aggregates all available models across the underlying services.
Returns
AxAIModelList<TModelKey>
Implementation of
getName()
getName(): string;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L223
Returns the name of this router.
Returns
string
Implementation of
getOptions()
getOptions(): Readonly<AxAIServiceOptions>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L325
Returns the options from the last used service, or falls back to the first service if none has been used.
Returns
Readonly<AxAIServiceOptions>
Implementation of
setOptions()
setOptions(options: Readonly<AxAIServiceOptions>): void;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L314
Sets options on all underlying services.
Parameters
| Parameter | Type |
|---|---|
options | Readonly<AxAIServiceOptions> |
Returns
void
Implementation of
setServiceEntry()
setServiceEntry(key: TModelKey, entry: object): void;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L353
Sets a service entry for a given key. This method is intended for testing purposes.
Parameters
| Parameter | Type | Description |
|---|---|---|
key | TModelKey | The model key |
entry | { description: string; embedModel?: string; isInternal?: boolean; model?: string; service: AxAIService<unknown, unknown, TModelKey>; } | The service entry to set |
entry.description | string | - |
entry.embedModel? | string | - |
entry.isInternal? | boolean | - |
entry.model? | string | - |
entry.service | AxAIService<unknown, unknown, TModelKey> | - |
Returns
void
create()
static create<TServices>(services: TServices): AxMultiServiceRouter<TServices, ExtractAllModelKeys<TServices>>;
Defined in: https://github.com/ax-llm/ax/blob/d2df625e2c2fd70a090d6321c042579c2819f0d1/src/ax/ai/multiservice.ts#L134
Static factory method for type-safe multi-service router creation with automatic model key inference.
Type Parameters
| Type Parameter |
|---|
TServices extends readonly ( | AxAIService<unknown, unknown, string> | AxAIServiceListItem<any, any, any>)[] |
Parameters
| Parameter | Type |
|---|---|
services | TServices |
Returns
AxMultiServiceRouter<TServices, ExtractAllModelKeys<TServices>>