@ai-sdk/mistral 4.0.69 → 4.0.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +46 -13
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +65 -19
- package/package.json +3 -3
- package/src/mistral-chat-language-model.ts +3 -1
- package/src/mistral-speech-model-options.ts +16 -0
- package/src/mistral-speech-model.ts +2 -0
- package/src/mistral-transcription-model-options.ts +17 -14
- package/src/mistral-transcription-model.ts +20 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.70
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- e104368: Add Voxtral 3 offline transcription and speech model IDs. Support transcription context phrases and detected language, update timestamp validation for Voxtral 3, and expose speech expressiveness and pronunciation hints.
|
|
8
|
+
- 43ad966: Report `interrupted` when a stream ends cleanly without its provider completion signal, preserving partial output without emitting an error solely for the interruption.
|
|
9
|
+
|
|
10
|
+
This applies to OpenAI (Chat, Responses, and Completions), Anthropic, Google (Generate Content and Interactions), Alibaba, Amazon Bedrock Converse, Cohere, DeepSeek, Groq, Hugging Face Responses, Mistral Chat, Moonshot AI, Open Responses, Perplexity, and xAI Responses. It also covers cutoffs in later Anthropic messages and Google automatic continuations.
|
|
11
|
+
|
|
12
|
+
**Compatibility notice:** These streams previously fell back to `other` or omitted the finish part. Applications must now handle `interrupted` in finish-reason switches, mappings, and custom validation. Check `finishReason === 'interrupted'` to detect incomplete responses; interruption alone does not trigger error handling.
|
|
13
|
+
|
|
14
|
+
Explicit unknown completion reasons still map to `other`. Actual provider, parsing, and transport errors retain their error paths; affected error paths that previously left the finish reason as `other` now report `error`. OpenAI-compatible remains unchanged.
|
|
15
|
+
|
|
16
|
+
- Updated dependencies [10026d1]
|
|
17
|
+
- @ai-sdk/provider@4.0.32
|
|
18
|
+
- @ai-sdk/provider-utils@5.0.66
|
|
19
|
+
|
|
3
20
|
## 4.0.69
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -34,16 +34,19 @@ declare const mistralEmbeddingModelOptions: z.ZodObject<{
|
|
|
34
34
|
type MistralEmbeddingModelOptions = z.infer<typeof mistralEmbeddingModelOptions>;
|
|
35
35
|
//#endregion
|
|
36
36
|
//#region src/mistral-speech-model-options.d.ts
|
|
37
|
-
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | 'voxtral-mini-tts-latest' | (string & {});
|
|
37
|
+
type MistralSpeechModelId = 'voxtral-mini-tts-2603' | 'voxtral-mini-tts-3-0' | 'voxtral-mini-tts-3' | 'voxtral-mini-tts-latest' | (string & {});
|
|
38
38
|
declare const mistralSpeechModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
39
39
|
refAudio?: string | undefined;
|
|
40
|
+
expressiveness?: number | undefined;
|
|
41
|
+
phonemeHints?: Record<string, string[]> | undefined;
|
|
40
42
|
}>;
|
|
41
43
|
type MistralSpeechModelOptions = InferSchema<typeof mistralSpeechModelOptions>;
|
|
42
44
|
//#endregion
|
|
43
45
|
//#region src/mistral-transcription-model-options.d.ts
|
|
44
|
-
type MistralTranscriptionModelId = 'voxtral-mini-2602' | 'voxtral-mini-latest' | (string & {});
|
|
46
|
+
type MistralTranscriptionModelId = 'voxtral-mini-2602' | 'voxtral-mini-latest' | 'voxtral-mini-transcribe-3-0' | 'voxtral-mini-transcribe-3' | 'voxtral-mini-transcribe-latest' | 'voxtral-small-transcribe-3-0' | 'voxtral-small-transcribe-3' | 'voxtral-small-transcribe-latest' | (string & {});
|
|
45
47
|
declare const mistralTranscriptionModelOptions: import("@ai-sdk/provider-utils").LazySchema<{
|
|
46
48
|
language?: string | undefined;
|
|
49
|
+
returnLanguage?: boolean | undefined;
|
|
47
50
|
temperature?: number | undefined;
|
|
48
51
|
timestampGranularities?: ("segment" | "word")[] | undefined;
|
|
49
52
|
diarize?: boolean | undefined;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/mistral-chat-language-model-options.ts","../src/mistral-embedding-model-options.ts","../src/mistral-speech-model-options.ts","../src/mistral-transcription-model-options.ts","../src/tool/index.ts","../src/mistral-provider.ts","../src/mistral-conversation-language-model-options.ts","../src/version.ts"],"mappings":";;;;KAIY;cAoCC,uCAA+B,EAAA;;;;;;;;;;;;GA+CxC,EAAA,KAAA;KAKQ,kCAAkC,EAAE,MAC9C,kBAAkB;;;KC3FR;cAOC,8BAA4B,EAAA;;;;;;;;;;GAiBvC,EAAA,KAAA;KAEU,+BAA+B,EAAE,aACpC;;;KCtBG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/mistral-chat-language-model-options.ts","../src/mistral-embedding-model-options.ts","../src/mistral-speech-model-options.ts","../src/mistral-transcription-model-options.ts","../src/tool/index.ts","../src/mistral-provider.ts","../src/mistral-conversation-language-model-options.ts","../src/version.ts"],"mappings":";;;;KAIY;cAoCC,uCAA+B,EAAA;;;;;;;;;;;;GA+CxC,EAAA,KAAA;KAKQ,kCAAkC,EAAE,MAC9C,kBAAkB;;;KC3FR;cAOC,8BAA4B,EAAA;;;;;;;;;;GAiBvC,EAAA,KAAA;KAEU,+BAA+B,EAAE,aACpC;;;KCtBG;cAOC,4DAAyB;;;iBAAzB;;KA2BD,4BAA4B,mBAC/B;;;KCnCG;cAYC,mEAAgC;;;;;;;;KA+CjC,mCAAmC,mBACtC;;;cCjEI;;;;;;;;;;;;;;;;;;;;;;UCwBI,wBAAwB;EACvC,cAAc;GACb,SAAS,qBAAqB;;;;EAK/B,cAAc,SAAS,qBAAqB;;;;EAK5C,KAAK,SAAS,qBAAqB;;;;EAKnC,aAAa,SAAS,qBAAqB;;;;EAK3C,UAAU,SAAS,0BAA0B;;;;EAK7C,iBAAiB,SAAS,4BAA4B;;;;EAKtD,OAAO,SAAS,uBAAuB;;;;EAKvC,YAAY,SAAS,uBAAuB;;;;EAK5C,cAAc,SAAS,8BAA8B;;;;EAKrD,mBACE,SAAS,8BACR;;;;EAKH,cAAc,SAAS,0BAA0B;;;;EAKjD,mBAAmB,SAAS,0BAA0B;;UAGvC;;;;;EAKf;;;;;EAMA;;;;EAKA,UAAU;;;;;EAMV,QAAQ;EAER;;;;;wBAMc,cACd,UAAS,0BACR;;;;qBA6FU,SAAO;;;KCxMR,0CACV;;;qBCZW"}
|
package/dist/index.js
CHANGED
|
@@ -467,7 +467,7 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
467
467
|
fetch: this.config.fetch
|
|
468
468
|
});
|
|
469
469
|
let finishReason = {
|
|
470
|
-
unified: "
|
|
470
|
+
unified: "interrupted",
|
|
471
471
|
raw: void 0
|
|
472
472
|
};
|
|
473
473
|
let usage = void 0;
|
|
@@ -491,6 +491,10 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
491
491
|
rawValue: chunk.rawValue
|
|
492
492
|
});
|
|
493
493
|
if (!chunk.success) {
|
|
494
|
+
finishReason = {
|
|
495
|
+
unified: "error",
|
|
496
|
+
raw: void 0
|
|
497
|
+
};
|
|
494
498
|
controller.enqueue({
|
|
495
499
|
type: "error",
|
|
496
500
|
error: chunk.error
|
|
@@ -1469,13 +1473,24 @@ const MistralTextEmbeddingResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1469
1473
|
})));
|
|
1470
1474
|
//#endregion
|
|
1471
1475
|
//#region src/mistral-speech-model-options.ts
|
|
1472
|
-
const mistralSpeechModelOptions = lazySchema(() => zodSchema(z.object({
|
|
1473
|
-
/**
|
|
1474
|
-
* Base64-encoded reference audio for one-off voice cloning.
|
|
1475
|
-
*
|
|
1476
|
-
* When provided, this takes precedence over the standard `voice` option.
|
|
1477
|
-
*/
|
|
1478
|
-
refAudio: z.string().min(1).optional()
|
|
1476
|
+
const mistralSpeechModelOptions = lazySchema(() => zodSchema(z.object({
|
|
1477
|
+
/**
|
|
1478
|
+
* Base64-encoded reference audio for one-off voice cloning.
|
|
1479
|
+
*
|
|
1480
|
+
* When provided, this takes precedence over the standard `voice` option.
|
|
1481
|
+
*/
|
|
1482
|
+
refAudio: z.string().min(1).optional(),
|
|
1483
|
+
/**
|
|
1484
|
+
* How expressive the speech is, from 1 to 5. Higher values trade voice
|
|
1485
|
+
* similarity and stability for stronger delivery. Supported by Voxtral 3.
|
|
1486
|
+
*/
|
|
1487
|
+
expressiveness: z.number().min(1).max(5).optional(),
|
|
1488
|
+
/**
|
|
1489
|
+
* Pronunciation hints mapping words to lists of IPA phonemes.
|
|
1490
|
+
* Supported by Voxtral 3.
|
|
1491
|
+
*/
|
|
1492
|
+
phonemeHints: z.record(z.string().min(1), z.array(z.string().min(1)).min(1)).optional()
|
|
1493
|
+
})));
|
|
1479
1494
|
//#endregion
|
|
1480
1495
|
//#region src/mistral-speech-model.ts
|
|
1481
1496
|
var MistralSpeechModel = class MistralSpeechModel {
|
|
@@ -1537,6 +1552,8 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1537
1552
|
input: text,
|
|
1538
1553
|
voice_id: refAudio == null ? voice : void 0,
|
|
1539
1554
|
ref_audio: refAudio,
|
|
1555
|
+
expressiveness: mistralOptions?.expressiveness,
|
|
1556
|
+
phoneme_hints: mistralOptions?.phonemeHints,
|
|
1540
1557
|
response_format: responseFormat,
|
|
1541
1558
|
stream: false
|
|
1542
1559
|
};
|
|
@@ -1587,25 +1604,32 @@ const mistralTranscriptionModelOptions = lazySchema(() => zodSchema(z.object({
|
|
|
1587
1604
|
*/
|
|
1588
1605
|
language: z.string().min(1).optional(),
|
|
1589
1606
|
/**
|
|
1607
|
+
* Return the detected language. Cannot be combined with `language`.
|
|
1608
|
+
*/
|
|
1609
|
+
returnLanguage: z.boolean().optional(),
|
|
1610
|
+
/**
|
|
1590
1611
|
* The sampling temperature.
|
|
1591
1612
|
*/
|
|
1592
1613
|
temperature: z.number().optional(),
|
|
1593
1614
|
/**
|
|
1594
1615
|
* The timestamp granularities to include in the transcription response.
|
|
1616
|
+
* Voxtral 3 supports segment timestamps only.
|
|
1595
1617
|
*/
|
|
1596
1618
|
timestampGranularities: z.array(z.enum(["segment", "word"])).min(1).optional(),
|
|
1597
1619
|
/**
|
|
1598
1620
|
* Whether to identify speakers in the transcription.
|
|
1621
|
+
* Voxtral 3 requires segment timestamps when diarization is enabled.
|
|
1599
1622
|
*/
|
|
1600
1623
|
diarize: z.boolean().optional(),
|
|
1601
1624
|
/**
|
|
1602
1625
|
* Words or phrases to guide the model toward correct spellings of names,
|
|
1603
1626
|
* technical terms, or domain-specific vocabulary.
|
|
1604
1627
|
*
|
|
1605
|
-
*
|
|
1606
|
-
*
|
|
1628
|
+
* Voxtral 3 also accepts phrases and descriptions of the recording,
|
|
1629
|
+
* including spaces and punctuation. Entries share the context window
|
|
1630
|
+
* with the audio.
|
|
1607
1631
|
*/
|
|
1608
|
-
contextBias: z.array(z.string().min(1)
|
|
1632
|
+
contextBias: z.array(z.string().min(1)).optional()
|
|
1609
1633
|
})));
|
|
1610
1634
|
//#endregion
|
|
1611
1635
|
//#region src/mistral-transcription-model.ts
|
|
@@ -1634,16 +1658,25 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
1634
1658
|
providerOptions,
|
|
1635
1659
|
schema: mistralTranscriptionModelOptions
|
|
1636
1660
|
});
|
|
1637
|
-
if (
|
|
1661
|
+
if ([
|
|
1662
|
+
"voxtral-mini-2507",
|
|
1663
|
+
"voxtral-mini-2602",
|
|
1664
|
+
"voxtral-mini-latest"
|
|
1665
|
+
].includes(this.modelId) && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1638
1666
|
argument: "providerOptions",
|
|
1639
1667
|
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities"
|
|
1640
1668
|
});
|
|
1669
|
+
if (mistralOptions?.language != null && mistralOptions.returnLanguage) throw new InvalidArgumentError({
|
|
1670
|
+
argument: "providerOptions",
|
|
1671
|
+
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.returnLanguage"
|
|
1672
|
+
});
|
|
1641
1673
|
const formData = new FormData();
|
|
1642
1674
|
const blob = audio instanceof Uint8Array ? new Blob([audio]) : new Blob([convertBase64ToUint8Array(audio)]);
|
|
1643
1675
|
formData.append("model", this.modelId);
|
|
1644
1676
|
formData.append("file", new File([blob], "audio", { type: mediaType }), `audio.${mediaTypeToExtension(mediaType)}`);
|
|
1645
1677
|
if (mistralOptions != null) {
|
|
1646
1678
|
appendFormValue(formData, "language", mistralOptions.language);
|
|
1679
|
+
appendFormValue(formData, "return_language", mistralOptions.returnLanguage);
|
|
1647
1680
|
appendFormValue(formData, "temperature", mistralOptions.temperature);
|
|
1648
1681
|
appendFormValue(formData, "timestamp_granularities", mistralOptions.timestampGranularities);
|
|
1649
1682
|
appendFormValue(formData, "diarize", mistralOptions.diarize);
|
|
@@ -1735,7 +1768,7 @@ const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1735
1768
|
})));
|
|
1736
1769
|
//#endregion
|
|
1737
1770
|
//#region src/version.ts
|
|
1738
|
-
const VERSION = "4.0.
|
|
1771
|
+
const VERSION = "4.0.70";
|
|
1739
1772
|
//#endregion
|
|
1740
1773
|
//#region src/tool/web-search.ts
|
|
1741
1774
|
const inputSchema = lazySchema(() => zodSchema(z.object({ arguments: z.string() })));
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_exhaustiveCheck","_exhaustiveCheck","_exhaustiveCheck","_exhaustiveCheck"],"sources":["../src/convert-mistral-usage.ts","../src/convert-to-mistral-chat-messages.ts","../src/map-mistral-finish-reason.ts","../src/mistral-chat-language-model-options.ts","../src/mistral-error.ts","../src/mistral-prepare-tools.ts","../src/mistral-chat-language-model.ts","../src/convert-to-mistral-conversation-inputs.ts","../src/mistral-conversation-language-model-options.ts","../src/mistral-conversation-prepare-tools.ts","../src/mistral-conversation-language-model.ts","../src/mistral-embedding-model-options.ts","../src/mistral-embedding-model.ts","../src/mistral-speech-model-options.ts","../src/mistral-speech-model.ts","../src/mistral-transcription-model-options.ts","../src/mistral-transcription-model.ts","../src/version.ts","../src/tool/web-search.ts","../src/tool/index.ts","../src/mistral-provider.ts"],"sourcesContent":["import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralPromptTokensDetailsSchema = z\n .object({\n messages: z.array(z.json()).nullish(),\n cached_tokens: z.number().nullish(),\n audio_tokens: z.number().nullish(),\n })\n .catchall(z.json());\n\nconst mistralCompletionTokensDetailsSchema = z\n .object({\n reasoning_tokens: z.number().nullish(),\n })\n .catchall(z.json());\n\nexport const mistralUsageSchema = z\n .object({\n prompt_tokens: z.number(),\n completion_tokens: z.number(),\n total_tokens: z.number(),\n prompt_audio_seconds: z.number().nullish(),\n request_count: z.number().nullish(),\n service_tier: z.string().nullish(),\n num_cached_tokens: z.number().nullish(),\n prompt_tokens_details: mistralPromptTokensDetailsSchema.nullish(),\n prompt_token_details: mistralPromptTokensDetailsSchema.nullish(),\n completion_tokens_details: mistralCompletionTokensDetailsSchema.nullish(),\n })\n .catchall(z.json());\n\nexport type MistralUsage = z.infer<typeof mistralUsageSchema>;\n\nexport function convertMistralUsage(\n usage: MistralUsage | undefined | null,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const promptTokens = usage.prompt_tokens;\n const completionTokens = usage.completion_tokens;\n\n const cacheReadTokens =\n usage.num_cached_tokens ??\n usage.prompt_tokens_details?.cached_tokens ??\n usage.prompt_token_details?.cached_tokens ??\n 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens || undefined,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens,\n text: completionTokens,\n reasoning: undefined,\n },\n raw: usage,\n };\n}\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n} from '@ai-sdk/provider';\nimport type {\n MistralAssistantMessageContent,\n MistralPrompt,\n} from './mistral-chat-prompt';\nimport {\n convertToBase64,\n getTopLevelMediaType,\n resolveFullMediaType,\n} from '@ai-sdk/provider-utils';\n\nfunction formatFileUrl({ part }: { part: LanguageModelV4FilePart }): string {\n if (part.data.type === 'url') {\n return part.data.url.toString();\n }\n\n if (part.data.type === 'data') {\n return `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`;\n }\n\n throw new UnsupportedFunctionalityError({\n functionality: `file part data type ${part.data.type}`,\n });\n}\n\nexport function convertToMistralChatMessages(\n prompt: LanguageModelV4Prompt,\n): MistralPrompt {\n const messages: MistralPrompt = [];\n\n for (let i = 0; i < prompt.length; i++) {\n const { role, content } = prompt[i];\n const isLastMessage = i === prompt.length - 1;\n\n switch (role) {\n case 'system': {\n messages.push({ role: 'system', content });\n break;\n }\n\n case 'user': {\n messages.push({\n role: 'user',\n content: content.map(part => {\n switch (part.type) {\n case 'text': {\n return { type: 'text', text: part.text };\n }\n\n case 'file': {\n switch (part.data.type) {\n case 'reference': {\n throw new UnsupportedFunctionalityError({\n functionality: 'file parts with provider references',\n });\n }\n case 'text': {\n throw new UnsupportedFunctionalityError({\n functionality: 'text file parts',\n });\n }\n case 'url':\n case 'data': {\n const topLevel = getTopLevelMediaType(part.mediaType);\n\n if (topLevel === 'image') {\n return {\n type: 'image_url',\n image_url: formatFileUrl({ part }),\n };\n } else {\n if (part.data.type === 'data') {\n const fullMediaType = resolveFullMediaType({ part });\n if (fullMediaType !== 'application/pdf') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only images and PDF file parts are supported',\n });\n }\n } else if (part.mediaType !== 'application/pdf') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only images and PDF file parts are supported',\n });\n }\n\n return {\n type: 'document_url',\n document_url: formatFileUrl({ part }),\n };\n }\n }\n }\n }\n }\n }),\n });\n break;\n }\n\n case 'assistant': {\n let text = '';\n let hasReasoning = false;\n const contentParts: Array<MistralAssistantMessageContent> = [];\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n text += part.text;\n contentParts.push({ type: 'text', text: part.text });\n break;\n }\n case 'tool-call': {\n toolCalls.push({\n id: part.toolCallId,\n type: 'function',\n function: {\n name: part.toolName,\n arguments: JSON.stringify(part.input),\n },\n });\n break;\n }\n case 'reasoning': {\n hasReasoning = true;\n contentParts.push({\n type: 'thinking',\n thinking: [{ type: 'text', text: part.text }],\n closed: true,\n });\n break;\n }\n default: {\n throw new Error(\n `Unsupported content type in assistant message: ${part.type}`,\n );\n }\n }\n }\n\n messages.push({\n role: 'assistant',\n content: hasReasoning ? contentParts : text,\n prefix: isLastMessage ? true : undefined,\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n });\n\n break;\n }\n case 'tool': {\n for (const toolResponse of content) {\n if (toolResponse.type === 'tool-approval-response') {\n continue;\n }\n const output = toolResponse.output;\n\n let contentValue: string;\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'execution-denied':\n contentValue = output.reason ?? 'Tool call execution denied.';\n break;\n case 'content':\n case 'json':\n case 'error-json':\n contentValue = JSON.stringify(output.value);\n break;\n }\n\n messages.push({\n role: 'tool',\n name: toolResponse.toolName,\n tool_call_id: toolResponse.toolCallId,\n content: contentValue,\n });\n }\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return messages;\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapMistralFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV4FinishReason['unified'] {\n switch (finishReason) {\n case 'stop':\n return 'stop';\n case 'length':\n case 'model_length':\n return 'length';\n case 'tool_calls':\n return 'tool-calls';\n case 'error':\n return 'error';\n default:\n return 'other';\n }\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://docs.mistral.ai/models\nexport type MistralChatModelId =\n | 'codestral-2508'\n | 'codestral-latest'\n | 'glm-5-2'\n | 'labs-leanstral-1-5'\n | 'labs-leanstral-1-5-1'\n | 'magistral-medium-latest'\n | 'magistral-small-latest'\n | 'ministral-14b-2512'\n | 'ministral-14b-latest'\n | 'ministral-3b-2512'\n | 'ministral-3b-latest'\n | 'ministral-8b-2512'\n | 'ministral-8b-latest'\n | 'mistral-code-fim-latest'\n | 'mistral-code-latest'\n | 'mistral-large-4'\n | 'mistral-large-4-0'\n | 'mistral-large-latest'\n | 'mistral-large-2512'\n | 'mistral-medium'\n | 'mistral-medium-latest'\n | 'mistral-medium-2604'\n | 'mistral-medium-3'\n | 'mistral-medium-3-5'\n | 'mistral-medium-3.5'\n | 'mistral-small-2603'\n | 'mistral-small-latest'\n | 'mistral-vibe-cli-fast'\n | 'mistral-vibe-cli-latest'\n | 'mistral-vibe-cli-with-tools'\n | 'voxtral-small-2507'\n | 'voxtral-small-latest'\n | 'zai-glm-5-2'\n | (string & {});\n\nexport const mistralLanguageModelChatOptions = () =>\n z.object({\n /**\n * Whether to inject a safety prompt before all conversations.\n *\n * Defaults to `false`.\n */\n safePrompt: z.boolean().optional(),\n\n documentImageLimit: z.number().optional(),\n documentPageLimit: z.number().optional(),\n\n /**\n * Whether to use structured outputs.\n *\n * @default true\n */\n structuredOutputs: z.boolean().optional(),\n\n /**\n * Whether to use strict JSON schema validation.\n *\n * @default false\n */\n strictJsonSchema: z.boolean().optional(),\n\n /**\n * Whether to enable parallel function calling during tool use.\n * When set to false, the model will use at most one tool per response.\n *\n * @default true\n */\n parallelToolCalls: z.boolean().optional(),\n\n /**\n * A stable identifier used to route requests with shared prompt prefixes to\n * the same cache.\n */\n promptCacheKey: z.string().optional(),\n\n /**\n * Controls the reasoning effort for models that support adjustable reasoning.\n *\n * - `'high'`: Enable reasoning\n * - `'none'`: Disable reasoning\n */\n reasoningEffort: z.enum(['high', 'none']).optional(),\n });\nexport const mistralLanguageModelChatOptionsValidator = lazySchema(() =>\n zodSchema(mistralLanguageModelChatOptions()),\n);\n\nexport type MistralLanguageModelChatOptions = z.infer<\n ReturnType<typeof mistralLanguageModelChatOptions>\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n createJsonErrorResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralErrorDataSchema = lazySchema(() =>\n zodSchema(\n z.object({\n object: z.literal('error'),\n message: z.string(),\n type: z.string(),\n param: z.string().nullable(),\n code: z.string().nullable(),\n }),\n ),\n);\n\nexport type MistralErrorData = InferSchema<typeof mistralErrorDataSchema>;\n\nexport const mistralFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: mistralErrorDataSchema,\n errorToMessage: data => data.message,\n});\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type { MistralToolChoice } from './mistral-chat-prompt';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools:\n | Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n }>\n | undefined;\n toolChoice: MistralToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const mistralTools: Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n }> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n mistralTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: mistralTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n return { tools: mistralTools, toolChoice: type, toolWarnings };\n case 'required':\n return { tools: mistralTools, toolChoice: 'any', toolWarnings };\n\n // mistral does not support tool mode directly,\n // so we filter the tools and force the tool choice through 'any'\n case 'tool':\n return {\n tools: mistralTools.filter(\n tool => tool.function.name === toolChoice.toolName,\n ),\n toolChoice: 'any',\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4Content,\n LanguageModelV4FinishReason,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n generateId,\n injectJsonInstructionIntoMessages,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type ParseResult,\n type StreamingToolCallDelta,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n convertMistralUsage,\n mistralUsageSchema,\n type MistralUsage,\n} from './convert-mistral-usage';\nimport { convertToMistralChatMessages } from './convert-to-mistral-chat-messages';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { mapMistralFinishReason } from './map-mistral-finish-reason';\nimport {\n mistralLanguageModelChatOptionsValidator,\n type MistralChatModelId,\n} from './mistral-chat-language-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport { prepareTools } from './mistral-prepare-tools';\n\ntype MistralChatConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n generateId?: () => string;\n};\n\n// Known non-reasoning models from https://api.mistral.ai/v1/models\n// (2026-10-06). Unknown IDs inherit current reasoning configuration support.\nconst modelsWithoutReasoningEffort = new Set<MistralChatModelId>([\n 'codestral-2508',\n 'codestral-latest',\n 'ministral-14b-2512',\n 'ministral-14b-latest',\n 'ministral-3b-2512',\n 'ministral-3b-latest',\n 'ministral-8b-2512',\n 'ministral-8b-latest',\n 'mistral-code-fim-latest',\n 'mistral-code-latest',\n 'mistral-large-latest',\n 'mistral-large-2512',\n 'voxtral-small-2507',\n 'voxtral-small-latest',\n]);\n\nexport class MistralChatLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: MistralChatModelId;\n\n private readonly config: MistralChatConfig;\n private readonly generateId: () => string;\n\n static [WORKFLOW_SERIALIZE](model: MistralChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralChatModelId;\n config: MistralChatConfig;\n }) {\n return new MistralChatLanguageModel(options.modelId, options.config);\n }\n\n constructor(modelId: MistralChatModelId, config: MistralChatConfig) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n readonly supportedUrls: Record<string, RegExp[]> = {\n 'application/pdf': [/^https:\\/\\/.*$/],\n };\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n reasoning,\n stopSequences,\n responseFormat,\n seed,\n providerOptions,\n tools,\n toolChoice,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const options =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralLanguageModelChatOptionsValidator,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n const supportsReasoningEffort = !modelsWithoutReasoningEffort.has(\n this.modelId,\n );\n\n let resolvedReasoningEffort: string | undefined;\n if (supportsReasoningEffort) {\n resolvedReasoningEffort =\n options.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'high',\n low: 'high',\n medium: 'high',\n high: 'high',\n xhigh: 'high',\n max: 'high',\n },\n warnings,\n })\n : undefined);\n } else if (isCustomReasoning(reasoning)) {\n warnings.push({\n type: 'unsupported',\n feature: 'reasoning',\n details: 'This model does not support reasoning configuration.',\n });\n }\n\n const structuredOutputs = options.structuredOutputs ?? true;\n const strictJsonSchema = options.strictJsonSchema ?? false;\n\n // For Mistral we need to instruct the model when using JSON Object mode.\n // https://docs.mistral.ai/capabilities/structured-output/structured_output_overview/\n if (\n responseFormat?.type === 'json' &&\n (!structuredOutputs || responseFormat.schema == null)\n ) {\n prompt = injectJsonInstructionIntoMessages({\n messages: prompt,\n schema: responseFormat.schema,\n });\n }\n\n const baseArgs = {\n // model id:\n model: this.modelId,\n\n // model specific settings:\n safe_prompt: options.safePrompt,\n\n // standardized settings:\n max_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(frequencyPenalty != null\n ? { frequency_penalty: frequencyPenalty }\n : {}),\n ...(presencePenalty != null ? { presence_penalty: presencePenalty } : {}),\n stop: stopSequences,\n random_seed: seed,\n reasoning_effort: resolvedReasoningEffort,\n\n // response format:\n response_format:\n responseFormat?.type === 'json'\n ? structuredOutputs && responseFormat?.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: strictJsonSchema,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n\n // mistral-specific provider options:\n document_image_limit: options.documentImageLimit,\n document_page_limit: options.documentPageLimit,\n ...(options.promptCacheKey !== undefined\n ? { prompt_cache_key: options.promptCacheKey }\n : {}),\n\n // messages:\n messages: convertToMistralChatMessages(prompt),\n };\n\n const {\n tools: mistralTools,\n toolChoice: mistralToolChoice,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n });\n\n return {\n args: {\n ...baseArgs,\n tools: mistralTools,\n tool_choice: mistralToolChoice,\n ...(mistralTools != null && options.parallelToolCalls !== undefined\n ? { parallel_tool_calls: options.parallelToolCalls }\n : {}),\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args: body, warnings } = await this.getArgs(options);\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/chat/completions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralChatResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const choice = response.choices[0];\n const content: Array<LanguageModelV4Content> = [];\n\n // process content parts in order to preserve sequence\n if (\n choice.message.content != null &&\n Array.isArray(choice.message.content)\n ) {\n for (const part of choice.message.content) {\n if (part.type === 'thinking') {\n const reasoningText = extractReasoningContent(part.thinking);\n if (reasoningText.length > 0) {\n content.push({ type: 'reasoning', text: reasoningText });\n }\n } else if (part.type === 'text') {\n if (part.text.length > 0) {\n content.push({ type: 'text', text: part.text });\n }\n }\n }\n } else {\n // handle legacy string content\n const text = extractTextContent(choice.message.content);\n if (text != null && text.length > 0) {\n content.push({ type: 'text', text });\n }\n }\n\n // when there is a trailing assistant message, mistral will send the\n // content of that message again. we skip this repeated content to\n // avoid duplication, e.g. in continuation mode.\n\n // tool calls:\n if (choice.message.tool_calls != null) {\n for (const toolCall of choice.message.tool_calls) {\n content.push({\n type: 'tool-call',\n toolCallId: toolCall.id,\n toolName: toolCall.function.name,\n input: toolCall.function.arguments!,\n });\n }\n }\n\n return {\n content,\n finishReason: {\n unified: mapMistralFinishReason(choice.finish_reason),\n raw: choice.finish_reason ?? undefined,\n },\n usage: convertMistralUsage(response.usage),\n request: { body },\n response: {\n ...getResponseMetadata(response),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: `${this.config.baseURL}/chat/completions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n mistralChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'other',\n raw: undefined,\n };\n let usage: MistralUsage | undefined = undefined;\n\n let isFirstChunk = true;\n let activeText = false;\n let activeReasoningId: string | null = null;\n let toolCallTracker: StreamingToolCallTracker<StreamingToolCallDelta>;\n\n const generateId = this.generateId;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof mistralChatChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n // Emit raw chunk if requested (before anything else)\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n if (isFirstChunk) {\n isFirstChunk = false;\n\n controller.enqueue({\n type: 'response-metadata',\n ...getResponseMetadata(value),\n });\n }\n\n if (value.usage != null) {\n usage = value.usage;\n }\n\n const choice = value.choices[0];\n const delta = choice.delta;\n\n const textContent = extractTextContent(delta.content);\n\n if (delta.content != null && Array.isArray(delta.content)) {\n for (const part of delta.content) {\n if (part.type === 'thinking') {\n const reasoningDelta = extractReasoningContent(part.thinking);\n if (reasoningDelta.length > 0) {\n if (activeReasoningId == null) {\n // end any active text before starting reasoning\n if (activeText) {\n controller.enqueue({ type: 'text-end', id: '0' });\n activeText = false;\n }\n\n activeReasoningId = generateId();\n controller.enqueue({\n type: 'reasoning-start',\n id: activeReasoningId,\n });\n }\n controller.enqueue({\n type: 'reasoning-delta',\n id: activeReasoningId,\n delta: reasoningDelta,\n });\n }\n }\n }\n }\n\n if (textContent != null && textContent.length > 0) {\n if (!activeText) {\n // if we were in reasoning mode, end it before starting text\n if (activeReasoningId != null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: activeReasoningId,\n });\n activeReasoningId = null;\n }\n controller.enqueue({ type: 'text-start', id: '0' });\n activeText = true;\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: '0',\n delta: textContent,\n });\n }\n\n if (delta?.tool_calls != null) {\n for (const toolCall of delta.tool_calls) {\n toolCallTracker.processDelta(toolCall);\n }\n }\n\n if (choice.finish_reason != null) {\n finishReason = {\n unified: mapMistralFinishReason(choice.finish_reason),\n raw: choice.finish_reason,\n };\n }\n },\n\n flush(controller) {\n if (activeReasoningId != null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: activeReasoningId,\n });\n }\n if (activeText) {\n controller.enqueue({ type: 'text-end', id: '0' });\n }\n\n toolCallTracker.flush();\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertMistralUsage(usage),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\nfunction extractReasoningContent(\n thinking: Array<{ type: string; text: string }>,\n) {\n return thinking\n .filter(chunk => chunk.type === 'text')\n .map(chunk => chunk.text)\n .join('');\n}\n\nfunction extractTextContent(\n content: z.infer<ReturnType<typeof mistralContentSchema>>,\n) {\n if (typeof content === 'string') {\n return content;\n }\n\n if (content == null) {\n return undefined;\n }\n\n const textContent: string[] = [];\n\n for (const chunk of content) {\n const { type } = chunk;\n\n switch (type) {\n case 'text':\n textContent.push(chunk.text);\n break;\n case 'thinking':\n case 'image_url':\n case 'reference':\n // thinking, image content, and reference content are currently ignored\n break;\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`Unsupported type: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return textContent.length ? textContent.join('') : undefined;\n}\n\nconst mistralContentSchema = () =>\n z\n .union([\n z.string(),\n z.array(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('image_url'),\n image_url: z.union([\n z.string(),\n z.object({\n url: z.string(),\n detail: z.string().nullable(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('reference'),\n reference_ids: z.array(z.union([z.string(), z.number()])),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.array(\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n ),\n }),\n ]),\n ),\n ])\n .nullish();\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst mistralChatResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n choices: z.array(\n z.object({\n message: z.object({\n role: z.literal('assistant'),\n content: mistralContentSchema(),\n tool_calls: z\n .array(\n z.object({\n id: z.string(),\n function: z.object({\n name: z.string(),\n arguments: z.string(),\n }),\n }),\n )\n .nullish(),\n }),\n index: z.number(),\n finish_reason: z.string().nullish(),\n }),\n ),\n object: z.literal('chat.completion'),\n usage: mistralUsageSchema,\n }),\n ),\n);\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst mistralChatChunkSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n choices: z.array(\n z.object({\n delta: z.object({\n role: z.enum(['assistant']).optional(),\n content: mistralContentSchema(),\n tool_calls: z\n .array(\n z.object({\n index: z.number().nullish(),\n id: z.string().nullish(),\n function: z.object({\n name: z.string().nullish(),\n arguments: z.string().nullish(),\n }),\n }),\n )\n .nullish(),\n }),\n finish_reason: z.string().nullish(),\n index: z.number(),\n }),\n ),\n usage: mistralUsageSchema.nullish(),\n }),\n ),\n);\n","import {\n UnsupportedFunctionalityError,\n type JSONValue,\n type LanguageModelV4Prompt,\n type LanguageModelV4ToolResultPart,\n} from '@ai-sdk/provider';\nimport type { ToolNameMapping } from '@ai-sdk/provider-utils';\nimport { convertToMistralChatMessages } from './convert-to-mistral-chat-messages';\nimport type {\n MistralAssistantMessageContent,\n MistralToolMessage,\n MistralUserMessageContent,\n} from './mistral-chat-prompt';\n\ntype ConversationInput =\n | {\n type: 'message.input';\n role: 'user' | 'assistant';\n content: Array<\n MistralUserMessageContent | MistralAssistantMessageContent\n >;\n }\n | {\n type: 'function.call';\n tool_call_id: string;\n name: string;\n arguments: string;\n }\n | { type: 'function.result'; tool_call_id: string; result: string };\n\nexport function convertToMistralConversationInputs(\n prompt: LanguageModelV4Prompt,\n toolNameMapping: ToolNameMapping,\n) {\n const inputs: ConversationInput[] = [];\n const instructions: string[] = [];\n const executions = new Set<string>();\n const appendToolResult = (part: LanguageModelV4ToolResultPart) => {\n if (executions.has(part.toolCallId)) {\n let result: JSONValue = null;\n if (part.output.type === 'json') {\n const value = part.output.value;\n const info =\n value != null && typeof value === 'object' && 'info' in value\n ? value.info\n : undefined;\n if (info != null && typeof info === 'object' && !Array.isArray(info)) {\n result = 'result' in info ? (info.result ?? info) : info;\n }\n }\n inputs.push({\n type: 'function.result',\n tool_call_id: part.toolCallId,\n result: typeof result === 'string' ? result : JSON.stringify(result),\n });\n return;\n }\n const converted = convertToMistralChatMessages([\n { role: 'tool', content: [part] },\n ])[0] as MistralToolMessage;\n inputs.push({\n type: 'function.result',\n tool_call_id: part.toolCallId,\n result: converted.content,\n });\n };\n\n for (const message of prompt) {\n switch (message.role) {\n case 'system':\n instructions.push(message.content);\n break;\n case 'user': {\n const converted = convertToMistralChatMessages([message])[0];\n if (converted.role === 'user') {\n inputs.push({\n type: 'message.input',\n role: 'user',\n content: converted.content,\n });\n }\n break;\n }\n case 'assistant': {\n let content: MistralAssistantMessageContent[] = [];\n const flush = () => {\n if (content.length > 0) {\n inputs.push({ type: 'message.input', role: 'assistant', content });\n content = [];\n }\n };\n for (const part of message.content) {\n switch (part.type) {\n case 'text':\n content.push({ type: 'text', text: part.text });\n break;\n case 'reasoning':\n content.push({\n type: 'thinking',\n thinking: [{ type: 'text', text: part.text }],\n closed: true,\n });\n break;\n case 'tool-call': {\n flush();\n if (part.providerExecuted) {\n const name =\n part.providerOptions?.mistral?.function ??\n part.providerOptions?.mistral?.name;\n const args = part.input as { arguments?: unknown } | null;\n // Replay built-in executions as calls and results. Entry IDs\n // and tool.execution output entries cannot be sent as inputs.\n inputs.push({\n type: 'function.call',\n tool_call_id: part.toolCallId,\n name:\n typeof name === 'string'\n ? name\n : toolNameMapping.toProviderToolName(part.toolName),\n arguments:\n typeof args?.arguments === 'string'\n ? args.arguments\n : JSON.stringify(part.input),\n });\n executions.add(part.toolCallId);\n } else {\n inputs.push({\n type: 'function.call',\n tool_call_id: part.toolCallId,\n name: part.toolName,\n arguments: JSON.stringify(part.input),\n });\n }\n break;\n }\n case 'tool-result':\n flush();\n appendToolResult(part);\n break;\n default:\n throw new UnsupportedFunctionalityError({\n functionality: `assistant content type: ${part.type}`,\n });\n }\n }\n flush();\n break;\n }\n case 'tool':\n for (const part of message.content) {\n if (part.type === 'tool-approval-response') {\n continue;\n }\n appendToolResult(part);\n }\n break;\n }\n }\n\n return {\n inputs,\n instructions:\n instructions.length > 0 ? instructions.join('\\n\\n') : undefined,\n };\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport {\n mistralLanguageModelChatOptions,\n type MistralChatModelId,\n type MistralLanguageModelChatOptions,\n} from './mistral-chat-language-model-options';\n\nexport type MistralConversationModelId = MistralChatModelId;\n\nexport const mistralLanguageModelConversationOptions = lazySchema(() =>\n zodSchema(mistralLanguageModelChatOptions()),\n);\n\nexport type MistralLanguageModelConversationOptions =\n MistralLanguageModelChatOptions;\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type { MistralToolChoice } from './mistral-chat-prompt';\nimport { createToolNameMapping } from '@ai-sdk/provider-utils';\n\ntype MistralTool =\n | { type: 'web_search' | 'web_search_premium' }\n | {\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n };\n\nexport const mistralProviderToolNames = {\n 'mistral.web_search': 'web_search',\n 'mistral.web_search_premium': 'web_search_premium',\n} as const;\n\nexport function prepareConversationTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools: Array<MistralTool> | undefined;\n toolChoice: MistralToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const mistralTools: Array<MistralTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n if (\n tool.id === 'mistral.web_search' ||\n tool.id === 'mistral.web_search_premium'\n ) {\n mistralTools.push({ type: mistralProviderToolNames[tool.id] });\n continue;\n }\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n mistralTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: mistralTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n return { tools: mistralTools, toolChoice: type, toolWarnings };\n case 'required':\n return { tools: mistralTools, toolChoice: 'any', toolWarnings };\n\n // mistral does not support tool mode directly,\n // so we filter the tools and force the tool choice through 'any'\n case 'tool': {\n const toolName = createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n }).toProviderToolName(toolChoice.toolName);\n return {\n tools: mistralTools.filter(tool =>\n tool.type === 'function'\n ? tool.function.name === toolName\n : tool.type === toolName,\n ),\n toolChoice: 'any',\n toolWarnings,\n };\n }\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4Content,\n LanguageModelV4GenerateResult,\n LanguageModelV4Reasoning,\n LanguageModelV4Source,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n LanguageModelV4Text,\n LanguageModelV4ToolCall,\n LanguageModelV4ToolResult,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n createToolNameMapping,\n generateId,\n injectJsonInstructionIntoMessages,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type ParseResult,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n convertMistralUsage,\n mistralUsageSchema,\n type MistralUsage,\n} from './convert-mistral-usage';\nimport { convertToMistralConversationInputs } from './convert-to-mistral-conversation-inputs';\nimport {\n mistralLanguageModelConversationOptions,\n type MistralConversationModelId,\n} from './mistral-conversation-language-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralProviderToolNames,\n prepareConversationTools,\n} from './mistral-conversation-prepare-tools';\n\ntype MistralConversationConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n generateId?: () => string;\n};\n\n// https://api.mistral.ai/v1/models (2026-10-06)\nconst reasoningEffortModelIds = new Set<MistralConversationModelId>([\n 'glm-5-2',\n 'labs-leanstral-1-5',\n 'labs-leanstral-1-5-1',\n 'magistral-medium-latest',\n 'magistral-small-latest',\n 'mistral-large-4',\n 'mistral-large-4-0',\n 'mistral-medium',\n 'mistral-medium-2604',\n 'mistral-medium-3',\n 'mistral-medium-3-5',\n 'mistral-medium-3.5',\n 'mistral-medium-latest',\n 'mistral-small-2603',\n 'mistral-small-latest',\n 'mistral-vibe-cli-fast',\n 'mistral-vibe-cli-latest',\n 'mistral-vibe-cli-with-tools',\n 'zai-glm-5-2',\n]);\n\nexport class MistralConversationLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: MistralConversationModelId;\n\n private readonly config: MistralConversationConfig;\n private readonly generateId: () => string;\n\n static [WORKFLOW_SERIALIZE](model: MistralConversationLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralConversationModelId;\n config: MistralConversationConfig;\n }) {\n return new MistralConversationLanguageModel(\n options.modelId,\n options.config,\n );\n }\n\n constructor(\n modelId: MistralConversationModelId,\n config: MistralConversationConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n readonly supportedUrls: Record<string, RegExp[]> = {\n 'application/pdf': [/^https:\\/\\/.*$/],\n };\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n reasoning,\n stopSequences,\n responseFormat,\n seed,\n providerOptions,\n tools,\n toolChoice,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const options =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralLanguageModelConversationOptions,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n const supportsReasoningEffort = reasoningEffortModelIds.has(this.modelId);\n\n let resolvedReasoningEffort: string | undefined;\n if (supportsReasoningEffort) {\n resolvedReasoningEffort =\n options.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'high',\n low: 'high',\n medium: 'high',\n high: 'high',\n xhigh: 'high',\n max: 'high',\n },\n warnings,\n })\n : undefined);\n } else if (isCustomReasoning(reasoning)) {\n warnings.push({\n type: 'unsupported',\n feature: 'reasoning',\n details: 'This model does not support reasoning configuration.',\n });\n }\n\n const structuredOutputs = options.structuredOutputs ?? true;\n const strictJsonSchema = options.strictJsonSchema ?? false;\n\n // For Mistral we need to instruct the model when using JSON Object mode.\n // https://docs.mistral.ai/capabilities/structured-output/structured_output_overview/\n if (\n responseFormat?.type === 'json' &&\n (!structuredOutputs || responseFormat.schema == null)\n ) {\n prompt = injectJsonInstructionIntoMessages({\n messages: prompt,\n schema: responseFormat.schema,\n });\n }\n\n const baseArgs = {\n // standardized settings:\n max_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(frequencyPenalty != null\n ? { frequency_penalty: frequencyPenalty }\n : {}),\n ...(presencePenalty != null ? { presence_penalty: presencePenalty } : {}),\n stop: stopSequences,\n random_seed: seed,\n reasoning_effort: resolvedReasoningEffort,\n\n // response format:\n response_format:\n responseFormat?.type === 'json'\n ? structuredOutputs && responseFormat?.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: strictJsonSchema,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n };\n\n const {\n tools: mistralTools,\n toolChoice: mistralToolChoice,\n toolWarnings,\n } = prepareConversationTools({ tools, toolChoice });\n\n for (const [feature, value] of Object.entries({\n safePrompt: options.safePrompt,\n documentImageLimit: options.documentImageLimit,\n documentPageLimit: options.documentPageLimit,\n promptCacheKey: options.promptCacheKey,\n parallelToolCalls: options.parallelToolCalls,\n })) {\n if (value != null) {\n warnings.push({\n type: 'unsupported',\n feature,\n details: 'Not supported by the Mistral Conversations API.',\n });\n }\n }\n\n return {\n args: {\n model: this.modelId,\n store: false,\n ...convertToMistralConversationInputs(\n prompt,\n createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n }),\n ),\n tools: mistralTools,\n completion_args: { ...baseArgs, tool_choice: mistralToolChoice },\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args: body, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n rawValue: rawResponse,\n responseHeaders,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/conversations`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralConversationResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const converter = createContentConverter({\n tools: options.tools,\n generateId: this.generateId,\n });\n const content: LanguageModelV4Content[] = [];\n let hasFunctionCalls = false;\n let modelId: string | undefined;\n\n for (const output of response.outputs) {\n switch (output.type) {\n case 'tool.execution':\n content.push(...converter.convertTool(output));\n break;\n case 'function.call':\n hasFunctionCalls = true;\n content.push({\n type: 'tool-call',\n toolCallId: output.tool_call_id,\n toolName: output.name,\n input:\n typeof output.arguments === 'string'\n ? output.arguments\n : JSON.stringify(output.arguments),\n });\n break;\n case 'message.output':\n modelId = output.model ?? modelId;\n for (const chunk of typeof output.content === 'string'\n ? [{ type: 'text' as const, text: output.content }]\n : output.content) {\n content.push(...converter.convertChunk(chunk));\n }\n break;\n }\n }\n\n return {\n content,\n finishReason: {\n unified: hasFunctionCalls ? 'tool-calls' : 'stop',\n raw: undefined,\n },\n usage: convertMistralUsage(response.usage),\n request: { body },\n response: {\n id: response.conversation_id,\n modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/conversations`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n mistralConversationChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const converter = createContentConverter({\n tools: options.tools,\n generateId: this.generateId,\n });\n const executions = new Map<\n string,\n { name: string; arguments: string; function?: string | null }\n >();\n let toolCallTracker: StreamingToolCallTracker;\n let active: { id: string; type: 'text' | 'reasoning' } | undefined;\n let usage: MistralUsage | undefined;\n let hasFunctionCalls = false;\n let hasError = false;\n let isDone = false;\n let hasModelId = false;\n const closeContent = (\n controller: TransformStreamDefaultController<LanguageModelV4StreamPart>,\n ) => {\n if (active != null) {\n controller.enqueue({\n type: active.type === 'text' ? 'text-end' : 'reasoning-end',\n id: active.id,\n });\n active = undefined;\n }\n };\n\n const generateId = this.generateId;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof mistralConversationChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n hasError = true;\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n const event = chunk.value;\n switch (event.type) {\n case 'conversation.response.started':\n controller.enqueue({\n type: 'response-metadata',\n id: event.conversation_id,\n ...(event.created_at != null\n ? { timestamp: new Date(event.created_at) }\n : {}),\n });\n break;\n case 'conversation.response.done':\n usage = event.usage ?? undefined;\n isDone = true;\n break;\n case 'conversation.response.error':\n hasError = true;\n controller.enqueue({ type: 'error', error: event });\n break;\n case 'message.output.delta': {\n if (!hasModelId && event.model != null) {\n hasModelId = true;\n controller.enqueue({\n type: 'response-metadata',\n modelId: event.model,\n });\n }\n for (const part of converter.convertChunk(\n typeof event.content === 'string'\n ? { type: 'text', text: event.content }\n : event.content,\n )) {\n if (part.type === 'text' || part.type === 'reasoning') {\n const id = `${event.id}-${event.content_index ?? 0}`;\n if (active?.id !== id || active.type !== part.type) {\n closeContent(controller);\n active = { id, type: part.type };\n controller.enqueue({\n type:\n part.type === 'text'\n ? 'text-start'\n : 'reasoning-start',\n id,\n });\n }\n controller.enqueue({\n type:\n part.type === 'text' ? 'text-delta' : 'reasoning-delta',\n id,\n delta: part.text,\n });\n } else if (part.type === 'source') {\n controller.enqueue(part);\n }\n }\n break;\n }\n case 'function.call.delta':\n closeContent(controller);\n hasFunctionCalls = true;\n toolCallTracker.processDelta({\n id: event.tool_call_id,\n index: event.output_index,\n function: { name: event.name, arguments: event.arguments },\n });\n break;\n case 'tool.execution.started':\n case 'tool.execution.delta': {\n closeContent(controller);\n const execution = executions.get(event.id);\n if (execution == null) {\n executions.set(event.id, {\n name: event.name,\n arguments: event.arguments,\n function: event.function,\n });\n controller.enqueue({\n type: 'tool-input-start',\n id: event.id,\n toolName: converter.toolNameMapping.toCustomToolName(\n event.name,\n ),\n providerExecuted: true,\n });\n } else {\n execution.arguments += event.arguments;\n }\n break;\n }\n case 'tool.execution.done': {\n const execution = executions.get(event.id);\n if (execution == null) {\n hasError = true;\n controller.enqueue({\n type: 'error',\n error: new Error(\n `Missing tool execution start for ${event.id}`,\n ),\n });\n break;\n }\n controller.enqueue({\n type: 'tool-input-delta',\n id: event.id,\n delta: JSON.stringify({ arguments: execution.arguments }),\n });\n controller.enqueue({ type: 'tool-input-end', id: event.id });\n for (const part of converter.convertTool({\n type: 'tool.execution',\n id: event.id,\n name: execution.name,\n arguments: execution.arguments,\n function: event.function ?? execution.function,\n info: event.info,\n })) {\n controller.enqueue(part);\n }\n executions.delete(event.id);\n break;\n }\n }\n },\n\n flush(controller) {\n closeContent(controller);\n toolCallTracker.flush();\n controller.enqueue({\n type: 'finish',\n finishReason: {\n unified:\n hasError || !isDone || executions.size > 0\n ? 'error'\n : hasFunctionCalls\n ? 'tool-calls'\n : 'stop',\n raw: undefined,\n },\n usage: convertMistralUsage(usage),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\nfunction createContentConverter({\n tools,\n generateId,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n generateId: () => string;\n}) {\n const toolNameMapping = createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n });\n const sourceUrls = new Set<string>();\n\n return {\n toolNameMapping,\n convertChunk(\n chunk: z.infer<ReturnType<typeof mistralConversationContentSchema>>,\n ): Array<\n LanguageModelV4Text | LanguageModelV4Reasoning | LanguageModelV4Source\n > {\n switch (chunk.type) {\n case 'text':\n return chunk.text.length > 0\n ? [{ type: 'text', text: chunk.text }]\n : [];\n case 'thinking': {\n const text = chunk.thinking.map(part => part.text).join('');\n return text.length > 0 ? [{ type: 'reasoning', text }] : [];\n }\n case 'tool_reference':\n if (chunk.url == null || sourceUrls.has(chunk.url)) {\n return [];\n }\n const id = generateId();\n sourceUrls.add(chunk.url);\n return [\n {\n type: 'source',\n sourceType: 'url',\n id,\n url: chunk.url,\n title: chunk.title ?? chunk.url,\n },\n ];\n }\n },\n convertTool(\n output: z.infer<\n ReturnType<typeof mistralConversationToolExecutionSchema>\n >,\n ): [LanguageModelV4ToolCall, LanguageModelV4ToolResult] {\n const toolName = toolNameMapping.toCustomToolName(output.name);\n return [\n {\n type: 'tool-call',\n toolCallId: output.id,\n toolName,\n input: JSON.stringify({ arguments: output.arguments }),\n providerExecuted: true,\n providerMetadata: {\n mistral: {\n type: 'tool.execution',\n name: output.name,\n ...(output.function != null ? { function: output.function } : {}),\n },\n },\n },\n {\n type: 'tool-result',\n toolCallId: output.id,\n toolName,\n result: { ...(output.info != null ? { info: output.info } : {}) },\n },\n ];\n },\n };\n}\n\nconst mistralConversationContentSchema = () =>\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('text'), text: z.string() }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.array(\n z.object({ type: z.literal('text'), text: z.string() }),\n ),\n }),\n z.object({\n type: z.literal('tool_reference'),\n tool: z.string().nullish(),\n title: z.string().nullish(),\n url: z.string().nullish(),\n }),\n ]);\nconst mistralConversationMessageContentSchema = () =>\n z.union([z.string(), z.array(mistralConversationContentSchema())]);\nconst mistralConversationToolExecutionSchema = () =>\n z.object({\n type: z.literal('tool.execution'),\n id: z.string(),\n name: z.string(),\n arguments: z.string(),\n function: z.string().nullish(),\n info: z.record(z.string(), z.json()).nullish(),\n });\nconst mistralConversationFunctionCallSchema = () =>\n z.object({\n type: z.literal('function.call'),\n tool_call_id: z.string(),\n name: z.string(),\n arguments: z.union([z.string(), z.record(z.string(), z.json())]),\n });\nconst mistralConversationUsageSchema = () =>\n mistralUsageSchema.extend({\n prompt_tokens: z.number().default(0),\n completion_tokens: z.number().default(0),\n total_tokens: z.number().default(0),\n });\nconst mistralConversationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n conversation_id: z.string(),\n outputs: z.array(\n z.discriminatedUnion('type', [\n mistralConversationToolExecutionSchema(),\n mistralConversationFunctionCallSchema(),\n z.object({\n type: z.literal('message.output'),\n content: mistralConversationMessageContentSchema(),\n model: z.string().nullish(),\n }),\n ]),\n ),\n usage: mistralConversationUsageSchema().nullish(),\n }),\n ),\n);\nconst mistralConversationChunkSchema = lazySchema(() =>\n zodSchema(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('conversation.response.started'),\n conversation_id: z.string(),\n created_at: z.string().nullish(),\n }),\n z.object({\n type: z.literal('conversation.response.done'),\n usage: mistralConversationUsageSchema().nullish(),\n }),\n z.object({\n type: z.literal('conversation.response.error'),\n message: z.string(),\n code: z.number(),\n }),\n z.object({\n type: z.literal('message.output.delta'),\n id: z.string(),\n content_index: z.number().nullish(),\n content: z.union([z.string(), mistralConversationContentSchema()]),\n model: z.string().nullish(),\n }),\n z.object({\n type: z.literal('function.call.delta'),\n tool_call_id: z.string(),\n name: z.string(),\n arguments: z.string(),\n output_index: z.number().nullish(),\n }),\n z.object({\n type: z.enum(['tool.execution.started', 'tool.execution.delta']),\n id: z.string(),\n name: z.string(),\n arguments: z.string(),\n function: z.string().nullish(),\n }),\n z.object({\n type: z.literal('tool.execution.done'),\n id: z.string(),\n name: z.string(),\n function: z.string().nullish(),\n info: z.record(z.string(), z.json()).nullish(),\n }),\n ]),\n ),\n);\n","import { z } from 'zod/v4';\n\nexport type MistralEmbeddingModelId =\n | 'mistral-embed'\n | 'mistral-embed-2312'\n | 'codestral-embed'\n | 'codestral-embed-2505'\n | (string & {});\n\nexport const mistralEmbeddingModelOptions = z.object({\n /**\n * Additional metadata to attach to the embedding request.\n */\n metadata: z.record(z.string(), z.any()).optional(),\n\n /**\n * The dimension of the output embeddings when supported by the model.\n */\n outputDimension: z.number().int().positive().optional(),\n\n /**\n * The data type of the output embeddings when supported by the model.\n */\n outputDtype: z\n .enum(['float', 'int8', 'uint8', 'binary', 'ubinary'])\n .optional(),\n});\n\nexport type MistralEmbeddingModelOptions = z.infer<\n typeof mistralEmbeddingModelOptions\n>;\n","import {\n TooManyEmbeddingValuesForCallError,\n type EmbeddingModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n mistralEmbeddingModelOptions,\n type MistralEmbeddingModelId,\n} from './mistral-embedding-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\n\ntype MistralEmbeddingConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n};\n\nexport class MistralEmbeddingModel implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n readonly modelId: MistralEmbeddingModelId;\n readonly maxEmbeddingsPerCall = 32;\n readonly supportsParallelCalls = false;\n\n private readonly config: MistralEmbeddingConfig;\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: MistralEmbeddingModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralEmbeddingModelId;\n config: MistralEmbeddingConfig;\n }) {\n return new MistralEmbeddingModel(options.modelId, options.config);\n }\n\n constructor(\n modelId: MistralEmbeddingModelId,\n config: MistralEmbeddingConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n }\n\n async doEmbed({\n values,\n dimensions,\n abortSignal,\n headers,\n providerOptions,\n }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n > {\n if (values.length > this.maxEmbeddingsPerCall) {\n throw new TooManyEmbeddingValuesForCallError({\n provider: this.provider,\n modelId: this.modelId,\n maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,\n values,\n });\n }\n\n const mistralOptions =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralEmbeddingModelOptions,\n })) ?? {};\n\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/embeddings`,\n headers: combineHeaders(this.config.headers?.(), headers),\n body: {\n model: this.modelId,\n input: values,\n metadata: mistralOptions.metadata,\n output_dimension: mistralOptions.outputDimension ?? dimensions,\n output_dtype: mistralOptions.outputDtype,\n encoding_format: 'float',\n },\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n MistralTextEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n warnings: [],\n embeddings: response.data.map(item => item.embedding),\n usage: response.usage\n ? { tokens: response.usage.prompt_tokens }\n : undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n}\n\n// minimal version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst MistralTextEmbeddingResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n data: z.array(z.object({ embedding: z.array(z.number()) })),\n usage: z.object({ prompt_tokens: z.number() }).nullish(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type MistralSpeechModelId =\n | 'voxtral-mini-tts-2603'\n | 'voxtral-mini-tts-latest'\n | (string & {});\n\nexport const mistralSpeechModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Base64-encoded reference audio for one-off voice cloning.\n *\n * When provided, this takes precedence over the standard `voice` option.\n */\n refAudio: z.string().min(1).optional(),\n }),\n ),\n);\n\nexport type MistralSpeechModelOptions = InferSchema<\n typeof mistralSpeechModelOptions\n>;\n","import type { SharedV4Warning, SpeechModelV4 } from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralSpeechModelOptions,\n type MistralSpeechModelId,\n} from './mistral-speech-model-options';\n\ninterface MistralSpeechModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\ntype MistralSpeechOutputFormat = 'pcm' | 'wav' | 'mp3' | 'flac' | 'opus';\n\nexport class MistralSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n static [WORKFLOW_SERIALIZE](model: MistralSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralSpeechModelId;\n config: MistralSpeechModelConfig;\n }) {\n return new MistralSpeechModel(options.modelId, options.config);\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MistralSpeechModelId,\n private readonly config: MistralSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice,\n outputFormat = 'mp3',\n instructions,\n speed,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n const mistralOptions = await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralSpeechModelOptions,\n });\n\n let responseFormat: MistralSpeechOutputFormat = 'mp3';\n if (['pcm', 'wav', 'mp3', 'flac', 'opus'].includes(outputFormat)) {\n responseFormat = outputFormat as MistralSpeechOutputFormat;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n\n if (instructions != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details:\n 'Mistral speech models do not support the `instructions` option. ' +\n 'Use a reference audio clip to guide delivery.',\n });\n }\n\n if (speed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'speed',\n details:\n 'Mistral speech models do not support the `speed` option. It was ignored.',\n });\n }\n\n if (language != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details:\n 'Mistral speech models do not support the `language` option. ' +\n 'Language is inferred from the input text and voice.',\n });\n }\n\n const refAudio = mistralOptions?.refAudio;\n const requestBody = {\n model: this.modelId,\n input: text,\n voice_id: refAudio == null ? voice : undefined,\n ref_audio: refAudio,\n response_format: responseFormat,\n stream: false,\n };\n\n const requestBodyValues = {\n ...requestBody,\n ref_audio: refAudio == null ? undefined : '[redacted]',\n };\n\n return { requestBody, requestBodyValues, warnings };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, requestBodyValues, warnings } =\n await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url: `${this.config.baseURL}/audio/speech`,\n headers: combineHeaders(\n { 'Content-Type': 'application/json' },\n this.config.headers?.(),\n options.headers,\n ),\n body: {\n content: JSON.stringify(requestBody),\n values: requestBodyValues,\n },\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralSpeechResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio: response.audio_data,\n warnings,\n request: {\n body: JSON.stringify(requestBodyValues),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst mistralSpeechResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n audio_data: z.string(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type MistralTranscriptionModelId =\n | 'voxtral-mini-2602'\n | 'voxtral-mini-latest'\n | (string & {});\n\n// https://docs.mistral.ai/api/endpoint/audio/transcriptions\nexport const mistralTranscriptionModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * The language of the audio, e.g. \"en\". Providing the language can boost\n * accuracy.\n */\n language: z.string().min(1).optional(),\n\n /**\n * The sampling temperature.\n */\n temperature: z.number().optional(),\n\n /**\n * The timestamp granularities to include in the transcription response.\n */\n timestampGranularities: z\n .array(z.enum(['segment', 'word']))\n .min(1)\n .optional(),\n\n /**\n * Whether to identify speakers in the transcription.\n */\n diarize: z.boolean().optional(),\n\n /**\n * Words or phrases to guide the model toward correct spellings of names,\n * technical terms, or domain-specific vocabulary.\n *\n * Mistral requires each item to omit commas and whitespace. Use\n * underscores to represent multi-word phrases.\n */\n contextBias: z\n .array(\n z\n .string()\n .min(1)\n .regex(\n /^[^\\s,]+$/,\n 'Context bias items must not contain commas or whitespace.',\n ),\n )\n .max(100)\n .optional(),\n }),\n ),\n);\n\nexport type MistralTranscriptionModelOptions = InferSchema<\n typeof mistralTranscriptionModelOptions\n>;\n","import {\n InvalidArgumentError,\n type JSONObject,\n type SharedV4Warning,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonResponseHandler,\n mediaTypeToExtension,\n parseProviderOptions,\n postFormDataToApi,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralTranscriptionModelOptions,\n type MistralTranscriptionModelId,\n} from './mistral-transcription-model-options';\n\ntype MistralTranscriptionModelConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n};\n\nexport class MistralTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n\n static [WORKFLOW_SERIALIZE](model: MistralTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralTranscriptionModelId;\n config: MistralTranscriptionModelConfig;\n }) {\n return new MistralTranscriptionModel(options.modelId, options.config);\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MistralTranscriptionModelId,\n private readonly config: MistralTranscriptionModelConfig,\n ) {}\n\n private async getArgs({\n audio,\n mediaType,\n providerOptions,\n }: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n const mistralOptions = await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralTranscriptionModelOptions,\n });\n\n // Mistral documents these options as mutually incompatible. Rejecting the\n // combination locally provides a stable SDK error instead of an API 4xx.\n if (\n mistralOptions?.language != null &&\n mistralOptions.timestampGranularities != null\n ) {\n throw new InvalidArgumentError({\n argument: 'providerOptions',\n message:\n 'providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities',\n });\n }\n\n const formData = new FormData();\n const blob =\n audio instanceof Uint8Array\n ? new Blob([audio as Uint8Array<ArrayBuffer>])\n : new Blob([convertBase64ToUint8Array(audio)]);\n\n formData.append('model', this.modelId);\n formData.append(\n 'file',\n new File([blob], 'audio', { type: mediaType }),\n `audio.${mediaTypeToExtension(mediaType)}`,\n );\n\n if (mistralOptions != null) {\n appendFormValue(formData, 'language', mistralOptions.language);\n appendFormValue(formData, 'temperature', mistralOptions.temperature);\n appendFormValue(\n formData,\n 'timestamp_granularities',\n mistralOptions.timestampGranularities,\n );\n appendFormValue(formData, 'diarize', mistralOptions.diarize);\n appendFormValue(formData, 'context_bias', mistralOptions.contextBias);\n }\n\n return { formData, warnings };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { formData, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postFormDataToApi({\n url: `${this.config.baseURL}/audio/transcriptions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n formData,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const segments =\n response.segments?.map(segment => ({\n text: segment.text,\n startSecond: segment.start,\n endSecond: segment.end,\n })) ?? [];\n\n const mistralMetadata: JSONObject = {};\n\n if (response.usage != null) {\n mistralMetadata.usage = {\n ...(response.usage.prompt_tokens != null && {\n promptTokens: response.usage.prompt_tokens,\n }),\n ...(response.usage.completion_tokens != null && {\n completionTokens: response.usage.completion_tokens,\n }),\n ...(response.usage.total_tokens != null && {\n totalTokens: response.usage.total_tokens,\n }),\n ...(response.usage.prompt_audio_seconds != null && {\n promptAudioSeconds: response.usage.prompt_audio_seconds,\n }),\n ...(response.usage.request_count != null && {\n requestCount: response.usage.request_count,\n }),\n };\n }\n\n const providerSegments = response.segments\n ?.filter(\n segment =>\n segment.type != null ||\n segment.score != null ||\n segment.speaker_id != null,\n )\n .map(segment => ({\n text: segment.text,\n startSecond: segment.start,\n endSecond: segment.end,\n ...(segment.type != null && { type: segment.type }),\n ...(segment.score != null && { score: segment.score }),\n ...(segment.speaker_id != null && {\n speakerId: segment.speaker_id,\n }),\n }));\n\n if (providerSegments != null && providerSegments.length > 0) {\n mistralMetadata.segments = providerSegments;\n }\n\n return {\n text: response.text,\n segments,\n language: response.language ?? undefined,\n durationInSeconds:\n response.usage?.prompt_audio_seconds ??\n segments.at(-1)?.endSecond ??\n undefined,\n warnings,\n ...(response.usage != null && { usage: response.usage }),\n response: {\n timestamp: currentDate,\n modelId: response.model,\n headers: responseHeaders,\n body: rawResponse,\n },\n ...(Object.keys(mistralMetadata).length > 0 && {\n providerMetadata: {\n mistral: mistralMetadata,\n },\n }),\n };\n }\n}\n\nfunction appendFormValue(\n formData: FormData,\n key: string,\n value: string | number | boolean | string[] | undefined,\n): void {\n if (value == null) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n formData.append(key, item);\n }\n return;\n }\n\n formData.append(key, String(value));\n}\n\nconst mistralTranscriptionResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n model: z.string(),\n text: z.string(),\n language: z.string().nullish(),\n segments: z\n .array(\n z.object({\n type: z.literal('transcription_segment').nullish(),\n text: z.string(),\n start: z.number(),\n end: z.number(),\n score: z.number().nullish(),\n speaker_id: z.string().nullish(),\n }),\n )\n .nullish(),\n usage: z\n .object({\n prompt_tokens: z.number().nullish(),\n completion_tokens: z.number().nullish(),\n total_tokens: z.number().nullish(),\n prompt_audio_seconds: z.number().nullish(),\n request_count: z.number().nullish(),\n })\n .nullish(),\n }),\n ),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import type { JSONValue } from '@ai-sdk/provider';\nimport {\n createProviderExecutedToolFactory,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst inputSchema = lazySchema(() =>\n zodSchema(z.object({ arguments: z.string() })),\n);\nconst outputSchema = lazySchema(() =>\n zodSchema(z.object({ info: z.record(z.string(), z.json()).optional() })),\n);\n\nconst webSearchFactory = createProviderExecutedToolFactory<\n { arguments: string },\n { info?: Record<string, JSONValue> },\n {}\n>({ id: 'mistral.web_search', inputSchema, outputSchema });\n\nconst webSearchPremiumFactory = createProviderExecutedToolFactory<\n { arguments: string },\n { info?: Record<string, JSONValue> },\n {}\n>({ id: 'mistral.web_search_premium', inputSchema, outputSchema });\n\n/** Search the web using Mistral's Conversations API. */\nexport const webSearch = (args: Parameters<typeof webSearchFactory>[0] = {}) =>\n webSearchFactory(args);\n\n/** Search the web and verified news using Mistral's Conversations API. */\nexport const webSearchPremium = (\n args: Parameters<typeof webSearchPremiumFactory>[0] = {},\n) => webSearchPremiumFactory(args);\n","import { webSearch, webSearchPremium } from './web-search';\n\nexport const mistralTools = { webSearch, webSearchPremium };\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { MistralChatLanguageModel } from './mistral-chat-language-model';\nimport { MistralConversationLanguageModel } from './mistral-conversation-language-model';\nimport type { MistralChatModelId } from './mistral-chat-language-model-options';\nimport { MistralEmbeddingModel } from './mistral-embedding-model';\nimport type { MistralEmbeddingModelId } from './mistral-embedding-model-options';\nimport { MistralSpeechModel } from './mistral-speech-model';\nimport type { MistralSpeechModelId } from './mistral-speech-model-options';\nimport { MistralTranscriptionModel } from './mistral-transcription-model';\nimport type { MistralTranscriptionModelId } from './mistral-transcription-model-options';\nimport { VERSION } from './version';\nimport { mistralTools } from './tool';\n\nexport interface MistralProvider extends ProviderV4 {\n tools: typeof mistralTools;\n (modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n chat(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model using the Conversations API, with support for web search.\n */\n conversation(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text embeddings.\n */\n embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * Creates a model for text embeddings.\n */\n embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV4;\n\n /**\n * Creates a model for speech generation (text-to-speech).\n */\n speech(modelId: MistralSpeechModelId): SpeechModelV4;\n\n /**\n * Creates a model for speech generation (text-to-speech).\n */\n speechModel(modelId: MistralSpeechModelId): SpeechModelV4;\n\n /**\n * Creates a model for audio transcription.\n */\n transcription(modelId: MistralTranscriptionModelId): TranscriptionModelV4;\n\n /**\n * Creates a model for audio transcription.\n */\n transcriptionModel(\n modelId: MistralTranscriptionModelId,\n ): TranscriptionModelV4;\n\n /**\n * @deprecated Use `embedding` instead.\n */\n textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n}\n\nexport interface MistralProviderSettings {\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.mistral.ai/v1`.\n */\n baseURL?: string;\n\n /**\n * API key that is being send using the `Authorization` header.\n * It defaults to the `MISTRAL_API_KEY` environment variable.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n generateId?: () => string;\n}\n\n/**\n * Create a Mistral AI provider instance.\n */\nexport function createMistral(\n options: MistralProviderSettings = {},\n): MistralProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ?? 'https://api.mistral.ai/v1';\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MISTRAL_API_KEY',\n description: 'Mistral',\n })}`,\n ...options.headers,\n },\n `ai-sdk-mistral/${VERSION}`,\n );\n\n const createChatModel = (modelId: MistralChatModelId) =>\n new MistralChatLanguageModel(modelId, {\n provider: 'mistral.chat',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId: options.generateId,\n });\n\n const createEmbeddingModel = (modelId: MistralEmbeddingModelId) =>\n new MistralEmbeddingModel(modelId, {\n provider: 'mistral.embedding',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createConversationModel = (modelId: MistralChatModelId) =>\n new MistralConversationLanguageModel(modelId, {\n provider: 'mistral.conversation',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId: options.generateId,\n });\n\n const createSpeechModel = (modelId: MistralSpeechModelId) =>\n new MistralSpeechModel(modelId, {\n provider: 'mistral.speech',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createTranscriptionModel = (modelId: MistralTranscriptionModelId) =>\n new MistralTranscriptionModel(modelId, {\n provider: 'mistral.transcription',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: MistralChatModelId) {\n if (new.target) {\n throw new Error(\n 'The Mistral model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.conversation = createConversationModel;\n provider.tools = mistralTools;\n provider.embedding = createEmbeddingModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\n/**\n * Default Mistral provider instance.\n */\nexport const mistral = createMistral();\n"],"mappings":";;;;AAIA,MAAM,mCAAmC,EACtC,OAAO;CACN,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CA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EACD,GAAG,QAAQ;CACb,GACA,kBAAkB,SACpB;CAEF,MAAM,mBAAmB,YACvB,IAAI,yBAAyB,SAAS;EACpC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;EACf,YAAY,QAAQ;CACtB,CAAC;CAEH,MAAM,wBAAwB,YAC5B,IAAI,sBAAsB,SAAS;EACjC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,2BAA2B,YAC/B,IAAI,iCAAiC,SAAS;EAC5C,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;EACf,YAAY,QAAQ;CACtB,CAAC;CAEH,MAAM,qBAAqB,YACzB,IAAI,mBAAmB,SAAS;EAC9B,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,4BAA4B,YAChC,IAAI,0BAA0B,SAAS;EACrC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,WAAW,SAAU,SAA6B;EACtD,IAAI,YACF,MAAM,IAAI,MACR,mEACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,eAAe;CACxB,SAAS,QAAQ;CACjB,SAAS,YAAY;CACrB,SAAS,iBAAiB;CAC1B,SAAS,gBAAgB;CACzB,SAAS,qBAAqB;CAC9B,SAAS,SAAS;CAClB,SAAS,cAAc;CACvB,SAAS,gBAAgB;CACzB,SAAS,qBAAqB;CAE9B,SAAS,cAAc,YAAoB;EACzC,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,OAAO;AACT;;;;AAKA,MAAa,UAAU,cAAc"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_exhaustiveCheck","_exhaustiveCheck","_exhaustiveCheck","_exhaustiveCheck"],"sources":["../src/convert-mistral-usage.ts","../src/convert-to-mistral-chat-messages.ts","../src/map-mistral-finish-reason.ts","../src/mistral-chat-language-model-options.ts","../src/mistral-error.ts","../src/mistral-prepare-tools.ts","../src/mistral-chat-language-model.ts","../src/convert-to-mistral-conversation-inputs.ts","../src/mistral-conversation-language-model-options.ts","../src/mistral-conversation-prepare-tools.ts","../src/mistral-conversation-language-model.ts","../src/mistral-embedding-model-options.ts","../src/mistral-embedding-model.ts","../src/mistral-speech-model-options.ts","../src/mistral-speech-model.ts","../src/mistral-transcription-model-options.ts","../src/mistral-transcription-model.ts","../src/version.ts","../src/tool/web-search.ts","../src/tool/index.ts","../src/mistral-provider.ts"],"sourcesContent":["import type { LanguageModelV4Usage } from '@ai-sdk/provider';\nimport { createNullLanguageModelUsage } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralPromptTokensDetailsSchema = z\n .object({\n messages: z.array(z.json()).nullish(),\n cached_tokens: z.number().nullish(),\n audio_tokens: z.number().nullish(),\n })\n .catchall(z.json());\n\nconst mistralCompletionTokensDetailsSchema = z\n .object({\n reasoning_tokens: z.number().nullish(),\n })\n .catchall(z.json());\n\nexport const mistralUsageSchema = z\n .object({\n prompt_tokens: z.number(),\n completion_tokens: z.number(),\n total_tokens: z.number(),\n prompt_audio_seconds: z.number().nullish(),\n request_count: z.number().nullish(),\n service_tier: z.string().nullish(),\n num_cached_tokens: z.number().nullish(),\n prompt_tokens_details: mistralPromptTokensDetailsSchema.nullish(),\n prompt_token_details: mistralPromptTokensDetailsSchema.nullish(),\n completion_tokens_details: mistralCompletionTokensDetailsSchema.nullish(),\n })\n .catchall(z.json());\n\nexport type MistralUsage = z.infer<typeof mistralUsageSchema>;\n\nexport function convertMistralUsage(\n usage: MistralUsage | undefined | null,\n): LanguageModelV4Usage {\n if (usage == null) {\n return createNullLanguageModelUsage();\n }\n\n const promptTokens = usage.prompt_tokens;\n const completionTokens = usage.completion_tokens;\n\n const cacheReadTokens =\n usage.num_cached_tokens ??\n usage.prompt_tokens_details?.cached_tokens ??\n usage.prompt_token_details?.cached_tokens ??\n 0;\n\n return {\n inputTokens: {\n total: promptTokens,\n noCache: promptTokens - cacheReadTokens,\n cacheRead: cacheReadTokens || undefined,\n cacheWrite: undefined,\n },\n outputTokens: {\n total: completionTokens,\n text: completionTokens,\n reasoning: undefined,\n },\n raw: usage,\n };\n}\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4FilePart,\n type LanguageModelV4Prompt,\n} from '@ai-sdk/provider';\nimport type {\n MistralAssistantMessageContent,\n MistralPrompt,\n} from './mistral-chat-prompt';\nimport {\n convertToBase64,\n getTopLevelMediaType,\n resolveFullMediaType,\n} from '@ai-sdk/provider-utils';\n\nfunction formatFileUrl({ part }: { part: LanguageModelV4FilePart }): string {\n if (part.data.type === 'url') {\n return part.data.url.toString();\n }\n\n if (part.data.type === 'data') {\n return `data:${resolveFullMediaType({ part })};base64,${convertToBase64(part.data.data)}`;\n }\n\n throw new UnsupportedFunctionalityError({\n functionality: `file part data type ${part.data.type}`,\n });\n}\n\nexport function convertToMistralChatMessages(\n prompt: LanguageModelV4Prompt,\n): MistralPrompt {\n const messages: MistralPrompt = [];\n\n for (let i = 0; i < prompt.length; i++) {\n const { role, content } = prompt[i];\n const isLastMessage = i === prompt.length - 1;\n\n switch (role) {\n case 'system': {\n messages.push({ role: 'system', content });\n break;\n }\n\n case 'user': {\n messages.push({\n role: 'user',\n content: content.map(part => {\n switch (part.type) {\n case 'text': {\n return { type: 'text', text: part.text };\n }\n\n case 'file': {\n switch (part.data.type) {\n case 'reference': {\n throw new UnsupportedFunctionalityError({\n functionality: 'file parts with provider references',\n });\n }\n case 'text': {\n throw new UnsupportedFunctionalityError({\n functionality: 'text file parts',\n });\n }\n case 'url':\n case 'data': {\n const topLevel = getTopLevelMediaType(part.mediaType);\n\n if (topLevel === 'image') {\n return {\n type: 'image_url',\n image_url: formatFileUrl({ part }),\n };\n } else {\n if (part.data.type === 'data') {\n const fullMediaType = resolveFullMediaType({ part });\n if (fullMediaType !== 'application/pdf') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only images and PDF file parts are supported',\n });\n }\n } else if (part.mediaType !== 'application/pdf') {\n throw new UnsupportedFunctionalityError({\n functionality:\n 'Only images and PDF file parts are supported',\n });\n }\n\n return {\n type: 'document_url',\n document_url: formatFileUrl({ part }),\n };\n }\n }\n }\n }\n }\n }),\n });\n break;\n }\n\n case 'assistant': {\n let text = '';\n let hasReasoning = false;\n const contentParts: Array<MistralAssistantMessageContent> = [];\n const toolCalls: Array<{\n id: string;\n type: 'function';\n function: { name: string; arguments: string };\n }> = [];\n\n for (const part of content) {\n switch (part.type) {\n case 'text': {\n text += part.text;\n contentParts.push({ type: 'text', text: part.text });\n break;\n }\n case 'tool-call': {\n toolCalls.push({\n id: part.toolCallId,\n type: 'function',\n function: {\n name: part.toolName,\n arguments: JSON.stringify(part.input),\n },\n });\n break;\n }\n case 'reasoning': {\n hasReasoning = true;\n contentParts.push({\n type: 'thinking',\n thinking: [{ type: 'text', text: part.text }],\n closed: true,\n });\n break;\n }\n default: {\n throw new Error(\n `Unsupported content type in assistant message: ${part.type}`,\n );\n }\n }\n }\n\n messages.push({\n role: 'assistant',\n content: hasReasoning ? contentParts : text,\n prefix: isLastMessage ? true : undefined,\n tool_calls: toolCalls.length > 0 ? toolCalls : undefined,\n });\n\n break;\n }\n case 'tool': {\n for (const toolResponse of content) {\n if (toolResponse.type === 'tool-approval-response') {\n continue;\n }\n const output = toolResponse.output;\n\n let contentValue: string;\n switch (output.type) {\n case 'text':\n case 'error-text':\n contentValue = output.value;\n break;\n case 'execution-denied':\n contentValue = output.reason ?? 'Tool call execution denied.';\n break;\n case 'content':\n case 'json':\n case 'error-json':\n contentValue = JSON.stringify(output.value);\n break;\n }\n\n messages.push({\n role: 'tool',\n name: toolResponse.toolName,\n tool_call_id: toolResponse.toolCallId,\n content: contentValue,\n });\n }\n break;\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unsupported role: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return messages;\n}\n","import type { LanguageModelV4FinishReason } from '@ai-sdk/provider';\n\nexport function mapMistralFinishReason(\n finishReason: string | null | undefined,\n): LanguageModelV4FinishReason['unified'] {\n switch (finishReason) {\n case 'stop':\n return 'stop';\n case 'length':\n case 'model_length':\n return 'length';\n case 'tool_calls':\n return 'tool-calls';\n case 'error':\n return 'error';\n default:\n return 'other';\n }\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\n// https://docs.mistral.ai/models\nexport type MistralChatModelId =\n | 'codestral-2508'\n | 'codestral-latest'\n | 'glm-5-2'\n | 'labs-leanstral-1-5'\n | 'labs-leanstral-1-5-1'\n | 'magistral-medium-latest'\n | 'magistral-small-latest'\n | 'ministral-14b-2512'\n | 'ministral-14b-latest'\n | 'ministral-3b-2512'\n | 'ministral-3b-latest'\n | 'ministral-8b-2512'\n | 'ministral-8b-latest'\n | 'mistral-code-fim-latest'\n | 'mistral-code-latest'\n | 'mistral-large-4'\n | 'mistral-large-4-0'\n | 'mistral-large-latest'\n | 'mistral-large-2512'\n | 'mistral-medium'\n | 'mistral-medium-latest'\n | 'mistral-medium-2604'\n | 'mistral-medium-3'\n | 'mistral-medium-3-5'\n | 'mistral-medium-3.5'\n | 'mistral-small-2603'\n | 'mistral-small-latest'\n | 'mistral-vibe-cli-fast'\n | 'mistral-vibe-cli-latest'\n | 'mistral-vibe-cli-with-tools'\n | 'voxtral-small-2507'\n | 'voxtral-small-latest'\n | 'zai-glm-5-2'\n | (string & {});\n\nexport const mistralLanguageModelChatOptions = () =>\n z.object({\n /**\n * Whether to inject a safety prompt before all conversations.\n *\n * Defaults to `false`.\n */\n safePrompt: z.boolean().optional(),\n\n documentImageLimit: z.number().optional(),\n documentPageLimit: z.number().optional(),\n\n /**\n * Whether to use structured outputs.\n *\n * @default true\n */\n structuredOutputs: z.boolean().optional(),\n\n /**\n * Whether to use strict JSON schema validation.\n *\n * @default false\n */\n strictJsonSchema: z.boolean().optional(),\n\n /**\n * Whether to enable parallel function calling during tool use.\n * When set to false, the model will use at most one tool per response.\n *\n * @default true\n */\n parallelToolCalls: z.boolean().optional(),\n\n /**\n * A stable identifier used to route requests with shared prompt prefixes to\n * the same cache.\n */\n promptCacheKey: z.string().optional(),\n\n /**\n * Controls the reasoning effort for models that support adjustable reasoning.\n *\n * - `'high'`: Enable reasoning\n * - `'none'`: Disable reasoning\n */\n reasoningEffort: z.enum(['high', 'none']).optional(),\n });\nexport const mistralLanguageModelChatOptionsValidator = lazySchema(() =>\n zodSchema(mistralLanguageModelChatOptions()),\n);\n\nexport type MistralLanguageModelChatOptions = z.infer<\n ReturnType<typeof mistralLanguageModelChatOptions>\n>;\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n createJsonErrorResponseHandler,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralErrorDataSchema = lazySchema(() =>\n zodSchema(\n z.object({\n object: z.literal('error'),\n message: z.string(),\n type: z.string(),\n param: z.string().nullable(),\n code: z.string().nullable(),\n }),\n ),\n);\n\nexport type MistralErrorData = InferSchema<typeof mistralErrorDataSchema>;\n\nexport const mistralFailedResponseHandler = createJsonErrorResponseHandler({\n errorSchema: mistralErrorDataSchema,\n errorToMessage: data => data.message,\n});\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type { MistralToolChoice } from './mistral-chat-prompt';\n\nexport function prepareTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools:\n | Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n }>\n | undefined;\n toolChoice: MistralToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const mistralTools: Array<{\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n }> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n mistralTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: mistralTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n return { tools: mistralTools, toolChoice: type, toolWarnings };\n case 'required':\n return { tools: mistralTools, toolChoice: 'any', toolWarnings };\n\n // mistral does not support tool mode directly,\n // so we filter the tools and force the tool choice through 'any'\n case 'tool':\n return {\n tools: mistralTools.filter(\n tool => tool.function.name === toolChoice.toolName,\n ),\n toolChoice: 'any',\n toolWarnings,\n };\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4Content,\n LanguageModelV4FinishReason,\n LanguageModelV4GenerateResult,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n generateId,\n injectJsonInstructionIntoMessages,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type ParseResult,\n type StreamingToolCallDelta,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n convertMistralUsage,\n mistralUsageSchema,\n type MistralUsage,\n} from './convert-mistral-usage';\nimport { convertToMistralChatMessages } from './convert-to-mistral-chat-messages';\nimport { getResponseMetadata } from './get-response-metadata';\nimport { mapMistralFinishReason } from './map-mistral-finish-reason';\nimport {\n mistralLanguageModelChatOptionsValidator,\n type MistralChatModelId,\n} from './mistral-chat-language-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport { prepareTools } from './mistral-prepare-tools';\n\ntype MistralChatConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n generateId?: () => string;\n};\n\n// Known non-reasoning models from https://api.mistral.ai/v1/models\n// (2026-10-06). Unknown IDs inherit current reasoning configuration support.\nconst modelsWithoutReasoningEffort = new Set<MistralChatModelId>([\n 'codestral-2508',\n 'codestral-latest',\n 'ministral-14b-2512',\n 'ministral-14b-latest',\n 'ministral-3b-2512',\n 'ministral-3b-latest',\n 'ministral-8b-2512',\n 'ministral-8b-latest',\n 'mistral-code-fim-latest',\n 'mistral-code-latest',\n 'mistral-large-latest',\n 'mistral-large-2512',\n 'voxtral-small-2507',\n 'voxtral-small-latest',\n]);\n\nexport class MistralChatLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: MistralChatModelId;\n\n private readonly config: MistralChatConfig;\n private readonly generateId: () => string;\n\n static [WORKFLOW_SERIALIZE](model: MistralChatLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralChatModelId;\n config: MistralChatConfig;\n }) {\n return new MistralChatLanguageModel(options.modelId, options.config);\n }\n\n constructor(modelId: MistralChatModelId, config: MistralChatConfig) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n readonly supportedUrls: Record<string, RegExp[]> = {\n 'application/pdf': [/^https:\\/\\/.*$/],\n };\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n reasoning,\n stopSequences,\n responseFormat,\n seed,\n providerOptions,\n tools,\n toolChoice,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const options =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralLanguageModelChatOptionsValidator,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n const supportsReasoningEffort = !modelsWithoutReasoningEffort.has(\n this.modelId,\n );\n\n let resolvedReasoningEffort: string | undefined;\n if (supportsReasoningEffort) {\n resolvedReasoningEffort =\n options.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'high',\n low: 'high',\n medium: 'high',\n high: 'high',\n xhigh: 'high',\n max: 'high',\n },\n warnings,\n })\n : undefined);\n } else if (isCustomReasoning(reasoning)) {\n warnings.push({\n type: 'unsupported',\n feature: 'reasoning',\n details: 'This model does not support reasoning configuration.',\n });\n }\n\n const structuredOutputs = options.structuredOutputs ?? true;\n const strictJsonSchema = options.strictJsonSchema ?? false;\n\n // For Mistral we need to instruct the model when using JSON Object mode.\n // https://docs.mistral.ai/capabilities/structured-output/structured_output_overview/\n if (\n responseFormat?.type === 'json' &&\n (!structuredOutputs || responseFormat.schema == null)\n ) {\n prompt = injectJsonInstructionIntoMessages({\n messages: prompt,\n schema: responseFormat.schema,\n });\n }\n\n const baseArgs = {\n // model id:\n model: this.modelId,\n\n // model specific settings:\n safe_prompt: options.safePrompt,\n\n // standardized settings:\n max_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(frequencyPenalty != null\n ? { frequency_penalty: frequencyPenalty }\n : {}),\n ...(presencePenalty != null ? { presence_penalty: presencePenalty } : {}),\n stop: stopSequences,\n random_seed: seed,\n reasoning_effort: resolvedReasoningEffort,\n\n // response format:\n response_format:\n responseFormat?.type === 'json'\n ? structuredOutputs && responseFormat?.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: strictJsonSchema,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n\n // mistral-specific provider options:\n document_image_limit: options.documentImageLimit,\n document_page_limit: options.documentPageLimit,\n ...(options.promptCacheKey !== undefined\n ? { prompt_cache_key: options.promptCacheKey }\n : {}),\n\n // messages:\n messages: convertToMistralChatMessages(prompt),\n };\n\n const {\n tools: mistralTools,\n toolChoice: mistralToolChoice,\n toolWarnings,\n } = prepareTools({\n tools,\n toolChoice,\n });\n\n return {\n args: {\n ...baseArgs,\n tools: mistralTools,\n tool_choice: mistralToolChoice,\n ...(mistralTools != null && options.parallelToolCalls !== undefined\n ? { parallel_tool_calls: options.parallelToolCalls }\n : {}),\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args: body, warnings } = await this.getArgs(options);\n\n const {\n responseHeaders,\n value: response,\n rawValue: rawResponse,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/chat/completions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralChatResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const choice = response.choices[0];\n const content: Array<LanguageModelV4Content> = [];\n\n // process content parts in order to preserve sequence\n if (\n choice.message.content != null &&\n Array.isArray(choice.message.content)\n ) {\n for (const part of choice.message.content) {\n if (part.type === 'thinking') {\n const reasoningText = extractReasoningContent(part.thinking);\n if (reasoningText.length > 0) {\n content.push({ type: 'reasoning', text: reasoningText });\n }\n } else if (part.type === 'text') {\n if (part.text.length > 0) {\n content.push({ type: 'text', text: part.text });\n }\n }\n }\n } else {\n // handle legacy string content\n const text = extractTextContent(choice.message.content);\n if (text != null && text.length > 0) {\n content.push({ type: 'text', text });\n }\n }\n\n // when there is a trailing assistant message, mistral will send the\n // content of that message again. we skip this repeated content to\n // avoid duplication, e.g. in continuation mode.\n\n // tool calls:\n if (choice.message.tool_calls != null) {\n for (const toolCall of choice.message.tool_calls) {\n content.push({\n type: 'tool-call',\n toolCallId: toolCall.id,\n toolName: toolCall.function.name,\n input: toolCall.function.arguments!,\n });\n }\n }\n\n return {\n content,\n finishReason: {\n unified: mapMistralFinishReason(choice.finish_reason),\n raw: choice.finish_reason ?? undefined,\n },\n usage: convertMistralUsage(response.usage),\n request: { body },\n response: {\n ...getResponseMetadata(response),\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { responseHeaders, value: response } = await postJsonToApi({\n url: `${this.config.baseURL}/chat/completions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n mistralChatChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n // A clean end without the provider's completion signal is interrupted.\n let finishReason: LanguageModelV4FinishReason = {\n unified: 'interrupted',\n raw: undefined,\n };\n let usage: MistralUsage | undefined = undefined;\n\n let isFirstChunk = true;\n let activeText = false;\n let activeReasoningId: string | null = null;\n let toolCallTracker: StreamingToolCallTracker<StreamingToolCallDelta>;\n\n const generateId = this.generateId;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof mistralChatChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n // Emit raw chunk if requested (before anything else)\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n finishReason = { unified: 'error', raw: undefined };\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n\n const value = chunk.value;\n\n if (isFirstChunk) {\n isFirstChunk = false;\n\n controller.enqueue({\n type: 'response-metadata',\n ...getResponseMetadata(value),\n });\n }\n\n if (value.usage != null) {\n usage = value.usage;\n }\n\n const choice = value.choices[0];\n const delta = choice.delta;\n\n const textContent = extractTextContent(delta.content);\n\n if (delta.content != null && Array.isArray(delta.content)) {\n for (const part of delta.content) {\n if (part.type === 'thinking') {\n const reasoningDelta = extractReasoningContent(part.thinking);\n if (reasoningDelta.length > 0) {\n if (activeReasoningId == null) {\n // end any active text before starting reasoning\n if (activeText) {\n controller.enqueue({ type: 'text-end', id: '0' });\n activeText = false;\n }\n\n activeReasoningId = generateId();\n controller.enqueue({\n type: 'reasoning-start',\n id: activeReasoningId,\n });\n }\n controller.enqueue({\n type: 'reasoning-delta',\n id: activeReasoningId,\n delta: reasoningDelta,\n });\n }\n }\n }\n }\n\n if (textContent != null && textContent.length > 0) {\n if (!activeText) {\n // if we were in reasoning mode, end it before starting text\n if (activeReasoningId != null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: activeReasoningId,\n });\n activeReasoningId = null;\n }\n controller.enqueue({ type: 'text-start', id: '0' });\n activeText = true;\n }\n\n controller.enqueue({\n type: 'text-delta',\n id: '0',\n delta: textContent,\n });\n }\n\n if (delta?.tool_calls != null) {\n for (const toolCall of delta.tool_calls) {\n toolCallTracker.processDelta(toolCall);\n }\n }\n\n if (choice.finish_reason != null) {\n finishReason = {\n unified: mapMistralFinishReason(choice.finish_reason),\n raw: choice.finish_reason,\n };\n }\n },\n\n flush(controller) {\n if (activeReasoningId != null) {\n controller.enqueue({\n type: 'reasoning-end',\n id: activeReasoningId,\n });\n }\n if (activeText) {\n controller.enqueue({ type: 'text-end', id: '0' });\n }\n\n toolCallTracker.flush();\n\n controller.enqueue({\n type: 'finish',\n finishReason,\n usage: convertMistralUsage(usage),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\nfunction extractReasoningContent(\n thinking: Array<{ type: string; text: string }>,\n) {\n return thinking\n .filter(chunk => chunk.type === 'text')\n .map(chunk => chunk.text)\n .join('');\n}\n\nfunction extractTextContent(\n content: z.infer<ReturnType<typeof mistralContentSchema>>,\n) {\n if (typeof content === 'string') {\n return content;\n }\n\n if (content == null) {\n return undefined;\n }\n\n const textContent: string[] = [];\n\n for (const chunk of content) {\n const { type } = chunk;\n\n switch (type) {\n case 'text':\n textContent.push(chunk.text);\n break;\n case 'thinking':\n case 'image_url':\n case 'reference':\n // thinking, image content, and reference content are currently ignored\n break;\n default: {\n const _exhaustiveCheck: never = type;\n throw new Error(`Unsupported type: ${_exhaustiveCheck}`);\n }\n }\n }\n\n return textContent.length ? textContent.join('') : undefined;\n}\n\nconst mistralContentSchema = () =>\n z\n .union([\n z.string(),\n z.array(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n z.object({\n type: z.literal('image_url'),\n image_url: z.union([\n z.string(),\n z.object({\n url: z.string(),\n detail: z.string().nullable(),\n }),\n ]),\n }),\n z.object({\n type: z.literal('reference'),\n reference_ids: z.array(z.union([z.string(), z.number()])),\n }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.array(\n z.object({\n type: z.literal('text'),\n text: z.string(),\n }),\n ),\n }),\n ]),\n ),\n ])\n .nullish();\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst mistralChatResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n choices: z.array(\n z.object({\n message: z.object({\n role: z.literal('assistant'),\n content: mistralContentSchema(),\n tool_calls: z\n .array(\n z.object({\n id: z.string(),\n function: z.object({\n name: z.string(),\n arguments: z.string(),\n }),\n }),\n )\n .nullish(),\n }),\n index: z.number(),\n finish_reason: z.string().nullish(),\n }),\n ),\n object: z.literal('chat.completion'),\n usage: mistralUsageSchema,\n }),\n ),\n);\n\n// limited version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst mistralChatChunkSchema = lazySchema(() =>\n zodSchema(\n z.object({\n id: z.string().nullish(),\n created: z.number().nullish(),\n model: z.string().nullish(),\n choices: z.array(\n z.object({\n delta: z.object({\n role: z.enum(['assistant']).optional(),\n content: mistralContentSchema(),\n tool_calls: z\n .array(\n z.object({\n index: z.number().nullish(),\n id: z.string().nullish(),\n function: z.object({\n name: z.string().nullish(),\n arguments: z.string().nullish(),\n }),\n }),\n )\n .nullish(),\n }),\n finish_reason: z.string().nullish(),\n index: z.number(),\n }),\n ),\n usage: mistralUsageSchema.nullish(),\n }),\n ),\n);\n","import {\n UnsupportedFunctionalityError,\n type JSONValue,\n type LanguageModelV4Prompt,\n type LanguageModelV4ToolResultPart,\n} from '@ai-sdk/provider';\nimport type { ToolNameMapping } from '@ai-sdk/provider-utils';\nimport { convertToMistralChatMessages } from './convert-to-mistral-chat-messages';\nimport type {\n MistralAssistantMessageContent,\n MistralToolMessage,\n MistralUserMessageContent,\n} from './mistral-chat-prompt';\n\ntype ConversationInput =\n | {\n type: 'message.input';\n role: 'user' | 'assistant';\n content: Array<\n MistralUserMessageContent | MistralAssistantMessageContent\n >;\n }\n | {\n type: 'function.call';\n tool_call_id: string;\n name: string;\n arguments: string;\n }\n | { type: 'function.result'; tool_call_id: string; result: string };\n\nexport function convertToMistralConversationInputs(\n prompt: LanguageModelV4Prompt,\n toolNameMapping: ToolNameMapping,\n) {\n const inputs: ConversationInput[] = [];\n const instructions: string[] = [];\n const executions = new Set<string>();\n const appendToolResult = (part: LanguageModelV4ToolResultPart) => {\n if (executions.has(part.toolCallId)) {\n let result: JSONValue = null;\n if (part.output.type === 'json') {\n const value = part.output.value;\n const info =\n value != null && typeof value === 'object' && 'info' in value\n ? value.info\n : undefined;\n if (info != null && typeof info === 'object' && !Array.isArray(info)) {\n result = 'result' in info ? (info.result ?? info) : info;\n }\n }\n inputs.push({\n type: 'function.result',\n tool_call_id: part.toolCallId,\n result: typeof result === 'string' ? result : JSON.stringify(result),\n });\n return;\n }\n const converted = convertToMistralChatMessages([\n { role: 'tool', content: [part] },\n ])[0] as MistralToolMessage;\n inputs.push({\n type: 'function.result',\n tool_call_id: part.toolCallId,\n result: converted.content,\n });\n };\n\n for (const message of prompt) {\n switch (message.role) {\n case 'system':\n instructions.push(message.content);\n break;\n case 'user': {\n const converted = convertToMistralChatMessages([message])[0];\n if (converted.role === 'user') {\n inputs.push({\n type: 'message.input',\n role: 'user',\n content: converted.content,\n });\n }\n break;\n }\n case 'assistant': {\n let content: MistralAssistantMessageContent[] = [];\n const flush = () => {\n if (content.length > 0) {\n inputs.push({ type: 'message.input', role: 'assistant', content });\n content = [];\n }\n };\n for (const part of message.content) {\n switch (part.type) {\n case 'text':\n content.push({ type: 'text', text: part.text });\n break;\n case 'reasoning':\n content.push({\n type: 'thinking',\n thinking: [{ type: 'text', text: part.text }],\n closed: true,\n });\n break;\n case 'tool-call': {\n flush();\n if (part.providerExecuted) {\n const name =\n part.providerOptions?.mistral?.function ??\n part.providerOptions?.mistral?.name;\n const args = part.input as { arguments?: unknown } | null;\n // Replay built-in executions as calls and results. Entry IDs\n // and tool.execution output entries cannot be sent as inputs.\n inputs.push({\n type: 'function.call',\n tool_call_id: part.toolCallId,\n name:\n typeof name === 'string'\n ? name\n : toolNameMapping.toProviderToolName(part.toolName),\n arguments:\n typeof args?.arguments === 'string'\n ? args.arguments\n : JSON.stringify(part.input),\n });\n executions.add(part.toolCallId);\n } else {\n inputs.push({\n type: 'function.call',\n tool_call_id: part.toolCallId,\n name: part.toolName,\n arguments: JSON.stringify(part.input),\n });\n }\n break;\n }\n case 'tool-result':\n flush();\n appendToolResult(part);\n break;\n default:\n throw new UnsupportedFunctionalityError({\n functionality: `assistant content type: ${part.type}`,\n });\n }\n }\n flush();\n break;\n }\n case 'tool':\n for (const part of message.content) {\n if (part.type === 'tool-approval-response') {\n continue;\n }\n appendToolResult(part);\n }\n break;\n }\n }\n\n return {\n inputs,\n instructions:\n instructions.length > 0 ? instructions.join('\\n\\n') : undefined,\n };\n}\n","import { lazySchema, zodSchema } from '@ai-sdk/provider-utils';\nimport {\n mistralLanguageModelChatOptions,\n type MistralChatModelId,\n type MistralLanguageModelChatOptions,\n} from './mistral-chat-language-model-options';\n\nexport type MistralConversationModelId = MistralChatModelId;\n\nexport const mistralLanguageModelConversationOptions = lazySchema(() =>\n zodSchema(mistralLanguageModelChatOptions()),\n);\n\nexport type MistralLanguageModelConversationOptions =\n MistralLanguageModelChatOptions;\n","import {\n UnsupportedFunctionalityError,\n type LanguageModelV4CallOptions,\n type SharedV4Warning,\n} from '@ai-sdk/provider';\nimport type { MistralToolChoice } from './mistral-chat-prompt';\nimport { createToolNameMapping } from '@ai-sdk/provider-utils';\n\ntype MistralTool =\n | { type: 'web_search' | 'web_search_premium' }\n | {\n type: 'function';\n function: {\n name: string;\n description: string | undefined;\n parameters: unknown;\n strict?: boolean;\n };\n };\n\nexport const mistralProviderToolNames = {\n 'mistral.web_search': 'web_search',\n 'mistral.web_search_premium': 'web_search_premium',\n} as const;\n\nexport function prepareConversationTools({\n tools,\n toolChoice,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n toolChoice?: LanguageModelV4CallOptions['toolChoice'];\n}): {\n tools: Array<MistralTool> | undefined;\n toolChoice: MistralToolChoice | undefined;\n toolWarnings: SharedV4Warning[];\n} {\n // when the tools array is empty, change it to undefined to prevent errors:\n tools = tools?.length ? tools : undefined;\n\n const toolWarnings: SharedV4Warning[] = [];\n\n if (tools == null) {\n return { tools: undefined, toolChoice: undefined, toolWarnings };\n }\n\n const mistralTools: Array<MistralTool> = [];\n\n for (const tool of tools) {\n if (tool.type === 'provider') {\n if (\n tool.id === 'mistral.web_search' ||\n tool.id === 'mistral.web_search_premium'\n ) {\n mistralTools.push({ type: mistralProviderToolNames[tool.id] });\n continue;\n }\n toolWarnings.push({\n type: 'unsupported',\n feature: `provider-defined tool ${tool.id}`,\n });\n } else {\n mistralTools.push({\n type: 'function',\n function: {\n name: tool.name,\n description: tool.description,\n parameters: tool.inputSchema,\n ...(tool.strict != null ? { strict: tool.strict } : {}),\n },\n });\n }\n }\n\n if (toolChoice == null) {\n return { tools: mistralTools, toolChoice: undefined, toolWarnings };\n }\n\n const type = toolChoice.type;\n\n switch (type) {\n case 'auto':\n case 'none':\n return { tools: mistralTools, toolChoice: type, toolWarnings };\n case 'required':\n return { tools: mistralTools, toolChoice: 'any', toolWarnings };\n\n // mistral does not support tool mode directly,\n // so we filter the tools and force the tool choice through 'any'\n case 'tool': {\n const toolName = createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n }).toProviderToolName(toolChoice.toolName);\n return {\n tools: mistralTools.filter(tool =>\n tool.type === 'function'\n ? tool.function.name === toolName\n : tool.type === toolName,\n ),\n toolChoice: 'any',\n toolWarnings,\n };\n }\n default: {\n const _exhaustiveCheck: never = type;\n throw new UnsupportedFunctionalityError({\n functionality: `tool choice type: ${_exhaustiveCheck}`,\n });\n }\n }\n}\n","import type {\n LanguageModelV4,\n LanguageModelV4CallOptions,\n LanguageModelV4Content,\n LanguageModelV4GenerateResult,\n LanguageModelV4Reasoning,\n LanguageModelV4Source,\n LanguageModelV4StreamPart,\n LanguageModelV4StreamResult,\n LanguageModelV4Text,\n LanguageModelV4ToolCall,\n LanguageModelV4ToolResult,\n SharedV4Warning,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n type InferSchema,\n combineHeaders,\n createEventSourceResponseHandler,\n createJsonResponseHandler,\n createToolNameMapping,\n generateId,\n injectJsonInstructionIntoMessages,\n isCustomReasoning,\n mapReasoningToProviderEffort,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n StreamingToolCallTracker,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n type ParseResult,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n convertMistralUsage,\n mistralUsageSchema,\n type MistralUsage,\n} from './convert-mistral-usage';\nimport { convertToMistralConversationInputs } from './convert-to-mistral-conversation-inputs';\nimport {\n mistralLanguageModelConversationOptions,\n type MistralConversationModelId,\n} from './mistral-conversation-language-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralProviderToolNames,\n prepareConversationTools,\n} from './mistral-conversation-prepare-tools';\n\ntype MistralConversationConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n generateId?: () => string;\n};\n\n// https://api.mistral.ai/v1/models (2026-10-06)\nconst reasoningEffortModelIds = new Set<MistralConversationModelId>([\n 'glm-5-2',\n 'labs-leanstral-1-5',\n 'labs-leanstral-1-5-1',\n 'magistral-medium-latest',\n 'magistral-small-latest',\n 'mistral-large-4',\n 'mistral-large-4-0',\n 'mistral-medium',\n 'mistral-medium-2604',\n 'mistral-medium-3',\n 'mistral-medium-3-5',\n 'mistral-medium-3.5',\n 'mistral-medium-latest',\n 'mistral-small-2603',\n 'mistral-small-latest',\n 'mistral-vibe-cli-fast',\n 'mistral-vibe-cli-latest',\n 'mistral-vibe-cli-with-tools',\n 'zai-glm-5-2',\n]);\n\nexport class MistralConversationLanguageModel implements LanguageModelV4 {\n readonly specificationVersion = 'v4';\n\n readonly modelId: MistralConversationModelId;\n\n private readonly config: MistralConversationConfig;\n private readonly generateId: () => string;\n\n static [WORKFLOW_SERIALIZE](model: MistralConversationLanguageModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralConversationModelId;\n config: MistralConversationConfig;\n }) {\n return new MistralConversationLanguageModel(\n options.modelId,\n options.config,\n );\n }\n\n constructor(\n modelId: MistralConversationModelId,\n config: MistralConversationConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n this.generateId = config.generateId ?? generateId;\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n readonly supportedUrls: Record<string, RegExp[]> = {\n 'application/pdf': [/^https:\\/\\/.*$/],\n };\n\n private async getArgs({\n prompt,\n maxOutputTokens,\n temperature,\n topP,\n topK,\n frequencyPenalty,\n presencePenalty,\n reasoning,\n stopSequences,\n responseFormat,\n seed,\n providerOptions,\n tools,\n toolChoice,\n }: LanguageModelV4CallOptions) {\n const warnings: SharedV4Warning[] = [];\n\n const options =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralLanguageModelConversationOptions,\n })) ?? {};\n\n if (topK != null) {\n warnings.push({ type: 'unsupported', feature: 'topK' });\n }\n\n const supportsReasoningEffort = reasoningEffortModelIds.has(this.modelId);\n\n let resolvedReasoningEffort: string | undefined;\n if (supportsReasoningEffort) {\n resolvedReasoningEffort =\n options.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: {\n minimal: 'high',\n low: 'high',\n medium: 'high',\n high: 'high',\n xhigh: 'high',\n max: 'high',\n },\n warnings,\n })\n : undefined);\n } else if (isCustomReasoning(reasoning)) {\n warnings.push({\n type: 'unsupported',\n feature: 'reasoning',\n details: 'This model does not support reasoning configuration.',\n });\n }\n\n const structuredOutputs = options.structuredOutputs ?? true;\n const strictJsonSchema = options.strictJsonSchema ?? false;\n\n // For Mistral we need to instruct the model when using JSON Object mode.\n // https://docs.mistral.ai/capabilities/structured-output/structured_output_overview/\n if (\n responseFormat?.type === 'json' &&\n (!structuredOutputs || responseFormat.schema == null)\n ) {\n prompt = injectJsonInstructionIntoMessages({\n messages: prompt,\n schema: responseFormat.schema,\n });\n }\n\n const baseArgs = {\n // standardized settings:\n max_tokens: maxOutputTokens,\n temperature,\n top_p: topP,\n ...(frequencyPenalty != null\n ? { frequency_penalty: frequencyPenalty }\n : {}),\n ...(presencePenalty != null ? { presence_penalty: presencePenalty } : {}),\n stop: stopSequences,\n random_seed: seed,\n reasoning_effort: resolvedReasoningEffort,\n\n // response format:\n response_format:\n responseFormat?.type === 'json'\n ? structuredOutputs && responseFormat?.schema != null\n ? {\n type: 'json_schema',\n json_schema: {\n schema: responseFormat.schema,\n strict: strictJsonSchema,\n name: responseFormat.name ?? 'response',\n description: responseFormat.description,\n },\n }\n : { type: 'json_object' }\n : undefined,\n };\n\n const {\n tools: mistralTools,\n toolChoice: mistralToolChoice,\n toolWarnings,\n } = prepareConversationTools({ tools, toolChoice });\n\n for (const [feature, value] of Object.entries({\n safePrompt: options.safePrompt,\n documentImageLimit: options.documentImageLimit,\n documentPageLimit: options.documentPageLimit,\n promptCacheKey: options.promptCacheKey,\n parallelToolCalls: options.parallelToolCalls,\n })) {\n if (value != null) {\n warnings.push({\n type: 'unsupported',\n feature,\n details: 'Not supported by the Mistral Conversations API.',\n });\n }\n }\n\n return {\n args: {\n model: this.modelId,\n store: false,\n ...convertToMistralConversationInputs(\n prompt,\n createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n }),\n ),\n tools: mistralTools,\n completion_args: { ...baseArgs, tool_choice: mistralToolChoice },\n },\n warnings: [...warnings, ...toolWarnings],\n };\n }\n\n async doGenerate(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4GenerateResult> {\n const { args: body, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n rawValue: rawResponse,\n responseHeaders,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/conversations`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralConversationResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const converter = createContentConverter({\n tools: options.tools,\n generateId: this.generateId,\n });\n const content: LanguageModelV4Content[] = [];\n let hasFunctionCalls = false;\n let modelId: string | undefined;\n\n for (const output of response.outputs) {\n switch (output.type) {\n case 'tool.execution':\n content.push(...converter.convertTool(output));\n break;\n case 'function.call':\n hasFunctionCalls = true;\n content.push({\n type: 'tool-call',\n toolCallId: output.tool_call_id,\n toolName: output.name,\n input:\n typeof output.arguments === 'string'\n ? output.arguments\n : JSON.stringify(output.arguments),\n });\n break;\n case 'message.output':\n modelId = output.model ?? modelId;\n for (const chunk of typeof output.content === 'string'\n ? [{ type: 'text' as const, text: output.content }]\n : output.content) {\n content.push(...converter.convertChunk(chunk));\n }\n break;\n }\n }\n\n return {\n content,\n finishReason: {\n unified: hasFunctionCalls ? 'tool-calls' : 'stop',\n raw: undefined,\n },\n usage: convertMistralUsage(response.usage),\n request: { body },\n response: {\n id: response.conversation_id,\n modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n warnings,\n };\n }\n\n async doStream(\n options: LanguageModelV4CallOptions,\n ): Promise<LanguageModelV4StreamResult> {\n const { args, warnings } = await this.getArgs(options);\n const body = { ...args, stream: true };\n\n const { value: response, responseHeaders } = await postJsonToApi({\n url: `${this.config.baseURL}/conversations`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n body,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createEventSourceResponseHandler(\n mistralConversationChunkSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const converter = createContentConverter({\n tools: options.tools,\n generateId: this.generateId,\n });\n const executions = new Map<\n string,\n { name: string; arguments: string; function?: string | null }\n >();\n let toolCallTracker: StreamingToolCallTracker;\n let active: { id: string; type: 'text' | 'reasoning' } | undefined;\n let usage: MistralUsage | undefined;\n let hasFunctionCalls = false;\n let hasError = false;\n let isDone = false;\n let hasModelId = false;\n const closeContent = (\n controller: TransformStreamDefaultController<LanguageModelV4StreamPart>,\n ) => {\n if (active != null) {\n controller.enqueue({\n type: active.type === 'text' ? 'text-end' : 'reasoning-end',\n id: active.id,\n });\n active = undefined;\n }\n };\n\n const generateId = this.generateId;\n\n return {\n stream: response.pipeThrough(\n new TransformStream<\n ParseResult<InferSchema<typeof mistralConversationChunkSchema>>,\n LanguageModelV4StreamPart\n >({\n start(controller) {\n toolCallTracker = new StreamingToolCallTracker(controller, {\n generateId,\n });\n controller.enqueue({ type: 'stream-start', warnings });\n },\n\n transform(chunk, controller) {\n if (options.includeRawChunks) {\n controller.enqueue({ type: 'raw', rawValue: chunk.rawValue });\n }\n\n if (!chunk.success) {\n hasError = true;\n controller.enqueue({ type: 'error', error: chunk.error });\n return;\n }\n const event = chunk.value;\n switch (event.type) {\n case 'conversation.response.started':\n controller.enqueue({\n type: 'response-metadata',\n id: event.conversation_id,\n ...(event.created_at != null\n ? { timestamp: new Date(event.created_at) }\n : {}),\n });\n break;\n case 'conversation.response.done':\n usage = event.usage ?? undefined;\n isDone = true;\n break;\n case 'conversation.response.error':\n hasError = true;\n controller.enqueue({ type: 'error', error: event });\n break;\n case 'message.output.delta': {\n if (!hasModelId && event.model != null) {\n hasModelId = true;\n controller.enqueue({\n type: 'response-metadata',\n modelId: event.model,\n });\n }\n for (const part of converter.convertChunk(\n typeof event.content === 'string'\n ? { type: 'text', text: event.content }\n : event.content,\n )) {\n if (part.type === 'text' || part.type === 'reasoning') {\n const id = `${event.id}-${event.content_index ?? 0}`;\n if (active?.id !== id || active.type !== part.type) {\n closeContent(controller);\n active = { id, type: part.type };\n controller.enqueue({\n type:\n part.type === 'text'\n ? 'text-start'\n : 'reasoning-start',\n id,\n });\n }\n controller.enqueue({\n type:\n part.type === 'text' ? 'text-delta' : 'reasoning-delta',\n id,\n delta: part.text,\n });\n } else if (part.type === 'source') {\n controller.enqueue(part);\n }\n }\n break;\n }\n case 'function.call.delta':\n closeContent(controller);\n hasFunctionCalls = true;\n toolCallTracker.processDelta({\n id: event.tool_call_id,\n index: event.output_index,\n function: { name: event.name, arguments: event.arguments },\n });\n break;\n case 'tool.execution.started':\n case 'tool.execution.delta': {\n closeContent(controller);\n const execution = executions.get(event.id);\n if (execution == null) {\n executions.set(event.id, {\n name: event.name,\n arguments: event.arguments,\n function: event.function,\n });\n controller.enqueue({\n type: 'tool-input-start',\n id: event.id,\n toolName: converter.toolNameMapping.toCustomToolName(\n event.name,\n ),\n providerExecuted: true,\n });\n } else {\n execution.arguments += event.arguments;\n }\n break;\n }\n case 'tool.execution.done': {\n const execution = executions.get(event.id);\n if (execution == null) {\n hasError = true;\n controller.enqueue({\n type: 'error',\n error: new Error(\n `Missing tool execution start for ${event.id}`,\n ),\n });\n break;\n }\n controller.enqueue({\n type: 'tool-input-delta',\n id: event.id,\n delta: JSON.stringify({ arguments: execution.arguments }),\n });\n controller.enqueue({ type: 'tool-input-end', id: event.id });\n for (const part of converter.convertTool({\n type: 'tool.execution',\n id: event.id,\n name: execution.name,\n arguments: execution.arguments,\n function: event.function ?? execution.function,\n info: event.info,\n })) {\n controller.enqueue(part);\n }\n executions.delete(event.id);\n break;\n }\n }\n },\n\n flush(controller) {\n closeContent(controller);\n toolCallTracker.flush();\n controller.enqueue({\n type: 'finish',\n finishReason: {\n unified:\n hasError || !isDone || executions.size > 0\n ? 'error'\n : hasFunctionCalls\n ? 'tool-calls'\n : 'stop',\n raw: undefined,\n },\n usage: convertMistralUsage(usage),\n });\n },\n }),\n ),\n request: { body },\n response: { headers: responseHeaders },\n };\n }\n}\n\nfunction createContentConverter({\n tools,\n generateId,\n}: {\n tools: LanguageModelV4CallOptions['tools'];\n generateId: () => string;\n}) {\n const toolNameMapping = createToolNameMapping({\n tools,\n providerToolNames: mistralProviderToolNames,\n });\n const sourceUrls = new Set<string>();\n\n return {\n toolNameMapping,\n convertChunk(\n chunk: z.infer<ReturnType<typeof mistralConversationContentSchema>>,\n ): Array<\n LanguageModelV4Text | LanguageModelV4Reasoning | LanguageModelV4Source\n > {\n switch (chunk.type) {\n case 'text':\n return chunk.text.length > 0\n ? [{ type: 'text', text: chunk.text }]\n : [];\n case 'thinking': {\n const text = chunk.thinking.map(part => part.text).join('');\n return text.length > 0 ? [{ type: 'reasoning', text }] : [];\n }\n case 'tool_reference':\n if (chunk.url == null || sourceUrls.has(chunk.url)) {\n return [];\n }\n const id = generateId();\n sourceUrls.add(chunk.url);\n return [\n {\n type: 'source',\n sourceType: 'url',\n id,\n url: chunk.url,\n title: chunk.title ?? chunk.url,\n },\n ];\n }\n },\n convertTool(\n output: z.infer<\n ReturnType<typeof mistralConversationToolExecutionSchema>\n >,\n ): [LanguageModelV4ToolCall, LanguageModelV4ToolResult] {\n const toolName = toolNameMapping.toCustomToolName(output.name);\n return [\n {\n type: 'tool-call',\n toolCallId: output.id,\n toolName,\n input: JSON.stringify({ arguments: output.arguments }),\n providerExecuted: true,\n providerMetadata: {\n mistral: {\n type: 'tool.execution',\n name: output.name,\n ...(output.function != null ? { function: output.function } : {}),\n },\n },\n },\n {\n type: 'tool-result',\n toolCallId: output.id,\n toolName,\n result: { ...(output.info != null ? { info: output.info } : {}) },\n },\n ];\n },\n };\n}\n\nconst mistralConversationContentSchema = () =>\n z.discriminatedUnion('type', [\n z.object({ type: z.literal('text'), text: z.string() }),\n z.object({\n type: z.literal('thinking'),\n thinking: z.array(\n z.object({ type: z.literal('text'), text: z.string() }),\n ),\n }),\n z.object({\n type: z.literal('tool_reference'),\n tool: z.string().nullish(),\n title: z.string().nullish(),\n url: z.string().nullish(),\n }),\n ]);\nconst mistralConversationMessageContentSchema = () =>\n z.union([z.string(), z.array(mistralConversationContentSchema())]);\nconst mistralConversationToolExecutionSchema = () =>\n z.object({\n type: z.literal('tool.execution'),\n id: z.string(),\n name: z.string(),\n arguments: z.string(),\n function: z.string().nullish(),\n info: z.record(z.string(), z.json()).nullish(),\n });\nconst mistralConversationFunctionCallSchema = () =>\n z.object({\n type: z.literal('function.call'),\n tool_call_id: z.string(),\n name: z.string(),\n arguments: z.union([z.string(), z.record(z.string(), z.json())]),\n });\nconst mistralConversationUsageSchema = () =>\n mistralUsageSchema.extend({\n prompt_tokens: z.number().default(0),\n completion_tokens: z.number().default(0),\n total_tokens: z.number().default(0),\n });\nconst mistralConversationResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n conversation_id: z.string(),\n outputs: z.array(\n z.discriminatedUnion('type', [\n mistralConversationToolExecutionSchema(),\n mistralConversationFunctionCallSchema(),\n z.object({\n type: z.literal('message.output'),\n content: mistralConversationMessageContentSchema(),\n model: z.string().nullish(),\n }),\n ]),\n ),\n usage: mistralConversationUsageSchema().nullish(),\n }),\n ),\n);\nconst mistralConversationChunkSchema = lazySchema(() =>\n zodSchema(\n z.discriminatedUnion('type', [\n z.object({\n type: z.literal('conversation.response.started'),\n conversation_id: z.string(),\n created_at: z.string().nullish(),\n }),\n z.object({\n type: z.literal('conversation.response.done'),\n usage: mistralConversationUsageSchema().nullish(),\n }),\n z.object({\n type: z.literal('conversation.response.error'),\n message: z.string(),\n code: z.number(),\n }),\n z.object({\n type: z.literal('message.output.delta'),\n id: z.string(),\n content_index: z.number().nullish(),\n content: z.union([z.string(), mistralConversationContentSchema()]),\n model: z.string().nullish(),\n }),\n z.object({\n type: z.literal('function.call.delta'),\n tool_call_id: z.string(),\n name: z.string(),\n arguments: z.string(),\n output_index: z.number().nullish(),\n }),\n z.object({\n type: z.enum(['tool.execution.started', 'tool.execution.delta']),\n id: z.string(),\n name: z.string(),\n arguments: z.string(),\n function: z.string().nullish(),\n }),\n z.object({\n type: z.literal('tool.execution.done'),\n id: z.string(),\n name: z.string(),\n function: z.string().nullish(),\n info: z.record(z.string(), z.json()).nullish(),\n }),\n ]),\n ),\n);\n","import { z } from 'zod/v4';\n\nexport type MistralEmbeddingModelId =\n | 'mistral-embed'\n | 'mistral-embed-2312'\n | 'codestral-embed'\n | 'codestral-embed-2505'\n | (string & {});\n\nexport const mistralEmbeddingModelOptions = z.object({\n /**\n * Additional metadata to attach to the embedding request.\n */\n metadata: z.record(z.string(), z.any()).optional(),\n\n /**\n * The dimension of the output embeddings when supported by the model.\n */\n outputDimension: z.number().int().positive().optional(),\n\n /**\n * The data type of the output embeddings when supported by the model.\n */\n outputDtype: z\n .enum(['float', 'int8', 'uint8', 'binary', 'ubinary'])\n .optional(),\n});\n\nexport type MistralEmbeddingModelOptions = z.infer<\n typeof mistralEmbeddingModelOptions\n>;\n","import {\n TooManyEmbeddingValuesForCallError,\n type EmbeddingModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postJsonToApi,\n serializeModelOptions,\n WORKFLOW_SERIALIZE,\n WORKFLOW_DESERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport {\n mistralEmbeddingModelOptions,\n type MistralEmbeddingModelId,\n} from './mistral-embedding-model-options';\nimport { mistralFailedResponseHandler } from './mistral-error';\n\ntype MistralEmbeddingConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n};\n\nexport class MistralEmbeddingModel implements EmbeddingModelV4 {\n readonly specificationVersion = 'v4';\n readonly modelId: MistralEmbeddingModelId;\n readonly maxEmbeddingsPerCall = 32;\n readonly supportsParallelCalls = false;\n\n private readonly config: MistralEmbeddingConfig;\n\n get provider(): string {\n return this.config.provider;\n }\n\n static [WORKFLOW_SERIALIZE](model: MistralEmbeddingModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralEmbeddingModelId;\n config: MistralEmbeddingConfig;\n }) {\n return new MistralEmbeddingModel(options.modelId, options.config);\n }\n\n constructor(\n modelId: MistralEmbeddingModelId,\n config: MistralEmbeddingConfig,\n ) {\n this.modelId = modelId;\n this.config = config;\n }\n\n async doEmbed({\n values,\n dimensions,\n abortSignal,\n headers,\n providerOptions,\n }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<\n Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>\n > {\n if (values.length > this.maxEmbeddingsPerCall) {\n throw new TooManyEmbeddingValuesForCallError({\n provider: this.provider,\n modelId: this.modelId,\n maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,\n values,\n });\n }\n\n const mistralOptions =\n (await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralEmbeddingModelOptions,\n })) ?? {};\n\n const {\n responseHeaders,\n value: response,\n rawValue,\n } = await postJsonToApi({\n url: `${this.config.baseURL}/embeddings`,\n headers: combineHeaders(this.config.headers?.(), headers),\n body: {\n model: this.modelId,\n input: values,\n metadata: mistralOptions.metadata,\n output_dimension: mistralOptions.outputDimension ?? dimensions,\n output_dtype: mistralOptions.outputDtype,\n encoding_format: 'float',\n },\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n MistralTextEmbeddingResponseSchema,\n ),\n abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n warnings: [],\n embeddings: response.data.map(item => item.embedding),\n usage: response.usage\n ? { tokens: response.usage.prompt_tokens }\n : undefined,\n response: { headers: responseHeaders, body: rawValue },\n };\n }\n}\n\n// minimal version of the schema, focussed on what is needed for the implementation\n// this approach limits breakages when the API changes and increases efficiency\nconst MistralTextEmbeddingResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n data: z.array(z.object({ embedding: z.array(z.number()) })),\n usage: z.object({ prompt_tokens: z.number() }).nullish(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type MistralSpeechModelId =\n | 'voxtral-mini-tts-2603'\n | 'voxtral-mini-tts-3-0'\n | 'voxtral-mini-tts-3'\n | 'voxtral-mini-tts-latest'\n | (string & {});\n\nexport const mistralSpeechModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * Base64-encoded reference audio for one-off voice cloning.\n *\n * When provided, this takes precedence over the standard `voice` option.\n */\n refAudio: z.string().min(1).optional(),\n\n /**\n * How expressive the speech is, from 1 to 5. Higher values trade voice\n * similarity and stability for stronger delivery. Supported by Voxtral 3.\n */\n expressiveness: z.number().min(1).max(5).optional(),\n\n /**\n * Pronunciation hints mapping words to lists of IPA phonemes.\n * Supported by Voxtral 3.\n */\n phonemeHints: z\n .record(z.string().min(1), z.array(z.string().min(1)).min(1))\n .optional(),\n }),\n ),\n);\n\nexport type MistralSpeechModelOptions = InferSchema<\n typeof mistralSpeechModelOptions\n>;\n","import type { SharedV4Warning, SpeechModelV4 } from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n createJsonResponseHandler,\n parseProviderOptions,\n postToApi,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralSpeechModelOptions,\n type MistralSpeechModelId,\n} from './mistral-speech-model-options';\n\ninterface MistralSpeechModelConfig {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n}\n\ntype MistralSpeechOutputFormat = 'pcm' | 'wav' | 'mp3' | 'flac' | 'opus';\n\nexport class MistralSpeechModel implements SpeechModelV4 {\n readonly specificationVersion = 'v4';\n\n static [WORKFLOW_SERIALIZE](model: MistralSpeechModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralSpeechModelId;\n config: MistralSpeechModelConfig;\n }) {\n return new MistralSpeechModel(options.modelId, options.config);\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MistralSpeechModelId,\n private readonly config: MistralSpeechModelConfig,\n ) {}\n\n private async getArgs({\n text,\n voice,\n outputFormat = 'mp3',\n instructions,\n speed,\n language,\n providerOptions,\n }: Parameters<SpeechModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n const mistralOptions = await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralSpeechModelOptions,\n });\n\n let responseFormat: MistralSpeechOutputFormat = 'mp3';\n if (['pcm', 'wav', 'mp3', 'flac', 'opus'].includes(outputFormat)) {\n responseFormat = outputFormat as MistralSpeechOutputFormat;\n } else {\n warnings.push({\n type: 'unsupported',\n feature: 'outputFormat',\n details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`,\n });\n }\n\n if (instructions != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'instructions',\n details:\n 'Mistral speech models do not support the `instructions` option. ' +\n 'Use a reference audio clip to guide delivery.',\n });\n }\n\n if (speed != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'speed',\n details:\n 'Mistral speech models do not support the `speed` option. It was ignored.',\n });\n }\n\n if (language != null) {\n warnings.push({\n type: 'unsupported',\n feature: 'language',\n details:\n 'Mistral speech models do not support the `language` option. ' +\n 'Language is inferred from the input text and voice.',\n });\n }\n\n const refAudio = mistralOptions?.refAudio;\n const requestBody = {\n model: this.modelId,\n input: text,\n voice_id: refAudio == null ? voice : undefined,\n ref_audio: refAudio,\n expressiveness: mistralOptions?.expressiveness,\n phoneme_hints: mistralOptions?.phonemeHints,\n response_format: responseFormat,\n stream: false,\n };\n\n const requestBodyValues = {\n ...requestBody,\n ref_audio: refAudio == null ? undefined : '[redacted]',\n };\n\n return { requestBody, requestBodyValues, warnings };\n }\n\n async doGenerate(\n options: Parameters<SpeechModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<SpeechModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { requestBody, requestBodyValues, warnings } =\n await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postToApi({\n url: `${this.config.baseURL}/audio/speech`,\n headers: combineHeaders(\n { 'Content-Type': 'application/json' },\n this.config.headers?.(),\n options.headers,\n ),\n body: {\n content: JSON.stringify(requestBody),\n values: requestBodyValues,\n },\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralSpeechResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n return {\n audio: response.audio_data,\n warnings,\n request: {\n body: JSON.stringify(requestBodyValues),\n },\n response: {\n timestamp: currentDate,\n modelId: this.modelId,\n headers: responseHeaders,\n body: rawResponse,\n },\n };\n }\n}\n\nconst mistralSpeechResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n audio_data: z.string(),\n }),\n ),\n);\n","import {\n lazySchema,\n zodSchema,\n type InferSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nexport type MistralTranscriptionModelId =\n | 'voxtral-mini-2602'\n | 'voxtral-mini-latest'\n | 'voxtral-mini-transcribe-3-0'\n | 'voxtral-mini-transcribe-3'\n | 'voxtral-mini-transcribe-latest'\n | 'voxtral-small-transcribe-3-0'\n | 'voxtral-small-transcribe-3'\n | 'voxtral-small-transcribe-latest'\n | (string & {});\n\n// https://docs.mistral.ai/api/endpoint/audio/transcriptions\nexport const mistralTranscriptionModelOptions = lazySchema(() =>\n zodSchema(\n z.object({\n /**\n * The language of the audio, e.g. \"en\". Providing the language can boost\n * accuracy.\n */\n language: z.string().min(1).optional(),\n\n /**\n * Return the detected language. Cannot be combined with `language`.\n */\n returnLanguage: z.boolean().optional(),\n\n /**\n * The sampling temperature.\n */\n temperature: z.number().optional(),\n\n /**\n * The timestamp granularities to include in the transcription response.\n * Voxtral 3 supports segment timestamps only.\n */\n timestampGranularities: z\n .array(z.enum(['segment', 'word']))\n .min(1)\n .optional(),\n\n /**\n * Whether to identify speakers in the transcription.\n * Voxtral 3 requires segment timestamps when diarization is enabled.\n */\n diarize: z.boolean().optional(),\n\n /**\n * Words or phrases to guide the model toward correct spellings of names,\n * technical terms, or domain-specific vocabulary.\n *\n * Voxtral 3 also accepts phrases and descriptions of the recording,\n * including spaces and punctuation. Entries share the context window\n * with the audio.\n */\n contextBias: z.array(z.string().min(1)).optional(),\n }),\n ),\n);\n\nexport type MistralTranscriptionModelOptions = InferSchema<\n typeof mistralTranscriptionModelOptions\n>;\n","import {\n InvalidArgumentError,\n type JSONObject,\n type SharedV4Warning,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n lazySchema,\n zodSchema,\n combineHeaders,\n convertBase64ToUint8Array,\n createJsonResponseHandler,\n mediaTypeToExtension,\n parseProviderOptions,\n postFormDataToApi,\n serializeModelOptions,\n WORKFLOW_DESERIALIZE,\n WORKFLOW_SERIALIZE,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\nimport { mistralFailedResponseHandler } from './mistral-error';\nimport {\n mistralTranscriptionModelOptions,\n type MistralTranscriptionModelId,\n} from './mistral-transcription-model-options';\n\ntype MistralTranscriptionModelConfig = {\n provider: string;\n baseURL: string;\n headers?: () => Record<string, string | undefined>;\n fetch?: FetchFunction;\n _internal?: {\n currentDate?: () => Date;\n };\n};\n\nexport class MistralTranscriptionModel implements TranscriptionModelV4 {\n readonly specificationVersion = 'v4';\n\n static [WORKFLOW_SERIALIZE](model: MistralTranscriptionModel) {\n return serializeModelOptions({\n modelId: model.modelId,\n config: model.config,\n });\n }\n\n static [WORKFLOW_DESERIALIZE](options: {\n modelId: MistralTranscriptionModelId;\n config: MistralTranscriptionModelConfig;\n }) {\n return new MistralTranscriptionModel(options.modelId, options.config);\n }\n\n get provider(): string {\n return this.config.provider;\n }\n\n constructor(\n readonly modelId: MistralTranscriptionModelId,\n private readonly config: MistralTranscriptionModelConfig,\n ) {}\n\n private async getArgs({\n audio,\n mediaType,\n providerOptions,\n }: Parameters<TranscriptionModelV4['doGenerate']>[0]) {\n const warnings: SharedV4Warning[] = [];\n const mistralOptions = await parseProviderOptions({\n provider: 'mistral',\n providerOptions,\n schema: mistralTranscriptionModelOptions,\n });\n\n // Restrict only known legacy models so future and custom models can combine\n // a pinned language with timestamps without an SDK update.\n if (\n [\n 'voxtral-mini-2507',\n 'voxtral-mini-2602',\n 'voxtral-mini-latest',\n ].includes(this.modelId) &&\n mistralOptions?.language != null &&\n mistralOptions.timestampGranularities != null\n ) {\n throw new InvalidArgumentError({\n argument: 'providerOptions',\n message:\n 'providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities',\n });\n }\n\n if (mistralOptions?.language != null && mistralOptions.returnLanguage) {\n throw new InvalidArgumentError({\n argument: 'providerOptions',\n message:\n 'providerOptions.mistral.language cannot be combined with providerOptions.mistral.returnLanguage',\n });\n }\n\n const formData = new FormData();\n const blob =\n audio instanceof Uint8Array\n ? new Blob([audio as Uint8Array<ArrayBuffer>])\n : new Blob([convertBase64ToUint8Array(audio)]);\n\n formData.append('model', this.modelId);\n formData.append(\n 'file',\n new File([blob], 'audio', { type: mediaType }),\n `audio.${mediaTypeToExtension(mediaType)}`,\n );\n\n if (mistralOptions != null) {\n appendFormValue(formData, 'language', mistralOptions.language);\n appendFormValue(\n formData,\n 'return_language',\n mistralOptions.returnLanguage,\n );\n appendFormValue(formData, 'temperature', mistralOptions.temperature);\n appendFormValue(\n formData,\n 'timestamp_granularities',\n mistralOptions.timestampGranularities,\n );\n appendFormValue(formData, 'diarize', mistralOptions.diarize);\n appendFormValue(formData, 'context_bias', mistralOptions.contextBias);\n }\n\n return { formData, warnings };\n }\n\n async doGenerate(\n options: Parameters<TranscriptionModelV4['doGenerate']>[0],\n ): Promise<Awaited<ReturnType<TranscriptionModelV4['doGenerate']>>> {\n const currentDate = this.config._internal?.currentDate?.() ?? new Date();\n const { formData, warnings } = await this.getArgs(options);\n\n const {\n value: response,\n responseHeaders,\n rawValue: rawResponse,\n } = await postFormDataToApi({\n url: `${this.config.baseURL}/audio/transcriptions`,\n headers: combineHeaders(this.config.headers?.(), options.headers),\n formData,\n failedResponseHandler: mistralFailedResponseHandler,\n successfulResponseHandler: createJsonResponseHandler(\n mistralTranscriptionResponseSchema,\n ),\n abortSignal: options.abortSignal,\n fetch: this.config.fetch,\n });\n\n const segments =\n response.segments?.map(segment => ({\n text: segment.text,\n startSecond: segment.start,\n endSecond: segment.end,\n })) ?? [];\n\n const mistralMetadata: JSONObject = {};\n\n if (response.usage != null) {\n mistralMetadata.usage = {\n ...(response.usage.prompt_tokens != null && {\n promptTokens: response.usage.prompt_tokens,\n }),\n ...(response.usage.completion_tokens != null && {\n completionTokens: response.usage.completion_tokens,\n }),\n ...(response.usage.total_tokens != null && {\n totalTokens: response.usage.total_tokens,\n }),\n ...(response.usage.prompt_audio_seconds != null && {\n promptAudioSeconds: response.usage.prompt_audio_seconds,\n }),\n ...(response.usage.request_count != null && {\n requestCount: response.usage.request_count,\n }),\n };\n }\n\n const providerSegments = response.segments\n ?.filter(\n segment =>\n segment.type != null ||\n segment.score != null ||\n segment.speaker_id != null,\n )\n .map(segment => ({\n text: segment.text,\n startSecond: segment.start,\n endSecond: segment.end,\n ...(segment.type != null && { type: segment.type }),\n ...(segment.score != null && { score: segment.score }),\n ...(segment.speaker_id != null && {\n speakerId: segment.speaker_id,\n }),\n }));\n\n if (providerSegments != null && providerSegments.length > 0) {\n mistralMetadata.segments = providerSegments;\n }\n\n return {\n text: response.text,\n segments,\n language: response.language ?? undefined,\n durationInSeconds:\n response.usage?.prompt_audio_seconds ??\n segments.at(-1)?.endSecond ??\n undefined,\n warnings,\n ...(response.usage != null && { usage: response.usage }),\n response: {\n timestamp: currentDate,\n modelId: response.model,\n headers: responseHeaders,\n body: rawResponse,\n },\n ...(Object.keys(mistralMetadata).length > 0 && {\n providerMetadata: {\n mistral: mistralMetadata,\n },\n }),\n };\n }\n}\n\nfunction appendFormValue(\n formData: FormData,\n key: string,\n value: string | number | boolean | string[] | undefined,\n): void {\n if (value == null) {\n return;\n }\n\n if (Array.isArray(value)) {\n for (const item of value) {\n formData.append(key, item);\n }\n return;\n }\n\n formData.append(key, String(value));\n}\n\nconst mistralTranscriptionResponseSchema = lazySchema(() =>\n zodSchema(\n z.object({\n model: z.string(),\n text: z.string(),\n language: z.string().nullish(),\n segments: z\n .array(\n z.object({\n type: z.literal('transcription_segment').nullish(),\n text: z.string(),\n start: z.number(),\n end: z.number(),\n score: z.number().nullish(),\n speaker_id: z.string().nullish(),\n }),\n )\n .nullish(),\n usage: z\n .object({\n prompt_tokens: z.number().nullish(),\n completion_tokens: z.number().nullish(),\n total_tokens: z.number().nullish(),\n prompt_audio_seconds: z.number().nullish(),\n request_count: z.number().nullish(),\n })\n .nullish(),\n }),\n ),\n);\n","// Version string of this package injected at build time.\ndeclare const __PACKAGE_VERSION__: string | undefined;\nexport const VERSION: string =\n typeof __PACKAGE_VERSION__ !== 'undefined'\n ? __PACKAGE_VERSION__\n : '0.0.0-test';\n","import type { JSONValue } from '@ai-sdk/provider';\nimport {\n createProviderExecutedToolFactory,\n lazySchema,\n zodSchema,\n} from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst inputSchema = lazySchema(() =>\n zodSchema(z.object({ arguments: z.string() })),\n);\nconst outputSchema = lazySchema(() =>\n zodSchema(z.object({ info: z.record(z.string(), z.json()).optional() })),\n);\n\nconst webSearchFactory = createProviderExecutedToolFactory<\n { arguments: string },\n { info?: Record<string, JSONValue> },\n {}\n>({ id: 'mistral.web_search', inputSchema, outputSchema });\n\nconst webSearchPremiumFactory = createProviderExecutedToolFactory<\n { arguments: string },\n { info?: Record<string, JSONValue> },\n {}\n>({ id: 'mistral.web_search_premium', inputSchema, outputSchema });\n\n/** Search the web using Mistral's Conversations API. */\nexport const webSearch = (args: Parameters<typeof webSearchFactory>[0] = {}) =>\n webSearchFactory(args);\n\n/** Search the web and verified news using Mistral's Conversations API. */\nexport const webSearchPremium = (\n args: Parameters<typeof webSearchPremiumFactory>[0] = {},\n) => webSearchPremiumFactory(args);\n","import { webSearch, webSearchPremium } from './web-search';\n\nexport const mistralTools = { webSearch, webSearchPremium };\n","import {\n NoSuchModelError,\n type EmbeddingModelV4,\n type LanguageModelV4,\n type ProviderV4,\n type SpeechModelV4,\n type TranscriptionModelV4,\n} from '@ai-sdk/provider';\nimport {\n loadApiKey,\n withoutTrailingSlash,\n withUserAgentSuffix,\n type FetchFunction,\n} from '@ai-sdk/provider-utils';\nimport { MistralChatLanguageModel } from './mistral-chat-language-model';\nimport { MistralConversationLanguageModel } from './mistral-conversation-language-model';\nimport type { MistralChatModelId } from './mistral-chat-language-model-options';\nimport { MistralEmbeddingModel } from './mistral-embedding-model';\nimport type { MistralEmbeddingModelId } from './mistral-embedding-model-options';\nimport { MistralSpeechModel } from './mistral-speech-model';\nimport type { MistralSpeechModelId } from './mistral-speech-model-options';\nimport { MistralTranscriptionModel } from './mistral-transcription-model';\nimport type { MistralTranscriptionModelId } from './mistral-transcription-model-options';\nimport { VERSION } from './version';\nimport { mistralTools } from './tool';\n\nexport interface MistralProvider extends ProviderV4 {\n tools: typeof mistralTools;\n (modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n languageModel(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text generation.\n */\n chat(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model using the Conversations API, with support for web search.\n */\n conversation(modelId: MistralChatModelId): LanguageModelV4;\n\n /**\n * Creates a model for text embeddings.\n */\n embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * Creates a model for text embeddings.\n */\n embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV4;\n\n /**\n * Creates a model for speech generation (text-to-speech).\n */\n speech(modelId: MistralSpeechModelId): SpeechModelV4;\n\n /**\n * Creates a model for speech generation (text-to-speech).\n */\n speechModel(modelId: MistralSpeechModelId): SpeechModelV4;\n\n /**\n * Creates a model for audio transcription.\n */\n transcription(modelId: MistralTranscriptionModelId): TranscriptionModelV4;\n\n /**\n * Creates a model for audio transcription.\n */\n transcriptionModel(\n modelId: MistralTranscriptionModelId,\n ): TranscriptionModelV4;\n\n /**\n * @deprecated Use `embedding` instead.\n */\n textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n\n /**\n * @deprecated Use `embeddingModel` instead.\n */\n textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV4;\n}\n\nexport interface MistralProviderSettings {\n /**\n * Use a different URL prefix for API calls, e.g. to use proxy servers.\n * The default prefix is `https://api.mistral.ai/v1`.\n */\n baseURL?: string;\n\n /**\n * API key that is being send using the `Authorization` header.\n * It defaults to the `MISTRAL_API_KEY` environment variable.\n */\n apiKey?: string;\n\n /**\n * Custom headers to include in the requests.\n */\n headers?: Record<string, string>;\n\n /**\n * Custom fetch implementation. You can use it as a middleware to intercept requests,\n * or to provide a custom fetch implementation for e.g. testing.\n */\n fetch?: FetchFunction;\n\n generateId?: () => string;\n}\n\n/**\n * Create a Mistral AI provider instance.\n */\nexport function createMistral(\n options: MistralProviderSettings = {},\n): MistralProvider {\n const baseURL =\n withoutTrailingSlash(options.baseURL) ?? 'https://api.mistral.ai/v1';\n\n const getHeaders = () =>\n withUserAgentSuffix(\n {\n Authorization: `Bearer ${loadApiKey({\n apiKey: options.apiKey,\n environmentVariableName: 'MISTRAL_API_KEY',\n description: 'Mistral',\n })}`,\n ...options.headers,\n },\n `ai-sdk-mistral/${VERSION}`,\n );\n\n const createChatModel = (modelId: MistralChatModelId) =>\n new MistralChatLanguageModel(modelId, {\n provider: 'mistral.chat',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId: options.generateId,\n });\n\n const createEmbeddingModel = (modelId: MistralEmbeddingModelId) =>\n new MistralEmbeddingModel(modelId, {\n provider: 'mistral.embedding',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createConversationModel = (modelId: MistralChatModelId) =>\n new MistralConversationLanguageModel(modelId, {\n provider: 'mistral.conversation',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n generateId: options.generateId,\n });\n\n const createSpeechModel = (modelId: MistralSpeechModelId) =>\n new MistralSpeechModel(modelId, {\n provider: 'mistral.speech',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const createTranscriptionModel = (modelId: MistralTranscriptionModelId) =>\n new MistralTranscriptionModel(modelId, {\n provider: 'mistral.transcription',\n baseURL,\n headers: getHeaders,\n fetch: options.fetch,\n });\n\n const provider = function (modelId: MistralChatModelId) {\n if (new.target) {\n throw new Error(\n 'The Mistral model function cannot be called with the new keyword.',\n );\n }\n\n return createChatModel(modelId);\n };\n\n provider.specificationVersion = 'v4' as const;\n provider.languageModel = createChatModel;\n provider.chat = createChatModel;\n provider.conversation = createConversationModel;\n provider.tools = mistralTools;\n provider.embedding = createEmbeddingModel;\n provider.embeddingModel = createEmbeddingModel;\n provider.textEmbedding = createEmbeddingModel;\n provider.textEmbeddingModel = createEmbeddingModel;\n provider.speech = createSpeechModel;\n provider.speechModel = createSpeechModel;\n provider.transcription = createTranscriptionModel;\n provider.transcriptionModel = createTranscriptionModel;\n\n provider.imageModel = (modelId: string) => {\n throw new NoSuchModelError({ modelId, modelType: 'imageModel' });\n };\n\n return provider;\n}\n\n/**\n * Default Mistral provider instance.\n */\nexport const mistral = createMistral();\n"],"mappings":";;;;AAIA,MAAM,mCAAmC,EACtC,OAAO;CACN,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC,CAAC,QAAQ;CACpC,eAAe,EAAE,OAAO,CAAC,CAAC,QAAQ;CAClC,cAAc,EAAE,OAAO,CAAC,CAAC,QAAQ;AACnC,CAAC,CAAC,CACD,SAAS,EAAE,KAAK,CAAC;AAEpB,MAAM,uCAAuC,EAC1C,OAAO,EACN,kBAAkB,EAAE,OAAO,CAAC,CAAC,QAAQ,EACvC,CAAC,CAAC,CACD,SAAS,EAAE,KAAK,CAAC;AAEpB,MAAa,qBAAqB,EAC/B,OAAO;CACN,eAAe,EAAE,OAAO;CACxB,mB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AM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CACjE;CAEA,OAAO;AACT;;;;AAKA,MAAa,UAAU,cAAc"}
|
package/docs/20-mistral.mdx
CHANGED
|
@@ -496,7 +496,7 @@ You can create models that call the
|
|
|
496
496
|
using the `.transcription()` factory method:
|
|
497
497
|
|
|
498
498
|
```ts
|
|
499
|
-
const model = mistral.transcription('voxtral-mini-
|
|
499
|
+
const model = mistral.transcription('voxtral-mini-transcribe-3-0');
|
|
500
500
|
```
|
|
501
501
|
|
|
502
502
|
Use Mistral transcription models with [`transcribe`](/docs/reference/ai-sdk-core/transcribe):
|
|
@@ -507,7 +507,7 @@ import { transcribe } from 'ai';
|
|
|
507
507
|
import { readFile } from 'node:fs/promises';
|
|
508
508
|
|
|
509
509
|
const result = await transcribe({
|
|
510
|
-
model: mistral.transcription('voxtral-mini-
|
|
510
|
+
model: mistral.transcription('voxtral-mini-transcribe-3-0'),
|
|
511
511
|
audio: await readFile('audio.mp3'),
|
|
512
512
|
});
|
|
513
513
|
```
|
|
@@ -525,13 +525,14 @@ import { transcribe } from 'ai';
|
|
|
525
525
|
import { readFile } from 'node:fs/promises';
|
|
526
526
|
|
|
527
527
|
const result = await transcribe({
|
|
528
|
-
model: mistral.transcription('voxtral-mini-
|
|
528
|
+
model: mistral.transcription('voxtral-mini-transcribe-3-0'),
|
|
529
529
|
audio: await readFile('audio.mp3'),
|
|
530
530
|
providerOptions: {
|
|
531
531
|
mistral: {
|
|
532
532
|
timestampGranularities: ['segment'],
|
|
533
533
|
diarize: true,
|
|
534
|
-
|
|
534
|
+
returnLanguage: true,
|
|
535
|
+
contextBias: ['Vercel', 'AI SDK', 'A discussion about TypeScript.'],
|
|
535
536
|
} satisfies MistralTranscriptionModelOptions,
|
|
536
537
|
},
|
|
537
538
|
});
|
|
@@ -543,25 +544,36 @@ The following optional provider options are available:
|
|
|
543
544
|
|
|
544
545
|
The language of the audio, such as `en`. Providing it can improve accuracy.
|
|
545
546
|
|
|
547
|
+
- **returnLanguage** _boolean_
|
|
548
|
+
|
|
549
|
+
Return the detected language with Voxtral 3. Without this option, the response
|
|
550
|
+
language is normally absent. Cannot be `true` when `language` is provided.
|
|
551
|
+
|
|
546
552
|
- **temperature** _number_
|
|
547
553
|
|
|
548
554
|
The sampling temperature for the transcription.
|
|
549
555
|
|
|
550
556
|
- **timestampGranularities** _Array<'segment' | 'word'>_
|
|
551
557
|
|
|
552
|
-
Timestamp granularities to include in the response.
|
|
553
|
-
|
|
554
|
-
|
|
558
|
+
Timestamp granularities to include in the response. Voxtral 3 supports only
|
|
559
|
+
`segment` and allows it to be combined with `language`. The SDK rejects this
|
|
560
|
+
combination for the legacy IDs `voxtral-mini-2507`, `voxtral-mini-2602`, and
|
|
561
|
+
`voxtral-mini-latest`, throwing an `InvalidArgumentError`. Other model IDs are
|
|
562
|
+
allowed to send the combination to Mistral. Model-specific timestamp and
|
|
563
|
+
diarization requirements are validated by the Mistral API.
|
|
555
564
|
|
|
556
565
|
- **diarize** _boolean_
|
|
557
566
|
|
|
558
|
-
Whether to identify speakers in the transcription.
|
|
567
|
+
Whether to identify speakers in the transcription. Voxtral 3 requires
|
|
568
|
+
`timestampGranularities: ['segment']` when this option is `true`.
|
|
559
569
|
|
|
560
570
|
- **contextBias** _string[]_
|
|
561
571
|
|
|
562
|
-
|
|
563
|
-
or domain-specific vocabulary.
|
|
564
|
-
|
|
572
|
+
Words, phrases, or descriptions of the recording that guide spelling for
|
|
573
|
+
names, technical terms, or domain-specific vocabulary. Voxtral 3 accepts spaces
|
|
574
|
+
and punctuation and has no fixed entry limit; entries share the context window
|
|
575
|
+
with the audio. Earlier models require entries without commas or whitespace
|
|
576
|
+
and support up to 100 entries.
|
|
565
577
|
|
|
566
578
|
The normalized result includes transcript text, language, timed segments, and
|
|
567
579
|
duration when returned by Mistral. Mistral token and prompt-audio usage is
|
|
@@ -577,9 +589,11 @@ speaker IDs from diarization are available under
|
|
|
577
589
|
|
|
578
590
|
### Model Capabilities
|
|
579
591
|
|
|
580
|
-
| Model
|
|
581
|
-
|
|
|
582
|
-
| `voxtral-mini-
|
|
592
|
+
| Model | Timestamps | Diarization | Context Bias |
|
|
593
|
+
| ------------------------------ | ---------- | ----------- | ------------ |
|
|
594
|
+
| `voxtral-mini-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
|
|
595
|
+
| `voxtral-small-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
|
|
596
|
+
| `voxtral-mini-latest` | <Check /> | <Check /> | <Check /> |
|
|
583
597
|
|
|
584
598
|
## Speech Models
|
|
585
599
|
|
|
@@ -588,7 +602,7 @@ You can create models that call the
|
|
|
588
602
|
the `.speech()` factory method:
|
|
589
603
|
|
|
590
604
|
```ts
|
|
591
|
-
const model = mistral.speech('voxtral-mini-tts-
|
|
605
|
+
const model = mistral.speech('voxtral-mini-tts-3-0');
|
|
592
606
|
```
|
|
593
607
|
|
|
594
608
|
Use a preset or saved voice ID with [`generateSpeech`](/docs/reference/ai-sdk-core/generate-speech):
|
|
@@ -598,9 +612,9 @@ import { mistral } from '@ai-sdk/mistral';
|
|
|
598
612
|
import { generateSpeech } from 'ai';
|
|
599
613
|
|
|
600
614
|
const result = await generateSpeech({
|
|
601
|
-
model: mistral.speech('voxtral-mini-tts-
|
|
615
|
+
model: mistral.speech('voxtral-mini-tts-3-0'),
|
|
602
616
|
text: 'Hello from the AI SDK!',
|
|
603
|
-
voice: '
|
|
617
|
+
voice: 'gb_jane_neutral',
|
|
604
618
|
outputFormat: 'mp3',
|
|
605
619
|
});
|
|
606
620
|
|
|
@@ -610,7 +624,38 @@ const audio = result.audio.uint8Array;
|
|
|
610
624
|
The Mistral speech model maps `voice` to Mistral's `voice_id`. It supports
|
|
611
625
|
`mp3`, `wav`, `pcm`, `flac`, and `opus` output formats and defaults to `mp3`.
|
|
612
626
|
The `instructions`, `speed`, and `language` settings are not supported and
|
|
613
|
-
produce warnings when provided.
|
|
627
|
+
produce warnings when provided. Voxtral 3 style instructions are not available
|
|
628
|
+
at launch. To control emotion and pace, include tags such as `[emotion=happy]`
|
|
629
|
+
and `[pace=slow]` directly in `text`.
|
|
630
|
+
|
|
631
|
+
Voxtral 3 supports additional delivery controls through `providerOptions.mistral`:
|
|
632
|
+
|
|
633
|
+
- **expressiveness** _number_
|
|
634
|
+
|
|
635
|
+
A value from 1 to 5 controlling expressiveness. Higher values trade voice
|
|
636
|
+
similarity and stability for stronger delivery. Omit it to use the service default.
|
|
637
|
+
|
|
638
|
+
- **phonemeHints** _Record<string, string[]>_
|
|
639
|
+
|
|
640
|
+
Map words in the input to lists of IPA phonemes. Mistral validates the supported
|
|
641
|
+
phoneme inventory. See [custom pronunciation](https://docs.mistral.ai/studio/audio/text-to-speech/custom-pronunciation).
|
|
642
|
+
|
|
643
|
+
```ts
|
|
644
|
+
import { mistral, type MistralSpeechModelOptions } from '@ai-sdk/mistral';
|
|
645
|
+
import { generateSpeech } from 'ai';
|
|
646
|
+
|
|
647
|
+
const result = await generateSpeech({
|
|
648
|
+
model: mistral.speech('voxtral-mini-tts-3-0'),
|
|
649
|
+
text: '[emotion=happy] I like tomato soup.',
|
|
650
|
+
voice: 'gb_jane_neutral',
|
|
651
|
+
providerOptions: {
|
|
652
|
+
mistral: {
|
|
653
|
+
expressiveness: 1.5,
|
|
654
|
+
phonemeHints: { tomato: ['t', 'ə', 'm', 'ɑ', 't', 'oʊ'] },
|
|
655
|
+
} satisfies MistralSpeechModelOptions,
|
|
656
|
+
},
|
|
657
|
+
});
|
|
658
|
+
```
|
|
614
659
|
|
|
615
660
|
Mistral also supports one-off voice cloning with base64-encoded reference
|
|
616
661
|
audio. Pass it through `providerOptions.mistral.refAudio` and use
|
|
@@ -624,7 +669,7 @@ import { generateSpeech } from 'ai';
|
|
|
624
669
|
const referenceAudio = await readFile('./reference.mp3');
|
|
625
670
|
|
|
626
671
|
const result = await generateSpeech({
|
|
627
|
-
model: mistral.speech('voxtral-mini-tts-
|
|
672
|
+
model: mistral.speech('voxtral-mini-tts-3-0'),
|
|
628
673
|
text: 'Hello from the AI SDK!',
|
|
629
674
|
providerOptions: {
|
|
630
675
|
mistral: {
|
|
@@ -648,6 +693,7 @@ is redacted from request metadata and API call errors returned by the provider.
|
|
|
648
693
|
|
|
649
694
|
| Model | Saved Voices | Reference Audio | Non-Streaming |
|
|
650
695
|
| ----------------------- | ------------ | --------------- | ------------- |
|
|
696
|
+
| `voxtral-mini-tts-3-0` | <Check /> | <Check /> | <Check /> |
|
|
651
697
|
| `voxtral-mini-tts-2603` | <Check /> | <Check /> | <Check /> |
|
|
652
698
|
|
|
653
699
|
## Embedding Models
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mistral",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.70",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "4.0.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/provider": "4.0.32",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.66"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -352,8 +352,9 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
352
352
|
fetch: this.config.fetch,
|
|
353
353
|
});
|
|
354
354
|
|
|
355
|
+
// A clean end without the provider's completion signal is interrupted.
|
|
355
356
|
let finishReason: LanguageModelV4FinishReason = {
|
|
356
|
-
unified: '
|
|
357
|
+
unified: 'interrupted',
|
|
357
358
|
raw: undefined,
|
|
358
359
|
};
|
|
359
360
|
let usage: MistralUsage | undefined = undefined;
|
|
@@ -385,6 +386,7 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
385
386
|
}
|
|
386
387
|
|
|
387
388
|
if (!chunk.success) {
|
|
389
|
+
finishReason = { unified: 'error', raw: undefined };
|
|
388
390
|
controller.enqueue({ type: 'error', error: chunk.error });
|
|
389
391
|
return;
|
|
390
392
|
}
|
|
@@ -7,6 +7,8 @@ import { z } from 'zod/v4';
|
|
|
7
7
|
|
|
8
8
|
export type MistralSpeechModelId =
|
|
9
9
|
| 'voxtral-mini-tts-2603'
|
|
10
|
+
| 'voxtral-mini-tts-3-0'
|
|
11
|
+
| 'voxtral-mini-tts-3'
|
|
10
12
|
| 'voxtral-mini-tts-latest'
|
|
11
13
|
| (string & {});
|
|
12
14
|
|
|
@@ -19,6 +21,20 @@ export const mistralSpeechModelOptions = lazySchema(() =>
|
|
|
19
21
|
* When provided, this takes precedence over the standard `voice` option.
|
|
20
22
|
*/
|
|
21
23
|
refAudio: z.string().min(1).optional(),
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* How expressive the speech is, from 1 to 5. Higher values trade voice
|
|
27
|
+
* similarity and stability for stronger delivery. Supported by Voxtral 3.
|
|
28
|
+
*/
|
|
29
|
+
expressiveness: z.number().min(1).max(5).optional(),
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Pronunciation hints mapping words to lists of IPA phonemes.
|
|
33
|
+
* Supported by Voxtral 3.
|
|
34
|
+
*/
|
|
35
|
+
phonemeHints: z
|
|
36
|
+
.record(z.string().min(1), z.array(z.string().min(1)).min(1))
|
|
37
|
+
.optional(),
|
|
22
38
|
}),
|
|
23
39
|
),
|
|
24
40
|
);
|
|
@@ -118,6 +118,8 @@ export class MistralSpeechModel implements SpeechModelV4 {
|
|
|
118
118
|
input: text,
|
|
119
119
|
voice_id: refAudio == null ? voice : undefined,
|
|
120
120
|
ref_audio: refAudio,
|
|
121
|
+
expressiveness: mistralOptions?.expressiveness,
|
|
122
|
+
phoneme_hints: mistralOptions?.phonemeHints,
|
|
121
123
|
response_format: responseFormat,
|
|
122
124
|
stream: false,
|
|
123
125
|
};
|
|
@@ -8,6 +8,12 @@ import { z } from 'zod/v4';
|
|
|
8
8
|
export type MistralTranscriptionModelId =
|
|
9
9
|
| 'voxtral-mini-2602'
|
|
10
10
|
| 'voxtral-mini-latest'
|
|
11
|
+
| 'voxtral-mini-transcribe-3-0'
|
|
12
|
+
| 'voxtral-mini-transcribe-3'
|
|
13
|
+
| 'voxtral-mini-transcribe-latest'
|
|
14
|
+
| 'voxtral-small-transcribe-3-0'
|
|
15
|
+
| 'voxtral-small-transcribe-3'
|
|
16
|
+
| 'voxtral-small-transcribe-latest'
|
|
11
17
|
| (string & {});
|
|
12
18
|
|
|
13
19
|
// https://docs.mistral.ai/api/endpoint/audio/transcriptions
|
|
@@ -20,6 +26,11 @@ export const mistralTranscriptionModelOptions = lazySchema(() =>
|
|
|
20
26
|
*/
|
|
21
27
|
language: z.string().min(1).optional(),
|
|
22
28
|
|
|
29
|
+
/**
|
|
30
|
+
* Return the detected language. Cannot be combined with `language`.
|
|
31
|
+
*/
|
|
32
|
+
returnLanguage: z.boolean().optional(),
|
|
33
|
+
|
|
23
34
|
/**
|
|
24
35
|
* The sampling temperature.
|
|
25
36
|
*/
|
|
@@ -27,6 +38,7 @@ export const mistralTranscriptionModelOptions = lazySchema(() =>
|
|
|
27
38
|
|
|
28
39
|
/**
|
|
29
40
|
* The timestamp granularities to include in the transcription response.
|
|
41
|
+
* Voxtral 3 supports segment timestamps only.
|
|
30
42
|
*/
|
|
31
43
|
timestampGranularities: z
|
|
32
44
|
.array(z.enum(['segment', 'word']))
|
|
@@ -35,6 +47,7 @@ export const mistralTranscriptionModelOptions = lazySchema(() =>
|
|
|
35
47
|
|
|
36
48
|
/**
|
|
37
49
|
* Whether to identify speakers in the transcription.
|
|
50
|
+
* Voxtral 3 requires segment timestamps when diarization is enabled.
|
|
38
51
|
*/
|
|
39
52
|
diarize: z.boolean().optional(),
|
|
40
53
|
|
|
@@ -42,21 +55,11 @@ export const mistralTranscriptionModelOptions = lazySchema(() =>
|
|
|
42
55
|
* Words or phrases to guide the model toward correct spellings of names,
|
|
43
56
|
* technical terms, or domain-specific vocabulary.
|
|
44
57
|
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
58
|
+
* Voxtral 3 also accepts phrases and descriptions of the recording,
|
|
59
|
+
* including spaces and punctuation. Entries share the context window
|
|
60
|
+
* with the audio.
|
|
47
61
|
*/
|
|
48
|
-
contextBias: z
|
|
49
|
-
.array(
|
|
50
|
-
z
|
|
51
|
-
.string()
|
|
52
|
-
.min(1)
|
|
53
|
-
.regex(
|
|
54
|
-
/^[^\s,]+$/,
|
|
55
|
-
'Context bias items must not contain commas or whitespace.',
|
|
56
|
-
),
|
|
57
|
-
)
|
|
58
|
-
.max(100)
|
|
59
|
-
.optional(),
|
|
62
|
+
contextBias: z.array(z.string().min(1)).optional(),
|
|
60
63
|
}),
|
|
61
64
|
),
|
|
62
65
|
);
|
|
@@ -73,9 +73,14 @@ export class MistralTranscriptionModel implements TranscriptionModelV4 {
|
|
|
73
73
|
schema: mistralTranscriptionModelOptions,
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
//
|
|
77
|
-
//
|
|
76
|
+
// Restrict only known legacy models so future and custom models can combine
|
|
77
|
+
// a pinned language with timestamps without an SDK update.
|
|
78
78
|
if (
|
|
79
|
+
[
|
|
80
|
+
'voxtral-mini-2507',
|
|
81
|
+
'voxtral-mini-2602',
|
|
82
|
+
'voxtral-mini-latest',
|
|
83
|
+
].includes(this.modelId) &&
|
|
79
84
|
mistralOptions?.language != null &&
|
|
80
85
|
mistralOptions.timestampGranularities != null
|
|
81
86
|
) {
|
|
@@ -86,6 +91,14 @@ export class MistralTranscriptionModel implements TranscriptionModelV4 {
|
|
|
86
91
|
});
|
|
87
92
|
}
|
|
88
93
|
|
|
94
|
+
if (mistralOptions?.language != null && mistralOptions.returnLanguage) {
|
|
95
|
+
throw new InvalidArgumentError({
|
|
96
|
+
argument: 'providerOptions',
|
|
97
|
+
message:
|
|
98
|
+
'providerOptions.mistral.language cannot be combined with providerOptions.mistral.returnLanguage',
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
89
102
|
const formData = new FormData();
|
|
90
103
|
const blob =
|
|
91
104
|
audio instanceof Uint8Array
|
|
@@ -101,6 +114,11 @@ export class MistralTranscriptionModel implements TranscriptionModelV4 {
|
|
|
101
114
|
|
|
102
115
|
if (mistralOptions != null) {
|
|
103
116
|
appendFormValue(formData, 'language', mistralOptions.language);
|
|
117
|
+
appendFormValue(
|
|
118
|
+
formData,
|
|
119
|
+
'return_language',
|
|
120
|
+
mistralOptions.returnLanguage,
|
|
121
|
+
);
|
|
104
122
|
appendFormValue(formData, 'temperature', mistralOptions.temperature);
|
|
105
123
|
appendFormValue(
|
|
106
124
|
formData,
|