@ai-sdk/mistral 4.0.76 → 4.0.78

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.
@@ -475,6 +475,8 @@ For `streamText`, consume the stream before appending
475
475
 
476
476
  ### Model Capabilities
477
477
 
478
+ {/* model-capabilities:mistral-language:start */}
479
+
478
480
  | Model | Image Input | Tool Usage |
479
481
  | ------------------------- | ----------- | ---------- |
480
482
  | `labs-leanstral-1-5` | <Check /> | <Check /> |
@@ -488,6 +490,8 @@ For `streamText`, consume the stream before appending
488
490
  | `voxtral-small-latest` | <Cross /> | <Check /> |
489
491
  | `zai-glm-5-2` | <Cross /> | <Check /> |
490
492
 
493
+ {/* model-capabilities:mistral-language:end */}
494
+
491
495
  <Note>
492
496
  The table above lists popular models. Please see the [Mistral
493
497
  docs](https://docs.mistral.ai/models) for a full list of available models. You
@@ -594,12 +598,16 @@ speaker IDs from diarization are available under
594
598
 
595
599
  ### Model Capabilities
596
600
 
601
+ {/* model-capabilities:mistral-transcription:start */}
602
+
597
603
  | Model | Timestamps | Diarization | Context Bias |
598
604
  | ------------------------------ | ---------- | ----------- | ------------ |
599
605
  | `voxtral-mini-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
600
606
  | `voxtral-small-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
601
607
  | `voxtral-mini-latest` | <Check /> | <Check /> | <Check /> |
602
608
 
609
+ {/* model-capabilities:mistral-transcription:end */}
610
+
603
611
  ## Speech Models
604
612
 
605
613
  You can create models that call the
@@ -696,11 +704,15 @@ is redacted from request metadata and API call errors returned by the provider.
696
704
 
697
705
  ### Model Capabilities
698
706
 
707
+ {/* model-capabilities:mistral-speech:start */}
708
+
699
709
  | Model | Saved Voices | Reference Audio | Non-Streaming |
700
710
  | ----------------------- | ------------ | --------------- | ------------- |
701
711
  | `voxtral-mini-tts-3-0` | <Check /> | <Check /> | <Check /> |
702
712
  | `voxtral-mini-tts-2603` | <Check /> | <Check /> | <Check /> |
703
713
 
714
+ {/* model-capabilities:mistral-speech:end */}
715
+
704
716
  ## Embedding Models
705
717
 
706
718
  You can create models that call the [Mistral embeddings API](https://docs.mistral.ai/api/#operation/createEmbedding)
@@ -761,6 +773,11 @@ models:
761
773
 
762
774
  ### Model Capabilities
763
775
 
764
- | Model | Default Dimensions |
765
- | --------------- | ------------------ |
766
- | `mistral-embed` | 1024 |
776
+ {/* model-capabilities:mistral-embedding:start */}
777
+
778
+ | Model | Default Dimensions |
779
+ | ----------------- | ------------------ |
780
+ | `mistral-embed` | 1024 |
781
+ | `codestral-embed` | 1536 |
782
+
783
+ {/* model-capabilities:mistral-embedding:end */}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/mistral",
3
- "version": "4.0.76",
3
+ "version": "4.0.78",
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.35",
33
- "@ai-sdk/provider-utils": "5.0.72"
33
+ "@ai-sdk/provider-utils": "5.0.73"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@ai-sdk/test-server": "2.0.4",
@@ -8,6 +8,8 @@ import type {
8
8
  MistralPrompt,
9
9
  } from './mistral-chat-prompt';
10
10
  import {
11
+ secureJsonParse,
12
+ stringifyWithBigIntAndCycles,
11
13
  convertToBase64,
12
14
  getTopLevelMediaType,
13
15
  resolveFullMediaType,
@@ -27,6 +29,18 @@ function formatFileUrl({ part }: { part: LanguageModelV4FilePart }): string {
27
29
  });
28
30
  }
29
31
 
32
+ export function serializeMistralToolCallArguments(input: unknown): string {
33
+ if (typeof input === 'string') {
34
+ try {
35
+ secureJsonParse(input);
36
+ return input;
37
+ } catch {
38
+ return JSON.stringify(input);
39
+ }
40
+ }
41
+ return stringifyWithBigIntAndCycles(input);
42
+ }
43
+
30
44
  export function convertToMistralChatMessages(
31
45
  prompt: LanguageModelV4Prompt,
32
46
  ): MistralPrompt {
@@ -125,7 +139,7 @@ export function convertToMistralChatMessages(
125
139
  type: 'function',
126
140
  function: {
127
141
  name: part.toolName,
128
- arguments: JSON.stringify(part.input),
142
+ arguments: serializeMistralToolCallArguments(part.input),
129
143
  },
130
144
  });
131
145
  break;
@@ -175,7 +189,7 @@ export function convertToMistralChatMessages(
175
189
  case 'content':
176
190
  case 'json':
177
191
  case 'error-json':
178
- contentValue = JSON.stringify(output.value);
192
+ contentValue = stringifyWithBigIntAndCycles(output.value);
179
193
  break;
180
194
  }
181
195
 
@@ -4,8 +4,14 @@ import {
4
4
  type LanguageModelV4Prompt,
5
5
  type LanguageModelV4ToolResultPart,
6
6
  } from '@ai-sdk/provider';
7
- import type { ToolNameMapping } from '@ai-sdk/provider-utils';
8
- import { convertToMistralChatMessages } from './convert-to-mistral-chat-messages';
7
+ import {
8
+ stringifyWithBigIntAndCycles,
9
+ type ToolNameMapping,
10
+ } from '@ai-sdk/provider-utils';
11
+ import {
12
+ convertToMistralChatMessages,
13
+ serializeMistralToolCallArguments,
14
+ } from './convert-to-mistral-chat-messages';
9
15
  import type {
10
16
  MistralAssistantMessageContent,
11
17
  MistralToolMessage,
@@ -51,7 +57,10 @@ export function convertToMistralConversationInputs(
51
57
  inputs.push({
52
58
  type: 'function.result',
53
59
  tool_call_id: part.toolCallId,
54
- result: typeof result === 'string' ? result : JSON.stringify(result),
60
+ result:
61
+ typeof result === 'string'
62
+ ? result
63
+ : stringifyWithBigIntAndCycles(result),
55
64
  });
56
65
  return;
57
66
  }
@@ -120,7 +129,7 @@ export function convertToMistralConversationInputs(
120
129
  arguments:
121
130
  typeof args?.arguments === 'string'
122
131
  ? args.arguments
123
- : JSON.stringify(part.input),
132
+ : serializeMistralToolCallArguments(part.input),
124
133
  });
125
134
  executions.add(part.toolCallId);
126
135
  } else {
@@ -128,7 +137,7 @@ export function convertToMistralConversationInputs(
128
137
  type: 'function.call',
129
138
  tool_call_id: part.toolCallId,
130
139
  name: part.toolName,
131
- arguments: JSON.stringify(part.input),
140
+ arguments: serializeMistralToolCallArguments(part.input),
132
141
  });
