UNPKG

@ai-sdk/mistral

Version:
461 lines • 17.2 kB
import { EmbeddingModelV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig, Experimental_RealtimeModelV4Transport, Experimental_RealtimeModelV4TransportOptions, LanguageModelV4, ModelCapabilities, ModelCapability, ProviderV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider"; import { FetchFunction, InferSchema, Resolvable, WebSocketConstructor } from "@ai-sdk/provider-utils"; import { z } from "zod/v4"; //#region src/mistral-model-catalog.d.ts type TranscriptionCapabilities = NonNullable<ModelCapabilities['transcription']> & { languageWithTimestamps: boolean; timestamps: ModelCapability; diarization: ModelCapability; contextBias: ModelCapability; }; type SpeechCapabilities = NonNullable<ModelCapabilities['speech']> & { savedVoices: ModelCapability; referenceAudio: ModelCapability; nonStreaming: boolean; outputFormats: readonly string[]; }; declare const languageModelDefinitions: { 'labs-leanstral-1-5': true; 'magistral-medium-latest': true; 'magistral-small-latest': true; 'ministral-14b-latest': true; 'ministral-8b-latest': true; 'mistral-large-latest': true; 'mistral-medium-latest': true; 'mistral-small-latest': true; 'voxtral-small-latest': false; 'zai-glm-5-2': false; 'codestral-2508': undefined; 'codestral-latest': undefined; 'glm-5-2': undefined; 'labs-leanstral-1-5-1': undefined; 'ministral-14b-2512': undefined; 'ministral-3b-2512': undefined; 'ministral-3b-latest': undefined; 'ministral-8b-2512': undefined; 'mistral-code-fim-latest': undefined; 'mistral-code-latest': undefined; 'mistral-large-2512': undefined; 'mistral-large-4': undefined; 'mistral-large-4-0': undefined; 'mistral-medium': undefined; 'mistral-medium-2604': undefined; 'mistral-medium-3': undefined; 'mistral-medium-3-5': undefined; 'mistral-medium-3.5': undefined; 'mistral-small-2603': undefined; 'mistral-vibe-cli-fast': undefined; 'mistral-vibe-cli-latest': undefined; 'mistral-vibe-cli-with-tools': undefined; 'voxtral-small-2507': undefined; 'zai-glm-5': undefined; 'zai-glm-5-3': undefined; 'zai-glm-5-3-flash': undefined; 'zai-glm-latest': undefined; }; declare const mistralEmbeddingModelEntries: { 'mistral-embed': { capabilities: { embedding: { defaultDimensions: number; customDimensions: boolean; }; }; providerOptions: { embedding: Record<"metadata" | "outputDimension" | "outputDtype", ModelCapability>; }; }; 'codestral-embed': { capabilities: { embedding: { defaultDimensions: number; customDimensions: boolean; }; }; providerOptions: { embedding: Record<"metadata" | "outputDimension" | "outputDtype", ModelCapability>; }; }; 'codestral-embed-2505': undefined; 'mistral-embed-2312': undefined; }; declare const mistralSpeechModelEntries: { 'voxtral-mini-tts-3-0': { capabilities: { speech: SpeechCapabilities; }; providerOptions: { speech: Record<"refAudio" | "expressiveness" | "phonemeHints", ModelCapability>; }; }; 'voxtral-mini-tts-2603': { capabilities: { speech: SpeechCapabilities; }; providerOptions: { speech: Record<"refAudio" | "expressiveness" | "phonemeHints", ModelCapability>; }; }; 'voxtral-mini-tts-3': undefined; 'voxtral-mini-tts-latest': undefined; }; declare const mistralTranscriptionModelEntries: { 'voxtral-mini-transcribe-3-0': { capabilities: { transcription: TranscriptionCapabilities; }; providerOptions: { transcription: Record<"language" | "returnLanguage" | "temperature" | "timestampGranularities" | "diarize" | "contextBias" | "targetStreamingDelayMs" | "speakerReferences" | "turnDetection", ModelCapability>; }; }; 'voxtral-small-transcribe-3-0': { capabilities: { transcription: TranscriptionCapabilities; }; providerOptions: { transcription: Record<"language" | "returnLanguage" | "temperature" | "timestampGranularities" | "diarize" | "contextBias" | "targetStreamingDelayMs" | "speakerReferences" | "turnDetection", ModelCapability>; }; }; 'voxtral-mini-latest': { capabilities: { transcription: TranscriptionCapabilities; }; providerOptions: { transcription: Record<"language" | "returnLanguage" | "temperature" | "timestampGranularities" | "diarize" | "contextBias" | "targetStreamingDelayMs" | "speakerReferences" | "turnDetection", ModelCapability>; }; }; 'voxtral-mini-2602': undefined; 'voxtral-mini-transcribe-3': undefined; 'voxtral-mini-transcribe-latest': undefined; 'voxtral-mini-transcribe-realtime-3': undefined; 'voxtral-mini-transcribe-realtime-3-0': undefined; 'voxtral-small-transcribe-3': undefined; 'voxtral-small-transcribe-latest': undefined; }; /** Known model IDs, derived from the declarations used to build the catalog. */ type MistralModelIds = { language: keyof typeof languageModelDefinitions; embedding: keyof typeof mistralEmbeddingModelEntries; speech: keyof typeof mistralSpeechModelEntries; transcription: keyof typeof mistralTranscriptionModelEntries; }; //#endregion //#region src/mistral-chat-language-model-options.d.ts type MistralChatModelId = MistralModelIds['language'] | (string & {}); declare const mistralLanguageModelChatOptions: () => z.ZodObject<{ safePrompt: z.ZodOptional<z.ZodBoolean>; documentImageLimit: z.ZodOptional<z.ZodNumber>; documentPageLimit: z.ZodOptional<z.ZodNumber>; structuredOutputs: z.ZodOptional<z.ZodBoolean>; strictJsonSchema: z.ZodOptional<z.ZodBoolean>; parallelToolCalls: z.ZodOptional<z.ZodBoolean>; promptCacheKey: z.ZodOptional<z.ZodString>; reasoningEffort: z.ZodOptional<z.ZodEnum<{ high: "high"; none: "none"; low: "low"; medium: "medium"; max: "max"; }>>; }, z.core.$strip>; type MistralLanguageModelChatOptions = z.infer<ReturnType<typeof mistralLanguageModelChatOptions>>; //#endregion //#region src/mistral-embedding-model-options.d.ts type MistralEmbeddingModelId = MistralModelIds['embedding'] | (string & {}); declare const mistralEmbeddingModelOptions: z.ZodObject<{ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; outputDimension: z.ZodOptional<z.ZodNumber>; outputDtype: z.ZodOptional<z.ZodEnum<{ float: "float"; int8: "int8"; uint8: "uint8"; binary: "binary"; ubinary: "ubinary"; }>>; }, z.core.$strip>; type MistralEmbeddingModelOptions = z.infer<typeof mistralEmbeddingModelOptions>; //#endregion //#region src/mistral-speech-model-options.d.ts type MistralSpeechModelId = MistralModelIds['speech'] | (string & {}); declare const mistralSpeechModelOptions: import("@ai-sdk/provider-utils").LazySchema<{ refAudio?: string | undefined; expressiveness?: number | undefined; phonemeHints?: Record<string, string[]> | undefined; }>; type MistralSpeechModelOptions = InferSchema<typeof mistralSpeechModelOptions>; //#endregion //#region src/mistral-transcription-model-options.d.ts type MistralTranscriptionModelId = MistralModelIds['transcription'] | (string & {}); declare const mistralTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{ language?: string | undefined; returnLanguage?: boolean | undefined; temperature?: number | undefined; timestampGranularities?: ("segment" | "word")[] | undefined; diarize?: boolean | undefined; contextBias?: string[] | undefined; targetStreamingDelayMs?: number | undefined; speakerReferences?: Record<string, string> | undefined; turnDetection?: { startThreshold?: number | undefined; eagerEndThreshold?: number | undefined; endThreshold?: number | undefined; minSilenceMs?: number | undefined; endTimeoutMs?: number | undefined; } | undefined; }>; type MistralTranscriptionModelOptions = InferSchema<typeof mistralTranscriptionModelOptions>; //#endregion //#region src/tool/index.d.ts declare const mistralTools: { webSearch: (args?: Parameters<import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{ arguments: string; }, { info?: Record<string, import("@ai-sdk/provider").JSONValue>; }, {}, {}>>[0]) => import("@ai-sdk/provider-utils").ProviderExecutedTool<{ arguments: string; }, { info?: Record<string, import("@ai-sdk/provider").JSONValue>; }, {}>; webSearchPremium: (args?: Parameters<import("@ai-sdk/provider-utils").ProviderExecutedToolFactory<{ arguments: string; }, { info?: Record<string, import("@ai-sdk/provider").JSONValue>; }, {}, {}>>[0]) => import("@ai-sdk/provider-utils").ProviderExecutedTool<{ arguments: string; }, { info?: Record<string, import("@ai-sdk/provider").JSONValue>; }, {}>; }; //#endregion //#region src/realtime/mistral-realtime-transport.d.ts /** LiveKit stays inside the Mistral provider and is loaded only on connection. */ declare class MistralRealtimeTransport implements Experimental_RealtimeModelV4Transport { private readonly options; private room?; private session?; private api?; private started; private closed; private accepting; private ready; private failed; private reconnecting; private agentDisconnected; private agentCheckQueued; private abort; private setup?; private cleanup?; private removeAbortListener?; private removeRoomListeners?; private resolveAgent?; private incoming; private deliveries; private pendingEvents; private pendingCount; private pendingBytes; private finalizedSegments; private captureVersion; private captureOperations; private sourceStream?; private ownedTracks; private microphone?; private playbackEnabled; private agentSpeaking; private remoteAudio; private pendingTools; constructor(options: Experimental_RealtimeModelV4TransportOptions); connect({ api, sessionConfig, stream, capture, abortSignal }: Parameters<Experimental_RealtimeModelV4Transport['connect']>[0]): Promise<void>; private open; sendEvent(event: Experimental_RealtimeModelV4ClientEvent, shouldSend?: () => boolean): Promise<void>; private updateSession; private handleToolCall; startCapture(stream?: MediaStream): Promise<void>; stopCapture(): Promise<void>; private releaseMicrophone; private stopOwnedTrack; stopPlayback(): void; resumePlayback(): Promise<void>; private receive; private emit; private findAgent; private checkAgentDisconnect; private assertOpen; private untilAborted; private fail; finish(): Promise<void>; private removeRemoteTrack; close(): Promise<void>; dispose(): void; } //#endregion //#region src/realtime/mistral-realtime-model.d.ts /** A managed Mistral voice agent with provider-owned LiveKit transport. */ declare class MistralRealtimeModel implements Experimental_RealtimeModelV4 { readonly modelId: MistralChatModelId; readonly specificationVersion = "v4"; readonly provider = "mistral.realtime"; readonly capabilities: { readonly conversation: "turn-based"; readonly transports: readonly ["webrtc"]; readonly connections: readonly ["provider"]; readonly startup: "session-update"; readonly finalization: "transport-close"; }; constructor(modelId: MistralChatModelId); createTransport(options: Experimental_RealtimeModelV4TransportOptions): MistralRealtimeTransport; parseServerEvent(raw: unknown): import("@ai-sdk/provider").Experimental_RealtimeModelV4ServerEvent[]; serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent): never; buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig): Promise<Record<string, unknown>>; } //#endregion //#region src/realtime/mistral-realtime-factory.d.ts /** Credentials for one browser voice conversation. */ type MistralRealtimeSession = { id: string; participantToken: string; serverUrl: string; }; interface MistralRealtimeFactory { (modelId: MistralChatModelId): MistralRealtimeModel; /** Server-only: create a voice session using the Mistral API key. */ createSession(options: { model: MistralChatModelId; sessionConfig?: Experimental_RealtimeModelV4SessionConfig; abortSignal?: AbortSignal; }): Promise<MistralRealtimeSession>; /** Server-only: release a voice session after the browser disconnects. */ closeSession(options: { sessionId: string; abortSignal?: AbortSignal; }): Promise<void>; } //#endregion //#region src/mistral-provider.d.ts interface MistralProvider extends ProviderV4 { tools: typeof mistralTools; /** Creates managed voice agents and their server-side sessions. */ experimental_realtime: MistralRealtimeFactory; (modelId: MistralChatModelId): LanguageModelV4; /** * Creates a model for text generation. */ languageModel(modelId: MistralChatModelId): LanguageModelV4; /** * Creates a model for text generation. */ chat(modelId: MistralChatModelId): LanguageModelV4; /** * Creates a model using the Conversations API, with support for web search. */ conversation(modelId: MistralChatModelId): LanguageModelV4; /** * Creates a model for text embeddings. */ embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4; /** * Creates a model for text embeddings. */ embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV4; /** * Creates a model for speech generation (text-to-speech). */ speech(modelId: MistralSpeechModelId): SpeechModelV4; /** * Creates a model for speech generation (text-to-speech). */ speechModel(modelId: MistralSpeechModelId): SpeechModelV4; /** * Creates a model for audio transcription. */ transcription(modelId: MistralTranscriptionModelId): TranscriptionModelV4; /** * Creates a model for audio transcription. */ transcriptionModel(modelId: MistralTranscriptionModelId): TranscriptionModelV4; /** * @deprecated Use `embedding` instead. */ textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4; /** * @deprecated Use `embeddingModel` instead. */ textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV4; } interface MistralProviderSettings { /** * Use a different URL prefix for API calls, e.g. to use proxy servers. * The default prefix is `https://api.mistral.ai/v1`. */ baseURL?: string; /** * API key that is being send using the `Authorization` header. * It defaults to the `MISTRAL_API_KEY` environment variable. */ apiKey?: Resolvable<string>; /** * Custom headers to include in the requests. */ headers?: Record<string, string>; /** * Custom fetch implementation. You can use it as a middleware to intercept requests, * or to provide a custom fetch implementation for e.g. testing. */ fetch?: FetchFunction; /** * WebSocket implementation for realtime transcription. Use a header-capable * implementation such as `ws` to send Mistral's Authorization header. */ webSocket?: WebSocketConstructor; generateId?: () => string; } /** * Create a Mistral AI provider instance. */ export declare function createMistral(options?: MistralProviderSettings): MistralProvider; /** * Default Mistral provider instance. */ export declare const mistral: MistralProvider; //#endregion //#region src/mistral-conversation-language-model-options.d.ts type MistralLanguageModelConversationOptions = MistralLanguageModelChatOptions; //#endregion //#region src/realtime/mistral-realtime-model-options.d.ts declare const mistralRealtimeModelOptions: import("@ai-sdk/provider-utils").LazySchema<{ stt?: { model?: string | undefined; language?: string | undefined; contextBias?: string[] | undefined; targetStreamingDelayMs?: number | undefined; turnDetection?: { startThreshold?: number | undefined; eagerEndThreshold?: number | undefined; endThreshold?: number | undefined; minSilenceMs?: number | undefined; endTimeoutMs?: number | undefined; } | undefined; } | undefined; tts?: { model?: string | undefined; voiceId?: string | undefined; phonemeHints?: Record<string, string[]> | undefined; } | undefined; turn?: { allowInterruptions?: boolean | undefined; inactivity?: { timeoutMs?: number | undefined; maxReminders?: number | undefined; messages?: string[] | undefined; } | undefined; } | undefined; welcomeMessage?: string | undefined; agentId?: string | undefined; agentVersion?: number | undefined; }>; type MistralRealtimeModelOptions = InferSchema<typeof mistralRealtimeModelOptions>; //#endregion //#region src/version.d.ts export declare const VERSION: string; //#endregion export type { MistralRealtimeFactory as Experimental_MistralRealtimeFactory, MistralRealtimeModelOptions as Experimental_MistralRealtimeModelOptions, MistralRealtimeSession as Experimental_MistralRealtimeSession, MistralEmbeddingModelOptions, MistralLanguageModelChatOptions, MistralLanguageModelChatOptions as MistralLanguageModelOptions, MistralLanguageModelConversationOptions, MistralProvider, MistralProviderSettings, MistralSpeechModelId, MistralSpeechModelOptions, MistralTranscriptionModelId, MistralTranscriptionModelOptions }; //# sourceMappingURL=index.d.ts.map