@ai-sdk/mistral 4.0.76 → 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 +6 -0
- package/dist/index.js +212 -59
- package/dist/index.js.map +1 -1
- package/docs/20-mistral.mdx +20 -3
- package/package.json +1 -1
- package/src/mistral-chat-language-model.ts +7 -39
- package/src/mistral-conversation-language-model.ts +8 -26
- package/src/mistral-model-catalog.ts +401 -0
- package/src/mistral-speech-model.ts +4 -2
- package/src/mistral-transcription-model.ts +3 -7
package/docs/20-mistral.mdx
CHANGED
|
@@ -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
|
-
|
|
765
|
-
|
|
766
|
-
|
|
|
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
|
@@ -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
|
|
124
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
|
|
153
125
|
this.modelId,
|
|
154
|
-
);
|
|
126
|
+
).capabilities.language;
|
|
155
127
|
|
|
156
128
|
let resolvedReasoningEffort: string | undefined;
|
|
157
|
-
if (
|
|
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:
|
|
166
|
-
|
|
167
|
-
|
|
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
|
|
135
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(
|
|
136
|
+
this.modelId,
|
|
137
|
+
).capabilities.language.endpoints.conversation;
|
|
158
138
|
|
|
159
139
|
let resolvedReasoningEffort: string | undefined;
|
|
160
|
-
if (
|
|
140
|
+
if (reasoningCapabilities.support) {
|
|
161
141
|
resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
162
142
|
reasoning,
|
|
163
143
|
providerOptionsEffort: options.reasoningEffort,
|
|
164
|
-
effortMap:
|
|
144
|
+
effortMap: Object.fromEntries(
|
|
145
|
+
reasoningCapabilities.efforts.map(effort => [effort, effort]),
|
|
146
|
+
),
|
|
165
147
|
warnings,
|
|
166
148
|
});
|
|
167
149
|
} else if (isCustomReasoning(reasoning)) {
|
|
@@ -0,0 +1,401 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ModelCapabilities,
|
|
3
|
+
ModelCapability,
|
|
4
|
+
ModelEntry,
|
|
5
|
+
ProviderOptionDefinition,
|
|
6
|
+
ProviderOptionDefinitions,
|
|
7
|
+
} from '@ai-sdk/provider';
|
|
8
|
+
import type {
|
|
9
|
+
MistralChatModelId,
|
|
10
|
+
MistralLanguageModelChatOptions,
|
|
11
|
+
} from './mistral-chat-language-model-options';
|
|
12
|
+
import type { MistralEmbeddingModelOptions } from './mistral-embedding-model-options';
|
|
13
|
+
import type { MistralSpeechModelOptions } from './mistral-speech-model-options';
|
|
14
|
+
import type { MistralTranscriptionModelOptions } from './mistral-transcription-model-options';
|
|
15
|
+
|
|
16
|
+
export const mistralProviderOptions = {
|
|
17
|
+
language: {
|
|
18
|
+
safePrompt: { description: 'Inject a safety prompt. Chat API only.' },
|
|
19
|
+
documentImageLimit: {
|
|
20
|
+
description: 'Maximum document images. Chat API only.',
|
|
21
|
+
},
|
|
22
|
+
documentPageLimit: {
|
|
23
|
+
description: 'Maximum document pages. Chat API only.',
|
|
24
|
+
},
|
|
25
|
+
structuredOutputs: {
|
|
26
|
+
description: 'Whether to send a JSON response schema.',
|
|
27
|
+
},
|
|
28
|
+
strictJsonSchema: {
|
|
29
|
+
description: 'Whether to use strict JSON schema validation.',
|
|
30
|
+
},
|
|
31
|
+
parallelToolCalls: {
|
|
32
|
+
description: 'Allow parallel function calls. Chat API only.',
|
|
33
|
+
},
|
|
34
|
+
promptCacheKey: { description: 'Cache affinity key. Chat API only.' },
|
|
35
|
+
reasoningEffort: {
|
|
36
|
+
description: 'Reasoning effort for configurable reasoning models.',
|
|
37
|
+
},
|
|
38
|
+
} satisfies Record<
|
|
39
|
+
keyof MistralLanguageModelChatOptions,
|
|
40
|
+
ProviderOptionDefinition
|
|
41
|
+
>,
|
|
42
|
+
embedding: {
|
|
43
|
+
metadata: { description: 'Metadata attached to the embedding request.' },
|
|
44
|
+
outputDimension: { description: 'Output embedding dimensions.' },
|
|
45
|
+
outputDtype: { description: 'Output embedding data type.' },
|
|
46
|
+
} satisfies Record<
|
|
47
|
+
keyof MistralEmbeddingModelOptions,
|
|
48
|
+
ProviderOptionDefinition
|
|
49
|
+
>,
|
|
50
|
+
transcription: {
|
|
51
|
+
language: { description: 'Language of the audio.' },
|
|
52
|
+
returnLanguage: { description: 'Return the detected language.' },
|
|
53
|
+
temperature: { description: 'Sampling temperature.' },
|
|
54
|
+
timestampGranularities: {
|
|
55
|
+
description: 'Timestamp granularities to return.',
|
|
56
|
+
},
|
|
57
|
+
diarize: { description: 'Identify speakers in the transcription.' },
|
|
58
|
+
contextBias: {
|
|
59
|
+
description: 'Vocabulary and context to guide transcription.',
|
|
60
|
+
},
|
|
61
|
+
} satisfies Record<
|
|
62
|
+
keyof MistralTranscriptionModelOptions,
|
|
63
|
+
ProviderOptionDefinition
|
|
64
|
+
>,
|
|
65
|
+
speech: {
|
|
66
|
+
refAudio: {
|
|
67
|
+
description: 'Reference audio for voice cloning, overriding voice.',
|
|
68
|
+
},
|
|
69
|
+
expressiveness: { description: 'Speech expressiveness, from 1 to 5.' },
|
|
70
|
+
phonemeHints: { description: 'Pronunciation hints as IPA phonemes.' },
|
|
71
|
+
} satisfies Record<keyof MistralSpeechModelOptions, ProviderOptionDefinition>,
|
|
72
|
+
} as const satisfies ProviderOptionDefinitions;
|
|
73
|
+
|
|
74
|
+
type ReasoningEffort = NonNullable<
|
|
75
|
+
MistralLanguageModelChatOptions['reasoningEffort']
|
|
76
|
+
>;
|
|
77
|
+
type ReasoningCapabilities = {
|
|
78
|
+
support: boolean;
|
|
79
|
+
efforts: readonly ReasoningEffort[];
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
type LanguageCapabilities = NonNullable<ModelCapabilities['language']> & {
|
|
83
|
+
reasoning: ReasoningCapabilities;
|
|
84
|
+
endpoints: {
|
|
85
|
+
conversation: {
|
|
86
|
+
reasoning: ReasoningCapabilities;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export type MistralLanguageModelEntry = {
|
|
92
|
+
capabilities: { language: LanguageCapabilities };
|
|
93
|
+
providerOptions: {
|
|
94
|
+
language: Record<keyof MistralLanguageModelChatOptions, ModelCapability>;
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
type TranscriptionCapabilities = NonNullable<
|
|
99
|
+
ModelCapabilities['transcription']
|
|
100
|
+
> & {
|
|
101
|
+
languageWithTimestamps: boolean;
|
|
102
|
+
timestamps: ModelCapability;
|
|
103
|
+
diarization: ModelCapability;
|
|
104
|
+
contextBias: ModelCapability;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
type SpeechCapabilities = NonNullable<ModelCapabilities['speech']> & {
|
|
108
|
+
savedVoices: ModelCapability;
|
|
109
|
+
referenceAudio: ModelCapability;
|
|
110
|
+
nonStreaming: boolean;
|
|
111
|
+
outputFormats: readonly string[];
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
type MistralModelEntry = ModelEntry & {
|
|
115
|
+
providerOptions?: {
|
|
116
|
+
[Section in keyof typeof mistralProviderOptions]?: Record<
|
|
117
|
+
keyof (typeof mistralProviderOptions)[Section],
|
|
118
|
+
ModelCapability
|
|
119
|
+
>;
|
|
120
|
+
};
|
|
121
|
+
capabilities: ModelCapabilities & {
|
|
122
|
+
language?: LanguageCapabilities;
|
|
123
|
+
transcription?: TranscriptionCapabilities;
|
|
124
|
+
speech?: SpeechCapabilities;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// Preserve the provider page's documented model set and image-input exceptions.
|
|
129
|
+
const documentedLanguageModels: Record<string, boolean> = {
|
|
130
|
+
'labs-leanstral-1-5': true,
|
|
131
|
+
'magistral-medium-latest': true,
|
|
132
|
+
'magistral-small-latest': true,
|
|
133
|
+
'ministral-14b-latest': true,
|
|
134
|
+
'ministral-8b-latest': true,
|
|
135
|
+
'mistral-large-latest': true,
|
|
136
|
+
'mistral-medium-latest': true,
|
|
137
|
+
'mistral-small-latest': true,
|
|
138
|
+
'voxtral-small-latest': false,
|
|
139
|
+
'zai-glm-5-2': false,
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// Known non-reasoning models from https://api.mistral.ai/v1/models
|
|
143
|
+
// (2026-10-06). Unknown IDs inherit current reasoning configuration support.
|
|
144
|
+
const modelsWithoutReasoningEffort = new Set<MistralChatModelId>([
|
|
145
|
+
'codestral-2508',
|
|
146
|
+
'codestral-latest',
|
|
147
|
+
'ministral-14b-2512',
|
|
148
|
+
'ministral-14b-latest',
|
|
149
|
+
'ministral-3b-2512',
|
|
150
|
+
'ministral-3b-latest',
|
|
151
|
+
'ministral-8b-2512',
|
|
152
|
+
'ministral-8b-latest',
|
|
153
|
+
'mistral-code-fim-latest',
|
|
154
|
+
'mistral-code-latest',
|
|
155
|
+
'mistral-large-latest',
|
|
156
|
+
'mistral-large-2512',
|
|
157
|
+
'voxtral-small-2507',
|
|
158
|
+
'voxtral-small-latest',
|
|
159
|
+
]);
|
|
160
|
+
|
|
161
|
+
// GLM-5.3 models accept only low, high, and max reasoning effort and cannot
|
|
162
|
+
// disable reasoning. Omitting reasoning_effort uses max.
|
|
163
|
+
// https://docs.mistral.ai/studio/conversations/reasoning (2026-10-26)
|
|
164
|
+
const modelsWithLowHighMaxReasoningEffort = new Set<MistralChatModelId>([
|
|
165
|
+
'zai-glm-5',
|
|
166
|
+
'zai-glm-5-3',
|
|
167
|
+
'zai-glm-5-3-flash',
|
|
168
|
+
'zai-glm-latest',
|
|
169
|
+
]);
|
|
170
|
+
|
|
171
|
+
// https://api.mistral.ai/v1/models (2026-10-06)
|
|
172
|
+
const reasoningEffortModelIds = new Set<MistralChatModelId>([
|
|
173
|
+
'glm-5-2',
|
|
174
|
+
'labs-leanstral-1-5',
|
|
175
|
+
'labs-leanstral-1-5-1',
|
|
176
|
+
'magistral-medium-latest',
|
|
177
|
+
'magistral-small-latest',
|
|
178
|
+
'mistral-large-4',
|
|
179
|
+
'mistral-large-4-0',
|
|
180
|
+
'mistral-medium',
|
|
181
|
+
'mistral-medium-2604',
|
|
182
|
+
'mistral-medium-3',
|
|
183
|
+
'mistral-medium-3-5',
|
|
184
|
+
'mistral-medium-3.5',
|
|
185
|
+
'mistral-medium-latest',
|
|
186
|
+
'mistral-small-2603',
|
|
187
|
+
'mistral-small-latest',
|
|
188
|
+
'mistral-vibe-cli-fast',
|
|
189
|
+
'mistral-vibe-cli-latest',
|
|
190
|
+
'mistral-vibe-cli-with-tools',
|
|
191
|
+
'zai-glm-5-2',
|
|
192
|
+
]);
|
|
193
|
+
|
|
194
|
+
function reasoningCapabilities(
|
|
195
|
+
efforts: readonly ReasoningEffort[],
|
|
196
|
+
): ReasoningCapabilities {
|
|
197
|
+
return { support: efforts.length > 0, efforts };
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function createLanguageModelEntry(
|
|
201
|
+
modelId: string,
|
|
202
|
+
image?: boolean,
|
|
203
|
+
): MistralLanguageModelEntry {
|
|
204
|
+
const reasoning = reasoningCapabilities(
|
|
205
|
+
modelsWithoutReasoningEffort.has(modelId)
|
|
206
|
+
? []
|
|
207
|
+
: modelsWithLowHighMaxReasoningEffort.has(modelId)
|
|
208
|
+
? ['low', 'high', 'max']
|
|
209
|
+
: ['none', 'high'],
|
|
210
|
+
);
|
|
211
|
+
const conversationReasoning = reasoningCapabilities(
|
|
212
|
+
reasoningEffortModelIds.has(modelId) ? ['none', 'high'] : [],
|
|
213
|
+
);
|
|
214
|
+
const chatOnly = { condition: 'Only supported on the Chat API.' };
|
|
215
|
+
return {
|
|
216
|
+
capabilities: {
|
|
217
|
+
language: {
|
|
218
|
+
inputs: { image: image ?? 'unknown', audio: 'unknown' },
|
|
219
|
+
objectGeneration: image != null ? true : 'unknown',
|
|
220
|
+
tools: {
|
|
221
|
+
usage: image != null ? true : 'unknown',
|
|
222
|
+
streaming: image != null ? true : 'unknown',
|
|
223
|
+
},
|
|
224
|
+
reasoning,
|
|
225
|
+
sampling: { temperature: 'unknown', topP: 'unknown', logprobs: false },
|
|
226
|
+
endpoints: { conversation: { reasoning: conversationReasoning } },
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
providerOptions: {
|
|
230
|
+
language: declareProviderOptions(
|
|
231
|
+
mistralProviderOptions.language,
|
|
232
|
+
image != null ? true : 'unknown',
|
|
233
|
+
{
|
|
234
|
+
safePrompt: chatOnly,
|
|
235
|
+
documentImageLimit: chatOnly,
|
|
236
|
+
documentPageLimit: chatOnly,
|
|
237
|
+
parallelToolCalls: chatOnly,
|
|
238
|
+
promptCacheKey: chatOnly,
|
|
239
|
+
reasoningEffort:
|
|
240
|
+
reasoning.support && !conversationReasoning.support
|
|
241
|
+
? chatOnly
|
|
242
|
+
: reasoning.support,
|
|
243
|
+
},
|
|
244
|
+
),
|
|
245
|
+
},
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function createTranscriptionModelEntry(modelId: string, declared: boolean) {
|
|
250
|
+
// Only these legacy IDs reject pinned language combined with timestamps.
|
|
251
|
+
// Future and custom IDs keep the existing permissive request behavior.
|
|
252
|
+
const languageWithTimestamps = ![
|
|
253
|
+
'voxtral-mini-2507',
|
|
254
|
+
'voxtral-mini-2602',
|
|
255
|
+
'voxtral-mini-latest',
|
|
256
|
+
].includes(modelId);
|
|
257
|
+
const support = declared ? true : 'unknown';
|
|
258
|
+
const capabilities: TranscriptionCapabilities = {
|
|
259
|
+
transcription: support,
|
|
260
|
+
streaming: false,
|
|
261
|
+
duration: support,
|
|
262
|
+
segments: support,
|
|
263
|
+
language: support,
|
|
264
|
+
languageWithTimestamps,
|
|
265
|
+
timestamps: support,
|
|
266
|
+
diarization: support,
|
|
267
|
+
contextBias: support,
|
|
268
|
+
};
|
|
269
|
+
return {
|
|
270
|
+
capabilities: { transcription: capabilities },
|
|
271
|
+
providerOptions: {
|
|
272
|
+
transcription: declareProviderOptions(
|
|
273
|
+
mistralProviderOptions.transcription,
|
|
274
|
+
support,
|
|
275
|
+
{
|
|
276
|
+
returnLanguage: {
|
|
277
|
+
condition: 'Only supported when language is not pinned.',
|
|
278
|
+
},
|
|
279
|
+
timestampGranularities: languageWithTimestamps
|
|
280
|
+
? support
|
|
281
|
+
: {
|
|
282
|
+
condition: 'Only supported when language is not pinned.',
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
),
|
|
286
|
+
},
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function createSpeechModelEntry(declared: boolean) {
|
|
291
|
+
const support = declared ? true : 'unknown';
|
|
292
|
+
const capabilities: SpeechCapabilities = {
|
|
293
|
+
instructions: false,
|
|
294
|
+
savedVoices: support,
|
|
295
|
+
referenceAudio: support,
|
|
296
|
+
nonStreaming: true,
|
|
297
|
+
outputFormats: ['pcm', 'wav', 'mp3', 'flac', 'opus'],
|
|
298
|
+
};
|
|
299
|
+
return {
|
|
300
|
+
capabilities: { speech: capabilities },
|
|
301
|
+
providerOptions: {
|
|
302
|
+
speech: declareProviderOptions(
|
|
303
|
+
mistralProviderOptions.speech,
|
|
304
|
+
support,
|
|
305
|
+
{},
|
|
306
|
+
),
|
|
307
|
+
},
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function createEmbeddingModelEntry(
|
|
312
|
+
defaultDimensions: number,
|
|
313
|
+
customDimensions: boolean,
|
|
314
|
+
) {
|
|
315
|
+
return {
|
|
316
|
+
capabilities: { embedding: { defaultDimensions, customDimensions } },
|
|
317
|
+
providerOptions: {
|
|
318
|
+
embedding: declareProviderOptions(
|
|
319
|
+
mistralProviderOptions.embedding,
|
|
320
|
+
true,
|
|
321
|
+
{
|
|
322
|
+
outputDimension: customDimensions,
|
|
323
|
+
outputDtype: customDimensions,
|
|
324
|
+
},
|
|
325
|
+
),
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
export const mistralModelCatalog: Readonly<Record<string, MistralModelEntry>> =
|
|
331
|
+
{
|
|
332
|
+
...Object.fromEntries(
|
|
333
|
+
Object.entries(documentedLanguageModels).map(([modelId, image]) => [
|
|
334
|
+
modelId,
|
|
335
|
+
createLanguageModelEntry(modelId, image),
|
|
336
|
+
]),
|
|
337
|
+
),
|
|
338
|
+
'voxtral-mini-transcribe-3-0': createTranscriptionModelEntry(
|
|
339
|
+
'voxtral-mini-transcribe-3-0',
|
|
340
|
+
true,
|
|
341
|
+
),
|
|
342
|
+
'voxtral-small-transcribe-3-0': createTranscriptionModelEntry(
|
|
343
|
+
'voxtral-small-transcribe-3-0',
|
|
344
|
+
true,
|
|
345
|
+
),
|
|
346
|
+
'voxtral-mini-latest': createTranscriptionModelEntry(
|
|
347
|
+
'voxtral-mini-latest',
|
|
348
|
+
true,
|
|
349
|
+
),
|
|
350
|
+
'voxtral-mini-tts-3-0': createSpeechModelEntry(true),
|
|
351
|
+
'voxtral-mini-tts-2603': createSpeechModelEntry(true),
|
|
352
|
+
'mistral-embed': createEmbeddingModelEntry(1024, false),
|
|
353
|
+
// https://docs.mistral.ai/studio/knowledge-rag/embeddings/code_embeddings
|
|
354
|
+
'codestral-embed': createEmbeddingModelEntry(1536, true),
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
function findModelEntry(modelId: string) {
|
|
358
|
+
return Object.prototype.hasOwnProperty.call(mistralModelCatalog, modelId)
|
|
359
|
+
? mistralModelCatalog[modelId]
|
|
360
|
+
: undefined;
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
export function getMistralLanguageModelEntry(
|
|
364
|
+
modelId: string,
|
|
365
|
+
): MistralLanguageModelEntry {
|
|
366
|
+
const entry = findModelEntry(modelId);
|
|
367
|
+
return entry?.capabilities.language != null &&
|
|
368
|
+
entry.providerOptions?.language != null
|
|
369
|
+
? {
|
|
370
|
+
capabilities: { language: entry.capabilities.language },
|
|
371
|
+
providerOptions: { language: entry.providerOptions.language },
|
|
372
|
+
}
|
|
373
|
+
: createLanguageModelEntry(modelId);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export function getMistralTranscriptionModelEntry(modelId: string) {
|
|
377
|
+
const capabilities = findModelEntry(modelId)?.capabilities.transcription;
|
|
378
|
+
return capabilities != null
|
|
379
|
+
? { capabilities: { transcription: capabilities } }
|
|
380
|
+
: createTranscriptionModelEntry(modelId, false);
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
export function getMistralSpeechModelEntry(modelId: string) {
|
|
384
|
+
const capabilities = findModelEntry(modelId)?.capabilities.speech;
|
|
385
|
+
return capabilities != null
|
|
386
|
+
? { capabilities: { speech: capabilities } }
|
|
387
|
+
: createSpeechModelEntry(false);
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
function declareProviderOptions<Option extends string>(
|
|
391
|
+
definitions: Readonly<Record<Option, ProviderOptionDefinition>>,
|
|
392
|
+
support: ModelCapability,
|
|
393
|
+
exceptions: Partial<Record<Option, ModelCapability>>,
|
|
394
|
+
): Record<Option, ModelCapability> {
|
|
395
|
+
return Object.fromEntries(
|
|
396
|
+
(Object.keys(definitions) as Option[]).map(option => [
|
|
397
|
+
option,
|
|
398
|
+
exceptions[option] ?? support,
|
|
399
|
+
]),
|
|
400
|
+
) as Record<Option, ModelCapability>;
|
|
401
|
+
}
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
} from '@ai-sdk/provider-utils';
|
|
16
16
|
import { z } from 'zod/v4';
|
|
17
17
|
import { mistralFailedResponseHandler } from './mistral-error';
|
|
18
|
+
import { getMistralSpeechModelEntry } from './mistral-model-catalog';
|
|
18
19
|
import {
|
|
19
20
|
mistralSpeechModelOptions,
|
|
20
21
|
type MistralSpeechModelId,
|
|
@@ -74,8 +75,9 @@ export class MistralSpeechModel implements SpeechModelV4 {
|
|
|
74
75
|
schema: mistralSpeechModelOptions,
|
|
75
76
|
});
|
|
76
77
|
|
|
78
|
+
const { speech } = getMistralSpeechModelEntry(this.modelId).capabilities;
|
|
77
79
|
let responseFormat: MistralSpeechOutputFormat = 'mp3';
|
|
78
|
-
if (
|
|
80
|
+
if (speech.outputFormats.includes(outputFormat)) {
|
|
79
81
|
responseFormat = outputFormat as MistralSpeechOutputFormat;
|
|
80
82
|
} else {
|
|
81
83
|
warnings.push({
|
|
@@ -85,7 +87,7 @@ export class MistralSpeechModel implements SpeechModelV4 {
|
|
|
85
87
|
});
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
if (instructions != null) {
|
|
90
|
+
if (speech.instructions === false && instructions != null) {
|
|
89
91
|
warnings.push({
|
|
90
92
|
type: 'unsupported',
|
|
91
93
|
feature: 'instructions',
|
|
@@ -22,6 +22,7 @@ import {
|
|
|
22
22
|
} from '@ai-sdk/provider-utils';
|
|
23
23
|
import { z } from 'zod/v4';
|
|
24
24
|
import { mistralFailedResponseHandler } from './mistral-error';
|
|
25
|
+
import { getMistralTranscriptionModelEntry } from './mistral-model-catalog';
|
|
25
26
|
import {
|
|
26
27
|
mistralTranscriptionModelOptions,
|
|
27
28
|
type MistralTranscriptionModelId,
|
|
@@ -75,14 +76,9 @@ export class MistralTranscriptionModel implements TranscriptionModelV4 {
|
|
|
75
76
|
schema: mistralTranscriptionModelOptions,
|
|
76
77
|
});
|
|
77
78
|
|
|
78
|
-
// Restrict only known legacy models so future and custom models can combine
|
|
79
|
-
// a pinned language with timestamps without an SDK update.
|
|
80
79
|
if (
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
'voxtral-mini-2602',
|
|
84
|
-
'voxtral-mini-latest',
|
|
85
|
-
].includes(this.modelId) &&
|
|
80
|
+
!getMistralTranscriptionModelEntry(this.modelId).capabilities
|
|
81
|
+
.transcription.languageWithTimestamps &&
|
|
86
82
|
mistralOptions?.language != null &&
|
|
87
83
|
mistralOptions.timestampGranularities != null
|
|
88
84
|
) {
|