@mastra/core
Version:
68 lines • 2.89 kB
TypeScript
import type { LanguageModelV2, LanguageModelV2CallOptions } from '../../_types/@ai-sdk_provider-v5/dist/index.d.ts';
import type { StreamTransport } from '../../stream/types.js';
import type { MastraModelGatewayInterface } from './gateways/base.js';
import type { ModelRouterModelId } from './provider-registry.js';
import type { MastraLanguageModelV2, OpenAICompatibleConfig } from './shared.types.js';
export { defaultGateways, gateways } from './gateways/defaults.js';
type StreamResult = Awaited<ReturnType<LanguageModelV2['doStream']>>;
export declare class ModelRouterLanguageModel implements MastraLanguageModelV2 {
#private;
readonly specificationVersion: "v2";
readonly defaultObjectGenerationMode: "json";
readonly supportsStructuredOutputs = true;
readonly supportsImageUrls = true;
/**
* Supported URL patterns by media type for the provider.
* This is a lazy promise that resolves the underlying model's supportedUrls.
* Models like Mistral define which URL patterns they support (e.g., application/pdf for https URLs).
*
* @see https://github.com/mastra-ai/mastra/issues/12152
*/
readonly supportedUrls: PromiseLike<Record<string, RegExp[]>>;
readonly modelId: string;
readonly provider: string;
readonly gatewayId: string;
private config;
private gateway;
private _supportedUrlsPromise;
private readonly instanceGatewayCache;
constructor(config: ModelRouterModelId | OpenAICompatibleConfig, customGateways?: MastraModelGatewayInterface[]);
/**
* Lazily resolves the underlying model's supportedUrls.
* This is cached to avoid multiple model resolutions.
* @internal
*/
private _resolveSupportedUrls;
/**
* Fetches supportedUrls from the underlying model.
* @internal
*/
private _fetchSupportedUrls;
/** @internal */
_getStreamTransport(): StreamTransport | undefined;
/**
* Custom serialization for tracing/observability spans.
* Excludes `config` (holds apiKey, headers, url) and `gateway`
* (may hold proxy credentials or cached tokens) so they cannot leak
* into telemetry backends.
*/
serializeForSpan(): {
specificationVersion: 'v2';
modelId: string;
provider: string;
gatewayId: string;
};
private getGatewayCache;
private shouldUseInstanceGatewayCache;
private setStreamTransportHandle;
private resolveAuth;
private setStreamTransportFromCache;
private stripUnsupportedSamplingParams;
doGenerate(options: LanguageModelV2CallOptions): Promise<StreamResult>;
doStream(options: LanguageModelV2CallOptions): Promise<StreamResult>;
private resolveLanguageModel;
private resolveOpenAIWebSocketModel;
private static _clearCachesForTests;
private static gatewayCaches;
}
//# sourceMappingURL=router.d.ts.map