UNPKG

@mastra/core

Version:

Mastra is a framework for building AI-powered applications and agents with a modern TypeScript stack.

73 lines 3.12 kB
import type { LanguageModelV2, LanguageModelV2CallOptions } from '@ai-sdk/provider-v5'; import type { StreamTransport } from '../../stream/types.js'; import type { MastraModelGateway } from './gateways/base.js'; import { MastraGateway } from './gateways/mastra.js'; import { ModelsDevGateway } from './gateways/models-dev.js'; import { NetlifyGateway } from './gateways/netlify.js'; import type { ModelRouterModelId } from './provider-registry.js'; import type { MastraLanguageModelV2, OpenAICompatibleConfig } from './shared.types.js'; type StreamResult = Awaited<ReturnType<LanguageModelV2['doStream']>>; export declare const defaultGateways: (ModelsDevGateway | NetlifyGateway | MastraGateway)[]; /** * @deprecated Use defaultGateways instead. This export will be removed in a future version. */ export declare const gateways: (ModelsDevGateway | NetlifyGateway | MastraGateway)[]; 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?: MastraModelGateway[]); /** * 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 setStreamTransportHandle; private setStreamTransportFromCache; doGenerate(options: LanguageModelV2CallOptions): Promise<StreamResult>; doStream(options: LanguageModelV2CallOptions): Promise<StreamResult>; private resolveLanguageModel; private resolveOpenAIWebSocketModel; private static _clearCachesForTests; private static gatewayCaches; } export {}; //# sourceMappingURL=router.d.ts.map