@ai-sdk/mistral 4.0.72 → 4.0.73
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 +8 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -15
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +2 -1
- package/package.json +2 -2
- package/src/mistral-chat-language-model-options.ts +8 -1
- package/src/mistral-chat-language-model.ts +47 -9
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { EmbeddingModelV4, LanguageModelV4, ProviderV4, SpeechModelV4, Transcrip
|
|
|
2
2
|
import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/mistral-chat-language-model-options.d.ts
|
|
5
|
-
type MistralChatModelId = 'codestral-2508' | 'codestral-latest' | 'glm-5-2' | 'labs-leanstral-1-5' | 'labs-leanstral-1-5-1' | 'magistral-medium-latest' | 'magistral-small-latest' | 'ministral-14b-2512' | 'ministral-14b-latest' | 'ministral-3b-2512' | 'ministral-3b-latest' | 'ministral-8b-2512' | 'ministral-8b-latest' | 'mistral-code-fim-latest' | 'mistral-code-latest' | 'mistral-large-4' | 'mistral-large-4-0' | 'mistral-large-latest' | 'mistral-large-2512' | 'mistral-medium' | 'mistral-medium-latest' | 'mistral-medium-2604' | 'mistral-medium-3' | 'mistral-medium-3-5' | 'mistral-medium-3.5' | 'mistral-small-2603' | 'mistral-small-latest' | 'mistral-vibe-cli-fast' | 'mistral-vibe-cli-latest' | 'mistral-vibe-cli-with-tools' | 'voxtral-small-2507' | 'voxtral-small-latest' | 'zai-glm-5-2' | (string & {});
|
|
5
|
+
type MistralChatModelId = 'codestral-2508' | 'codestral-latest' | 'glm-5-2' | 'labs-leanstral-1-5' | 'labs-leanstral-1-5-1' | 'magistral-medium-latest' | 'magistral-small-latest' | 'ministral-14b-2512' | 'ministral-14b-latest' | 'ministral-3b-2512' | 'ministral-3b-latest' | 'ministral-8b-2512' | 'ministral-8b-latest' | 'mistral-code-fim-latest' | 'mistral-code-latest' | 'mistral-large-4' | 'mistral-large-4-0' | 'mistral-large-latest' | 'mistral-large-2512' | 'mistral-medium' | 'mistral-medium-latest' | 'mistral-medium-2604' | 'mistral-medium-3' | 'mistral-medium-3-5' | 'mistral-medium-3.5' | 'mistral-small-2603' | 'mistral-small-latest' | 'mistral-vibe-cli-fast' | 'mistral-vibe-cli-latest' | 'mistral-vibe-cli-with-tools' | 'voxtral-small-2507' | 'voxtral-small-latest' | 'zai-glm-5' | 'zai-glm-5-2' | 'zai-glm-5-3' | 'zai-glm-5-3-flash' | 'zai-glm-latest' | (string & {});
|
|
6
6
|
declare const mistralLanguageModelChatOptions: () => z.ZodObject<{
|
|
7
7
|
safePrompt: z.ZodOptional<z.ZodBoolean>;
|
|
8
8
|
documentImageLimit: z.ZodOptional<z.ZodNumber>;
|
|
@@ -14,6 +14,8 @@ declare const mistralLanguageModelChatOptions: () => z.ZodObject<{
|
|
|
14
14
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
15
15
|
high: "high";
|
|
16
16
|
none: "none";
|
|
17
|
+
low: "low";
|
|
18
|
+
max: "max";
|
|
17
19
|
}>>;
|
|
18
20
|
}, z.core.$strip>;
|
|
19
21
|
type MistralLanguageModelChatOptions = z.infer<ReturnType<typeof mistralLanguageModelChatOptions>>;
|
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;
|
|
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;cAwCC,uCAA+B,EAAA;;;;;;;;;;;;;;GAkDxC,EAAA,KAAA;KAKQ,kCAAkC,EAAE,MAC9C,kBAAkB;;;KClGR;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
|
@@ -216,8 +216,16 @@ const mistralLanguageModelChatOptions = () => z.object({
|
|
|
216
216
|
*
|
|
217
217
|
* - `'high'`: Enable reasoning
|
|
218
218
|
* - `'none'`: Disable reasoning
|
|
219
|
+
* - `'low'`, `'max'`: Lowest and highest reasoning effort for models that
|
|
220
|
+
* support them, e.g. `zai-glm-5-3`, which accepts `'low'`, `'high'`, and
|
|
221
|
+
* `'max'` but not `'none'`
|
|
219
222
|
*/
|
|
220
|
-
reasoningEffort: z.enum([
|
|
223
|
+
reasoningEffort: z.enum([
|
|
224
|
+
"high",
|
|
225
|
+
"none",
|
|
226
|
+
"low",
|
|
227
|
+
"max"
|
|
228
|
+
]).optional()
|
|
221
229
|
});
|
|
222
230
|
const mistralLanguageModelChatOptionsValidator = lazySchema(() => zodSchema(mistralLanguageModelChatOptions()));
|
|
223
231
|
//#endregion
|
|
@@ -301,6 +309,12 @@ const modelsWithoutReasoningEffort = /* @__PURE__ */ new Set([
|
|
|
301
309
|
"voxtral-small-2507",
|
|
302
310
|
"voxtral-small-latest"
|
|
303
311
|
]);
|
|
312
|
+
const modelsWithLowHighMaxReasoningEffort = /* @__PURE__ */ new Set([
|
|
313
|
+
"zai-glm-5",
|
|
314
|
+
"zai-glm-5-3",
|
|
315
|
+
"zai-glm-5-3-flash",
|
|
316
|
+
"zai-glm-latest"
|
|
317
|
+
]);
|
|
304
318
|
var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
305
319
|
static [WORKFLOW_SERIALIZE](model) {
|
|
306
320
|
return serializeModelOptions({
|
|
@@ -334,19 +348,33 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
334
348
|
});
|
|
335
349
|
const supportsReasoningEffort = !modelsWithoutReasoningEffort.has(this.modelId);
|
|
336
350
|
let resolvedReasoningEffort;
|
|
337
|
-
if (supportsReasoningEffort)
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
351
|
+
if (supportsReasoningEffort) {
|
|
352
|
+
const supportsLowHighMax = modelsWithLowHighMaxReasoningEffort.has(this.modelId);
|
|
353
|
+
if (options.reasoningEffort == null && reasoning === "none" && supportsLowHighMax) warnings.push({
|
|
354
|
+
type: "compatibility",
|
|
355
|
+
feature: "reasoning",
|
|
356
|
+
details: "reasoning \"none\" is not directly supported by this model. mapped to effort \"low\"."
|
|
357
|
+
});
|
|
358
|
+
resolvedReasoningEffort = options.reasoningEffort ?? (isCustomReasoning(reasoning) ? reasoning === "none" ? supportsLowHighMax ? "low" : "none" : mapReasoningToProviderEffort({
|
|
359
|
+
reasoning,
|
|
360
|
+
effortMap: supportsLowHighMax ? {
|
|
361
|
+
minimal: "low",
|
|
362
|
+
low: "low",
|
|
363
|
+
medium: "high",
|
|
364
|
+
high: "high",
|
|
365
|
+
xhigh: "max",
|
|
366
|
+
max: "max"
|
|
367
|
+
} : {
|
|
368
|
+
minimal: "high",
|
|
369
|
+
low: "high",
|
|
370
|
+
medium: "high",
|
|
371
|
+
high: "high",
|
|
372
|
+
xhigh: "high",
|
|
373
|
+
max: "high"
|
|
374
|
+
},
|
|
375
|
+
warnings
|
|
376
|
+
}) : void 0);
|
|
377
|
+
} else if (isCustomReasoning(reasoning)) warnings.push({
|
|
350
378
|
type: "unsupported",
|
|
351
379
|
feature: "reasoning",
|
|
352
380
|
details: "This model does not support reasoning configuration."
|
|
@@ -1768,7 +1796,7 @@ const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1768
1796
|
})));
|
|
1769
1797
|
//#endregion
|
|
1770
1798
|
//#region src/version.ts
|
|
1771
|
-
const VERSION = "4.0.
|
|
1799
|
+
const VERSION = "4.0.73";
|
|
1772
1800
|
//#endregion
|
|
1773
1801
|
//#region src/tool/web-search.ts
|
|
1774
1802
|
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 // 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,mBAAmB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AAI,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'\n | 'zai-glm-5-2'\n | 'zai-glm-5-3'\n | 'zai-glm-5-3-flash'\n | 'zai-glm-latest'\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 * - `'low'`, `'max'`: Lowest and highest reasoning effort for models that\n * support them, e.g. `zai-glm-5-3`, which accepts `'low'`, `'high'`, and\n * `'max'` but not `'none'`\n */\n reasoningEffort: z.enum(['high', 'none', 'low', 'max']).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\n// GLM-5.3 models accept only low, high, and max reasoning effort and cannot\n// disable reasoning. Omitting reasoning_effort uses max.\n// https://docs.mistral.ai/studio/conversations/reasoning (2026-10-26)\nconst modelsWithLowHighMaxReasoningEffort = new Set<MistralChatModelId>([\n 'zai-glm-5',\n 'zai-glm-5-3',\n 'zai-glm-5-3-flash',\n 'zai-glm-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 const supportsLowHighMax = modelsWithLowHighMaxReasoningEffort.has(\n this.modelId,\n );\n\n if (\n options.reasoningEffort == null &&\n reasoning === 'none' &&\n supportsLowHighMax\n ) {\n warnings.push({\n type: 'compatibility',\n feature: 'reasoning',\n details:\n 'reasoning \"none\" is not directly supported by this model. mapped to effort \"low\".',\n });\n }\n\n resolvedReasoningEffort =\n options.reasoningEffort ??\n (isCustomReasoning(reasoning)\n ? reasoning === 'none'\n ? supportsLowHighMax\n ? 'low'\n : 'none'\n : mapReasoningToProviderEffort({\n reasoning,\n effortMap: supportsLowHighMax\n ? {\n minimal: 'low',\n low: 'low',\n medium: 'high',\n high: 'high',\n xhigh: 'max',\n max: 'max',\n }\n : {\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,mBAAmB,EAAE,OAAO;CAC5B,cAAc,EAAE,OAAO;CACvB,sBAAsB,EAAE,OAAO,CAAC,CAAC,QAAQ;CACzC,eAAe,EAAE,OAAO,CAAC,CAAC,QAAQ;CAClC,cAAc,EAAE,OAAO,CAAC,CAAC,QAAQ;CACjC,mBAAmB,EAAE,OAAO,CAAC,CAAC,QAAQ;CACtC,uBAAuB,iCAAiC,QAAQ;CAChE,sBAAsB,iC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Ac;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"}
|
package/docs/20-mistral.mdx
CHANGED
|
@@ -285,7 +285,8 @@ console.log('REASONING:', result.reasoningText);
|
|
|
285
285
|
console.log('ANSWER:', result.text);
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
|
|
288
|
+
Most Mistral reasoning models support `'high'` and `'none'` as effort levels, so other levels are mapped to `'high'`.
|
|
289
|
+
GLM-5.3 models (`zai-glm-5-3`, `zai-glm-5-3-flash`, `zai-glm-5`, `zai-glm-latest`) support `'low'`, `'high'`, and `'max'` and cannot disable reasoning: `minimal` and `low` are mapped to `'low'`, `medium` and `high` to `'high'`, `xhigh` and `max` to `'max'`, and `'none'` to `'low'` with a warning.
|
|
289
290
|
|
|
290
291
|
### Example
|
|
291
292
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mistral",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.73",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/provider": "4.0.34",
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.69"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -35,7 +35,11 @@ export type MistralChatModelId =
|
|
|
35
35
|
| 'mistral-vibe-cli-with-tools'
|
|
36
36
|
| 'voxtral-small-2507'
|
|
37
37
|
| 'voxtral-small-latest'
|
|
38
|
+
| 'zai-glm-5'
|
|
38
39
|
| 'zai-glm-5-2'
|
|
40
|
+
| 'zai-glm-5-3'
|
|
41
|
+
| 'zai-glm-5-3-flash'
|
|
42
|
+
| 'zai-glm-latest'
|
|
39
43
|
| (string & {});
|
|
40
44
|
|
|
41
45
|
export const mistralLanguageModelChatOptions = () =>
|
|
@@ -83,8 +87,11 @@ export const mistralLanguageModelChatOptions = () =>
|
|
|
83
87
|
*
|
|
84
88
|
* - `'high'`: Enable reasoning
|
|
85
89
|
* - `'none'`: Disable reasoning
|
|
90
|
+
* - `'low'`, `'max'`: Lowest and highest reasoning effort for models that
|
|
91
|
+
* support them, e.g. `zai-glm-5-3`, which accepts `'low'`, `'high'`, and
|
|
92
|
+
* `'max'` but not `'none'`
|
|
86
93
|
*/
|
|
87
|
-
reasoningEffort: z.enum(['high', 'none']).optional(),
|
|
94
|
+
reasoningEffort: z.enum(['high', 'none', 'low', 'max']).optional(),
|
|
88
95
|
});
|
|
89
96
|
export const mistralLanguageModelChatOptionsValidator = lazySchema(() =>
|
|
90
97
|
zodSchema(mistralLanguageModelChatOptions()),
|
|
@@ -72,6 +72,16 @@ const modelsWithoutReasoningEffort = new Set<MistralChatModelId>([
|
|
|
72
72
|
'voxtral-small-latest',
|
|
73
73
|
]);
|
|
74
74
|
|
|
75
|
+
// GLM-5.3 models accept only low, high, and max reasoning effort and cannot
|
|
76
|
+
// disable reasoning. Omitting reasoning_effort uses max.
|
|
77
|
+
// https://docs.mistral.ai/studio/conversations/reasoning (2026-10-26)
|
|
78
|
+
const modelsWithLowHighMaxReasoningEffort = new Set<MistralChatModelId>([
|
|
79
|
+
'zai-glm-5',
|
|
80
|
+
'zai-glm-5-3',
|
|
81
|
+
'zai-glm-5-3-flash',
|
|
82
|
+
'zai-glm-latest',
|
|
83
|
+
]);
|
|
84
|
+
|
|
75
85
|
export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
76
86
|
readonly specificationVersion = 'v4';
|
|
77
87
|
|
|
@@ -143,21 +153,49 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
143
153
|
|
|
144
154
|
let resolvedReasoningEffort: string | undefined;
|
|
145
155
|
if (supportsReasoningEffort) {
|
|
156
|
+
const supportsLowHighMax = modelsWithLowHighMaxReasoningEffort.has(
|
|
157
|
+
this.modelId,
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
if (
|
|
161
|
+
options.reasoningEffort == null &&
|
|
162
|
+
reasoning === 'none' &&
|
|
163
|
+
supportsLowHighMax
|
|
164
|
+
) {
|
|
165
|
+
warnings.push({
|
|
166
|
+
type: 'compatibility',
|
|
167
|
+
feature: 'reasoning',
|
|
168
|
+
details:
|
|
169
|
+
'reasoning "none" is not directly supported by this model. mapped to effort "low".',
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
|
|
146
173
|
resolvedReasoningEffort =
|
|
147
174
|
options.reasoningEffort ??
|
|
148
175
|
(isCustomReasoning(reasoning)
|
|
149
176
|
? reasoning === 'none'
|
|
150
|
-
?
|
|
177
|
+
? supportsLowHighMax
|
|
178
|
+
? 'low'
|
|
179
|
+
: 'none'
|
|
151
180
|
: mapReasoningToProviderEffort({
|
|
152
181
|
reasoning,
|
|
153
|
-
effortMap:
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
182
|
+
effortMap: supportsLowHighMax
|
|
183
|
+
? {
|
|
184
|
+
minimal: 'low',
|
|
185
|
+
low: 'low',
|
|
186
|
+
medium: 'high',
|
|
187
|
+
high: 'high',
|
|
188
|
+
xhigh: 'max',
|
|
189
|
+
max: 'max',
|
|
190
|
+
}
|
|
191
|
+
: {
|
|
192
|
+
minimal: 'high',
|
|
193
|
+
low: 'high',
|
|
194
|
+
medium: 'high',
|
|
195
|
+
high: 'high',
|
|
196
|
+
xhigh: 'high',
|
|
197
|
+
max: 'high',
|
|
198
|
+
},
|
|
161
199
|
warnings,
|
|
162
200
|
})
|
|
163
201
|
: undefined);
|