133
142
  }
134
143
  break;
@@ -46,6 +46,7 @@ import {
46
46
  } from './mistral-chat-language-model-options';
47
47
  import { mistralFailedResponseHandler } from './mistral-error';
48
48
  import { prepareTools } from './mistral-prepare-tools';
49
+ import { getMistralLanguageModelEntry } from './mistral-model-catalog';
49
50
 
50
51
  type MistralChatConfig = {
51
52
  provider: string;
@@ -55,35 +56,6 @@ type MistralChatConfig = {
55
56
  generateId?: () => string;
56
57
  };
57
58
 
58
- // Known non-reasoning models from https://api.mistral.ai/v1/models
59
- // (2026-10-06). Unknown IDs inherit current reasoning configuration support.
60
- const modelsWithoutReasoningEffort = new Set<MistralChatModelId>([
61
- 'codestral-2508',
62
- 'codestral-latest',
63
- 'ministral-14b-2512',
64
- 'ministral-14b-latest',
65
- 'ministral-3b-2512',
66
- 'ministral-3b-latest',
67
- 'ministral-8b-2512',
68
- 'ministral-8b-latest',
69
- 'mistral-code-fim-latest',
70
- 'mistral-code-latest',
71
- 'mistral-large-latest',
72
- 'mistral-large-2512',
73
- 'voxtral-small-2507',
74
- 'voxtral-small-latest',
75
- ]);
76
-
77
- // GLM-5.3 models accept only low, high, and max reasoning effort and cannot
78
- // disable reasoning. Omitting reasoning_effort uses max.
79
- // https://docs.mistral.ai/studio/conversations/reasoning (2026-10-26)
80
- const modelsWithLowHighMaxReasoningEffort = new Set<MistralChatModelId>([
81
- 'zai-glm-5',
82
- 'zai-glm-5-3',
83
- 'zai-glm-5-3-flash',
84
- 'zai-glm-latest',
85
- ]);
86
-
87
59
  export class MistralChatLanguageModel implements LanguageModelV4 {
88
60
  readonly specificationVersion = 'v4';
89
61
 
@@ -149,22 +121,18 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
149
121
  warnings.push({ type: 'unsupported', feature: 'topK' });
150
122
  }
151
123
 
152
- const supportsReasoningEffort = !modelsWithoutReasoningEffort.has(
124
+ const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
153
125
  this.modelId,
154
- );
126
+ ).capabilities.language;
155
127
 
