@ai-sdk/mistral 4.0.75 → 4.0.77
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 +20 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +223 -70
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +25 -4
- package/package.json +3 -3
- package/src/mistral-chat-language-model.ts +18 -42
- package/src/mistral-conversation-language-model.ts +19 -29
- package/src/mistral-embedding-model.ts +4 -2
- package/src/mistral-model-catalog.ts +401 -0
- package/src/mistral-provider.ts +15 -11
- package/src/mistral-speech-model.ts +8 -4
- package/src/mistral-transcription-model.ts +10 -9
package/docs/20-mistral.mdx
CHANGED
|
@@ -85,7 +85,11 @@ You can use the following optional settings to customize the Mistral provider in
|
|
|
85
85
|
Use a different URL prefix for API calls, e.g. to use proxy servers.
|
|
86
86
|
The default prefix is `https://api.mistral.ai/v1`.
|
|
87
87
|
|
|
88
|
-
- **apiKey**
|
|
88
|
+
- **apiKey** _string | PromiseLike<string> | (() => string | PromiseLike<string>)_
|
|
89
|
+
|
|
90
|
+
Pass a function to resolve credentials before each request, including when keys
|
|
91
|
+
rotate. The function can return a string or a promise. Credential caching and
|
|
92
|
+
refresh are managed by the function.
|
|
89
93
|
|
|
90
94
|
API key that is being sent using the `Authorization` header.
|
|
91
95
|
It defaults to the `MISTRAL_API_KEY` environment variable.
|
|
@@ -471,6 +475,8 @@ For `streamText`, consume the stream before appending
|
|
|
471
475
|
|
|
472
476
|
### Model Capabilities
|
|
473
477
|
|
|
478
|
+
{/* model-capabilities:mistral-language:start */}
|
|
479
|
+
|
|
474
480
|
| Model | Image Input | Tool Usage |
|
|
475
481
|
| ------------------------- | ----------- | ---------- |
|
|
476
482
|
| `labs-leanstral-1-5` | <Check /> | <Check /> |
|
|
@@ -484,6 +490,8 @@ For `streamText`, consume the stream before appending
|
|
|
484
490
|
| `voxtral-small-latest` | <Cross /> | <Check /> |
|
|
485
491
|
| `zai-glm-5-2` | <Cross /> | <Check /> |
|
|
486
492
|
|
|
493
|
+
{/* model-capabilities:mistral-language:end */}
|
|
494
|
+
|
|
487
495
|
<Note>
|
|
488
496
|
The table above lists popular models. Please see the [Mistral
|
|
489
497
|
docs](https://docs.mistral.ai/models) for a full list of available models. You
|
|
@@ -590,12 +598,16 @@ speaker IDs from diarization are available under
|
|
|
590
598
|
|
|
591
599
|
### Model Capabilities
|
|
592
600
|
|
|
601
|
+
{/* model-capabilities:mistral-transcription:start */}
|
|
602
|
+
|
|
593
603
|
| Model | Timestamps | Diarization | Context Bias |
|
|
594
604
|
| ------------------------------ | ---------- | ----------- | ------------ |
|
|
595
605
|
| `voxtral-mini-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
|
|
596
606
|
| `voxtral-small-transcribe-3-0` | <Check /> | <Check /> | <Check /> |
|
|
597
607
|
| `voxtral-mini-latest` | <Check /> | <Check /> | <Check /> |
|
|
598
608
|
|
|
609
|
+
{/* model-capabilities:mistral-transcription:end */}
|
|
610
|
+
|
|
599
611
|
## Speech Models
|
|
600
612
|
|
|
601
613
|
You can create models that call the
|
|
@@ -692,11 +704,15 @@ is redacted from request metadata and API call errors returned by the provider.
|
|
|
692
704
|
|
|
693
705
|
### Model Capabilities
|
|
694
706
|
|
|
707
|
+
{/* model-capabilities:mistral-speech:start */}
|
|
708
|
+
|
|
695
709
|
| Model | Saved Voices | Reference Audio | Non-Streaming |
|
|
696
710
|
| ----------------------- | ------------ | --------------- | ------------- |
|
|
697
711
|
| `voxtral-mini-tts-3-0` | <Check /> | <Check /> | <Check /> |
|
|
698
712
|
| `voxtral-mini-tts-2603` | <Check /> | <Check /> | <Check /> |
|
|
699
713
|
|
|
714
|
+
{/* model-capabilities:mistral-speech:end */}
|
|
715
|
+
|
|
700
716
|
## Embedding Models
|
|
701
717
|
|
|
702
718
|
You can create models that call the [Mistral embeddings API](https://docs.mistral.ai/api/#operation/createEmbedding)
|
|
@@ -757,6 +773,11 @@ models:
|
|
|
757
773
|
|
|
758
774
|
### Model Capabilities
|
|
759
775
|
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
|
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.
|
|
3
|
+
"version": "4.0.77",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/provider": "4.0.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
32
|
+
"@ai-sdk/provider": "4.0.35",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.72"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ai-sdk/test-server": "2.0.4",
|
|
@@ -9,6 +9,8 @@ import type {
|
|
|
9
9
|
SharedV4Warning,
|
|
10
10
|
} from '@ai-sdk/provider';
|
|
11
11
|
import {
|
|
12
|
+
resolve,
|
|
13
|
+
type Resolvable,
|
|
12
14
|
lazySchema,
|
|
13
15
|
zodSchema,
|
|
14
16
|
type InferSchema,
|
|
@@ -44,44 +46,16 @@ import {
|
|
|
44
46
|
} from './mistral-chat-language-model-options';
|
|
45
47
|
import { mistralFailedResponseHandler } from './mistral-error';
|
|
46
48
|
import { prepareTools } from './mistral-prepare-tools';
|
|
49
|
+
import { getMistralLanguageModelEntry } from './mistral-model-catalog';
|
|
47
50
|
|
|
48
51
|
type MistralChatConfig = {
|
|
49
52
|
provider: string;
|
|
50
53
|
baseURL: string;
|
|
51
|
-
headers?:
|
|
54
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
52
55
|
fetch?: FetchFunction;
|
|
53
56
|
generateId?: () => string;
|
|
54
57
|
};
|
|
55
58
|
|
|
56
|
-
// Known non-reasoning models from https://api.mistral.ai/v1/models
|
|
57
|
-
// (2026-10-06). Unknown IDs inherit current reasoning configuration support.
|
|
58
|
-
const modelsWithoutReasoningEffort = new Set<MistralChatModelId>([
|
|
59
|
-
'codestral-2508',
|
|
60
|
-
'codestral-latest',
|
|
61
|
-
'ministral-14b-2512',
|
|
62
|
-
'ministral-14b-latest',
|
|
63
|
-
'ministral-3b-2512',
|
|
64
|
-
'ministral-3b-latest',
|
|
65
|
-
'ministral-8b-2512',
|
|
66
|
-
'ministral-8b-latest',
|
|
67
|
-
'mistral-code-fim-latest',
|
|
68
|
-
'mistral-code-latest',
|
|
69
|
-
'mistral-large-latest',
|
|
70
|
-
'mistral-large-2512',
|
|
71
|
-
'voxtral-small-2507',
|
|
72
|
-
'voxtral-small-latest',
|
|
73
|
-
]);
|
|
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
|
-
|
|
85
59
|
export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
86
60
|
readonly specificationVersion = 'v4';
|
|
87
61
|
|
|
@@ -147,22 +121,18 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
147
121
|
warnings.push({ type: 'unsupported', feature: 'topK' });
|
|
148
122
|
}
|
|
149
123
|
|
|
150
|
-
const
|
|
124
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
|
|
151
125
|
this.modelId,
|
|
152
|
-
);
|
|
126
|
+
).capabilities.language;
|
|
153
127
|
|
|
154
128
|
let resolvedReasoningEffort: string | undefined;
|
|
155
|
-
if (
|
|
156
|
-
const supportsLowHighMax = modelsWithLowHighMaxReasoningEffort.has(
|
|
157
|
-
this.modelId,
|
|
158
|
-
);
|
|
159
|
-
|
|
129
|
+
if (reasoningCapabilities.support) {
|
|
160
130
|
resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
161
131
|
reasoning,
|
|
162
132
|
providerOptionsEffort: options.reasoningEffort,
|
|
163
|
-
effortMap:
|
|
164
|
-
|
|
165
|
-
|
|
133
|
+
effortMap: Object.fromEntries(
|
|
134
|
+
reasoningCapabilities.efforts.map(effort => [effort, effort]),
|
|
135
|
+
),
|
|
166
136
|
warnings,
|
|
167
137
|
});
|
|
168
138
|
} else if (isCustomReasoning(reasoning)) {
|
|
@@ -267,7 +237,10 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
267
237
|
rawValue: rawResponse,
|
|
268
238
|
} = await postJsonToApi({
|
|
269
239
|
url: `${this.config.baseURL}/chat/completions`,
|
|
270
|
-
headers: combineHeaders(
|
|
240
|
+
headers: combineHeaders(
|
|
241
|
+
await resolve(this.config.headers),
|
|
242
|
+
options.headers,
|
|
243
|
+
),
|
|
271
244
|
body,
|
|
272
245
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
273
246
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -346,7 +319,10 @@ export class MistralChatLanguageModel implements LanguageModelV4 {
|
|
|
346
319
|
|
|
347
320
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
348
321
|
url: `${this.config.baseURL}/chat/completions`,
|
|
349
|
-
headers: combineHeaders(
|
|
322
|
+
headers: combineHeaders(
|
|
323
|
+
await resolve(this.config.headers),
|
|
324
|
+
options.headers,
|
|
325
|
+
),
|
|
350
326
|
body,
|
|
351
327
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
352
328
|
successfulResponseHandler: createEventSourceResponseHandler(
|
|
@@ -13,6 +13,8 @@ import type {
|
|
|
13
13
|
SharedV4Warning,
|
|
14
14
|
} from '@ai-sdk/provider';
|
|
15
15
|
import {
|
|
16
|
+
resolve,
|
|
17
|
+
type Resolvable,
|
|
16
18
|
lazySchema,
|
|
17
19
|
zodSchema,
|
|
18
20
|
type InferSchema,
|
|
@@ -45,6 +47,7 @@ import {
|
|
|
45
47
|
type MistralConversationModelId,
|
|
46
48
|
} from './mistral-conversation-language-model-options';
|
|
47
49
|
import { mistralFailedResponseHandler } from './mistral-error';
|
|
50
|
+
import { getMistralLanguageModelEntry } from './mistral-model-catalog';
|
|
48
51
|
import {
|
|
49
52
|
mistralProviderToolNames,
|
|
50
53
|
prepareConversationTools,
|
|
@@ -53,34 +56,11 @@ import {
|
|
|
53
56
|
type MistralConversationConfig = {
|
|
54
57
|
provider: string;
|
|
55
58
|
baseURL: string;
|
|
56
|
-
headers?:
|
|
59
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
57
60
|
fetch?: FetchFunction;
|
|
58
61
|
generateId?: () => string;
|
|
59
62
|
};
|
|
60
63
|
|
|
61
|
-
// https://api.mistral.ai/v1/models (2026-10-06)
|
|
62
|
-
const reasoningEffortModelIds = new Set<MistralConversationModelId>([
|
|
63
|
-
'glm-5-2',
|
|
64
|
-
'labs-leanstral-1-5',
|
|
65
|
-
'labs-leanstral-1-5-1',
|
|
66
|
-
'magistral-medium-latest',
|
|
67
|
-
'magistral-small-latest',
|
|
68
|
-
'mistral-large-4',
|
|
69
|
-
'mistral-large-4-0',
|
|
70
|
-
'mistral-medium',
|
|
71
|
-
'mistral-medium-2604',
|
|
72
|
-
'mistral-medium-3',
|
|
73
|
-
'mistral-medium-3-5',
|
|
74
|
-
'mistral-medium-3.5',
|
|
75
|
-
'mistral-medium-latest',
|
|
76
|
-
'mistral-small-2603',
|
|
77
|
-
'mistral-small-latest',
|
|
78
|
-
'mistral-vibe-cli-fast',
|
|
79
|
-
'mistral-vibe-cli-latest',
|
|
80
|
-
'mistral-vibe-cli-with-tools',
|
|
81
|
-
'zai-glm-5-2',
|
|
82
|
-
]);
|
|
83
|
-
|
|
84
64
|
export class MistralConversationLanguageModel implements LanguageModelV4 {
|
|
85
65
|
readonly specificationVersion = 'v4';
|
|
86
66
|
|
|
@@ -152,14 +132,18 @@ export class MistralConversationLanguageModel implements LanguageModelV4 {
|
|
|
152
132
|
warnings.push({ type: 'unsupported', feature: 'topK' });
|
|
153
133
|
}
|
|
154
134
|
|
|
155
|
-
const
|
|
135
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
|
|
136
|
+
this.modelId,
|
|
137
|
+
).capabilities.language.endpoints.conversation;
|
|
156
138
|
|
|
157
139
|
let resolvedReasoningEffort: string | undefined;
|
|
158
|
-
if (
|
|
140
|
+
if (reasoningCapabilities.support) {
|
|
159
141
|
resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
160
142
|
reasoning,
|
|
161
143
|
providerOptionsEffort: options.reasoningEffort,
|
|
162
|
-
effortMap:
|
|
144
|
+
effortMap: Object.fromEntries(
|
|
145
|
+
reasoningCapabilities.efforts.map(effort => [effort, effort]),
|
|
146
|
+
),
|
|
163
147
|
warnings,
|
|
164
148
|
});
|
|
165
149
|
} else if (isCustomReasoning(reasoning)) {
|
|
@@ -266,7 +250,10 @@ export class MistralConversationLanguageModel implements LanguageModelV4 {
|
|
|
266
250
|
responseHeaders,
|
|
267
251
|
} = await postJsonToApi({
|
|
268
252
|
url: `${this.config.baseURL}/conversations`,
|
|
269
|
-
headers: combineHeaders(
|
|
253
|
+
headers: combineHeaders(
|
|
254
|
+
await resolve(this.config.headers),
|
|
255
|
+
options.headers,
|
|
256
|
+
),
|
|
270
257
|
body,
|
|
271
258
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
272
259
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -338,7 +325,10 @@ export class MistralConversationLanguageModel implements LanguageModelV4 {
|
|
|
338
325
|
|
|
339
326
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
340
327
|
url: `${this.config.baseURL}/conversations`,
|
|
341
|
-
headers: combineHeaders(
|
|
328
|
+
headers: combineHeaders(
|
|
329
|
+
await resolve(this.config.headers),
|
|
330
|
+
options.headers,
|
|
331
|
+
),
|
|
342
332
|
body,
|
|
343
333
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
344
334
|
successfulResponseHandler: createEventSourceResponseHandler(
|
|
@@ -3,6 +3,8 @@ import {
|
|
|
3
3
|
type EmbeddingModelV4,
|
|
4
4
|
} from '@ai-sdk/provider';
|
|
5
5
|
import {
|
|
6
|
+
resolve,
|
|
7
|
+
type Resolvable,
|
|
6
8
|
lazySchema,
|
|
7
9
|
zodSchema,
|
|
8
10
|
combineHeaders,
|
|
@@ -24,7 +26,7 @@ import { mistralFailedResponseHandler } from './mistral-error';
|
|
|
24
26
|
type MistralEmbeddingConfig = {
|
|
25
27
|
provider: string;
|
|
26
28
|
baseURL: string;
|
|
27
|
-
headers?:
|
|
29
|
+
headers?: Resolvable<Record<string, string | undefined>>;
|
|
28
30
|
fetch?: FetchFunction;
|
|
29
31
|
};
|
|
30
32
|
|
|
@@ -93,7 +95,7 @@ export class MistralEmbeddingModel implements EmbeddingModelV4 {
|
|
|
93
95
|
rawValue,
|
|
94
96
|
} = await postJsonToApi({
|
|
95
97
|
url: `${this.config.baseURL}/embeddings`,
|
|
96
|
-
headers: combineHeaders(this.config.headers
|
|
98
|
+
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
97
99
|
body: {
|
|
98
100
|
model: this.modelId,
|
|
99
101
|
input: values,
|