@ai-sdk/mistral
Version:
The **[Mistral provider](https://ai-sdk.dev/providers/ai-sdk-providers/mistral)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model, embedding model, and speech model support for Mistral APIs.
109 lines (102 loc) • 4.46 kB
TypeScript
import { ProviderV4, LanguageModelV4, EmbeddingModelV4, SpeechModelV4 } from '@ai-sdk/provider';
import { FetchFunction } from '@ai-sdk/provider-utils';
import { z } from 'zod/v4';
type MistralChatModelId = 'ministral-3b-latest' | 'ministral-8b-latest' | 'ministral-14b-latest' | 'mistral-large-latest' | 'mistral-medium-latest' | 'mistral-medium-3' | 'mistral-large-2512' | 'mistral-medium-2508' | 'mistral-medium-2505' | 'mistral-small-2506' | 'pixtral-large-latest' | 'mistral-medium-3.5' | 'mistral-small-latest' | 'mistral-small-2603' | 'magistral-medium-latest' | 'magistral-small-latest' | 'magistral-medium-2509' | 'magistral-small-2509' | (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>;
reasoningEffort: z.ZodOptional<z.ZodEnum<{
none: "none";
high: "high";
}>>;
}, z.core.$strip>;
type MistralLanguageModelChatOptions = z.infer<typeof mistralLanguageModelChatOptions>;
type MistralEmbeddingModelId = 'mistral-embed' | 'codestral-embed-2505' | (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>;
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | (string & {});
declare const mistralSpeechModelOptions: z.ZodObject<{
refAudio: z.ZodOptional<z.ZodString>;
}, z.core.$strip>;
type MistralSpeechModelOptions = z.infer<typeof mistralSpeechModelOptions>;
interface MistralProvider extends ProviderV4 {
(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 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;
/**
* @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?: 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;
generateId?: () => string;
}
/**
* Create a Mistral AI provider instance.
*/
declare function createMistral(options?: MistralProviderSettings): MistralProvider;
/**
* Default Mistral provider instance.
*/
declare const mistral: MistralProvider;
declare const VERSION: string;
export { type MistralEmbeddingModelOptions, type MistralLanguageModelChatOptions, type MistralLanguageModelChatOptions as MistralLanguageModelOptions, type MistralProvider, type MistralProviderSettings, type MistralSpeechModelId, type MistralSpeechModelOptions, VERSION, createMistral, mistral };