AxMultiServiceRouter
Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L49
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L75
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L191
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L218
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
getEstimatedCost()
getEstimatedCost(modelUsage?: AxModelUsage): number;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L390
Parameters
| Parameter | Type |
|---|---|
modelUsage? | AxModelUsage |
Returns
number
Implementation of
getFeatures()
getFeatures(model?: TModelKey): AxAIFeatures;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L327
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L293
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L150
Returns
unknown
Implementation of
AxAIService.getLastUsedChatModel
getLastUsedEmbedModel()
getLastUsedEmbedModel(): unknown;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L153
Returns
unknown
Implementation of
AxAIService.getLastUsedEmbedModel
getLastUsedModelConfig()
getLastUsedModelConfig(): AxModelConfig | undefined;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L156
Returns
AxModelConfig | undefined
Implementation of
AxAIService.getLastUsedModelConfig
getLogger()
getLogger(): AxLoggerFunction;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L417
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L371
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L309
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L302
Returns the name of this router.
Returns
string
Implementation of
getOptions()
getOptions(): Readonly<AxAIServiceOptions>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L409
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
openChatSession()
openChatSession(req: Readonly<AxChatRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxChatSession>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L177
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxChatRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxChatSession>
Implementation of
resolveChatService()
resolveChatService(req: Readonly<AxChatRequest<TModelKey>>): Promise<{
model?: string;
service: Readonly<AxAIService<unknown, unknown, any>>;
}>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L163
Delegates the chat call to the service matching the provided model key.
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxChatRequest<TModelKey>> |
Returns
Promise<{
model?: string;
service: Readonly<AxAIService<unknown, unknown, any>>;
}>
Implementation of
AxAIService.resolveChatService
setOptions()
setOptions(options: Readonly<AxAIServiceOptions>): void;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L398
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/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L437
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
speak()
speak(req: Readonly<AxSpeechRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxChatAudioOutput>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L269
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxSpeechRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxChatAudioOutput>
Implementation of
transcribe()
transcribe(req: Readonly<AxTranscriptionRequest<TModelKey>>, options?: Readonly<AxAIServiceOptions>): Promise<AxTranscriptionResponse>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L246
Parameters
| Parameter | Type |
|---|---|
req | Readonly<AxTranscriptionRequest<TModelKey>> |
options? | Readonly<AxAIServiceOptions> |
Returns
Promise<AxTranscriptionResponse>
Implementation of
create()
static create<TServices>(services: TServices): AxMultiServiceRouter<TServices, ExtractAllModelKeys<TServices>>;Defined in: https://github.com/ax-llm/ax/blob/3d5aa8dac28a2637e4150f022dcd02e6fc3309f0/src/ax/ai/multiservice.ts#L140
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>>