156
128
  let resolvedReasoningEffort: string | undefined;
157
- if (supportsReasoningEffort) {
158
- const supportsLowHighMax = modelsWithLowHighMaxReasoningEffort.has(
159
- this.modelId,
160
- );
161
-
129
+ if (reasoningCapabilities.support) {
162
130
  resolvedReasoningEffort = mapReasoningToProviderEffort({
163
131
  reasoning,
164
132
  providerOptionsEffort: options.reasoningEffort,
165
- effortMap: supportsLowHighMax
166
- ? { low: 'low', high: 'high', max: 'max' }
167
- : { none: 'none', high: 'high' },
133
+ effortMap: Object.fromEntries(
134
+ reasoningCapabilities.efforts.map(effort => [effort, effort]),
135
+ ),
168
136
  warnings,
169
137
  });
170
138
  } else if (isCustomReasoning(reasoning)) {
@@ -47,6 +47,7 @@ import {
47
47
  type MistralConversationModelId,
48
48
  } from './mistral-conversation-language-model-options';
49
49
  import { mistralFailedResponseHandler } from './mistral-error';
50
+ import { getMistralLanguageModelEntry } from './mistral-model-catalog';
50
51
  import {
51
52
  mistralProviderToolNames,
52
53
  prepareConversationTools,
@@ -60,29 +61,6 @@ type MistralConversationConfig = {
60
61
  generateId?: () => string;
61
62
  };
62
63
 
63
- // https://api.mistral.ai/v1/models (2026-10-06)
64
- const reasoningEffortModelIds = new Set<MistralConversationModelId>([
65
- 'glm-5-2',
66
- 'labs-leanstral-1-5',
67
- 'labs-leanstral-1-5-1',
68
- 'magistral-medium-latest',
69
- 'magistral-small-latest',
70
- 'mistral-large-4',
71
- 'mistral-large-4-0',
72
- 'mistral-medium',
73
- 'mistral-medium-2604',
74
- 'mistral-medium-3',
75
- 'mistral-medium-3-5',
76
- 'mistral-medium-3.5',
77
- 'mistral-medium-latest',
78
- 'mistral-small-2603',
79
- 'mistral-small-latest',
80
- 'mistral-vibe-cli-fast',
81
- 'mistral-vibe-cli-latest',
82
- 'mistral-vibe-cli-with-tools',
83
- 'zai-glm-5-2',
84
- ]);
85
-
86
64
  export class MistralConversationLanguageModel implements LanguageModelV4 {
87
65
  readonly specificationVersion = 'v4';
88
66
 
@@ -154,14 +132,18 @@ export class MistralConversationLanguageModel implements LanguageModelV4 {
154
132
  warnings.push({ type: 'unsupported', feature: 'topK' });
155
133
  }
156
134
 
157
- const supportsReasoningEffort = reasoningEffortModelIds.has(this.modelId);
135
+ const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
136
+ this.modelId,
137
+ ).capabilities.language.endpoints.conversation;
158
138
 
159
139
  let resolvedReasoningEffort: string | undefined;
160
- if (supportsReasoningEffort) {
140
+ if (reasoningCapabilities.support) {
161
141
  resolvedReasoningEffort = mapReasoningToProviderEffort({
162
142
  reasoning,
163
143
  providerOptionsEffort: options.reasoningEffort,
164
- effortMap: { none: 'none', high: 'high' },
144
+ effortMap: Object.fromEntries(
145
+ reasoningCapabilities.efforts.map(effort => [effort, effort]),
146
+ ),
165
147
  warnings,
166
148
  });
167
149
  } else if (isCustomReasoning(reasoning)) {