@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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.77
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 19cb252: Centralize Mistral model capabilities and provider option support in a model catalog shared by request preparation and generated documentation, preserving Chat and Conversations reasoning policies and legacy transcription restrictions.
|
|
8
|
+
|
|
9
|
+
## 4.0.76
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 7716e18: Support promises and synchronous or asynchronous callbacks in provider API key and token settings. Resolve credentials per authenticated request while preserving existing authentication behavior and synchronous credential serialization.
|
|
14
|
+
|
|
15
|
+
The experimental OpenAI Live `getServerWebSocketConfig()` method can now resolve asynchronously. Await its result before using the connection settings.
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [7716e18]
|
|
18
|
+
- Updated dependencies [5c247e9]
|
|
19
|
+
- Updated dependencies [dcd2f8d]
|
|
20
|
+
- @ai-sdk/provider-utils@5.0.72
|
|
21
|
+
- @ai-sdk/provider@4.0.35
|
|
22
|
+
|
|
3
23
|
## 4.0.75
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EmbeddingModelV4, LanguageModelV4, ProviderV4, SpeechModelV4, TranscriptionModelV4 } from "@ai-sdk/provider";
|
|
2
|
-
import { FetchFunction, InferSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { FetchFunction, InferSchema, Resolvable } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/mistral-chat-language-model-options.d.ts
|
|
5
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 & {});
|
|
@@ -137,7 +137,7 @@ interface MistralProviderSettings {
|
|
|
137
137
|
* API key that is being send using the `Authorization` header.
|
|
138
138
|
* It defaults to the `MISTRAL_API_KEY` environment variable.
|
|
139
139
|
*/
|
|
140
|
-
apiKey?: string
|
|
140
|
+
apiKey?: Resolvable<string>;
|
|
141
141
|
/**
|
|
142
142
|
* Custom headers to include in the requests.
|
|
143
143
|
*/
|
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;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;;;;;;;;;;;;;;;;;;;;;;
|
|
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;;;;;;;;;;;;;;;;;;;;;;UC0BI,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,SAAS;;;;EAKT,UAAU;;;;;EAMV,QAAQ;EAER;;;;;wBAMc,cACd,UAAS,0BACR;;;;qBA+FU,SAAO;;;KC5MR,0CACV;;;qBCZW"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { InvalidArgumentError, NoSuchModelError, TooManyEmbeddingValuesForCallError, UnsupportedFunctionalityError } from "@ai-sdk/provider";
|
|
2
|
-
import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderExecutedToolFactory, createToolNameMapping, generateId, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderEffort, mediaTypeToExtension, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, resolveFullMediaType, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
2
|
+
import { StreamingToolCallTracker, WORKFLOW_DESERIALIZE, WORKFLOW_SERIALIZE, combineHeaders, convertBase64ToUint8Array, convertToBase64, createEventSourceResponseHandler, createJsonErrorResponseHandler, createJsonResponseHandler, createLanguageModelResponseMetadata as getResponseMetadata, createNullLanguageModelUsage, createProviderExecutedToolFactory, createToolNameMapping, generateId, getTopLevelMediaType, injectJsonInstructionIntoMessages, isCustomReasoning, lazySchema, loadApiKey, mapReasoningToProviderEffort, mediaTypeToExtension, parseProviderOptions, postFormDataToApi, postJsonToApi, postToApi, resolve, resolveFullMediaType, resolveWith, serializeModelOptions, withUserAgentSuffix, withoutTrailingSlash, zodSchema } from "@ai-sdk/provider-utils";
|
|
3
3
|
import { z } from "zod/v4";
|
|
4
4
|
//#region src/convert-mistral-usage.ts
|
|
5
5
|
const mistralPromptTokensDetailsSchema = z.object({
|
|
@@ -292,7 +292,49 @@ function prepareTools({ tools, toolChoice }) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
//#endregion
|
|
295
|
-
//#region src/mistral-
|
|
295
|
+
//#region src/mistral-model-catalog.ts
|
|
296
|
+
const mistralProviderOptions = {
|
|
297
|
+
language: {
|
|
298
|
+
safePrompt: { description: "Inject a safety prompt. Chat API only." },
|
|
299
|
+
documentImageLimit: { description: "Maximum document images. Chat API only." },
|
|
300
|
+
documentPageLimit: { description: "Maximum document pages. Chat API only." },
|
|
301
|
+
structuredOutputs: { description: "Whether to send a JSON response schema." },
|
|
302
|
+
strictJsonSchema: { description: "Whether to use strict JSON schema validation." },
|
|
303
|
+
parallelToolCalls: { description: "Allow parallel function calls. Chat API only." },
|
|
304
|
+
promptCacheKey: { description: "Cache affinity key. Chat API only." },
|
|
305
|
+
reasoningEffort: { description: "Reasoning effort for configurable reasoning models." }
|
|
306
|
+
},
|
|
307
|
+
embedding: {
|
|
308
|
+
metadata: { description: "Metadata attached to the embedding request." },
|
|
309
|
+
outputDimension: { description: "Output embedding dimensions." },
|
|
310
|
+
outputDtype: { description: "Output embedding data type." }
|
|
311
|
+
},
|
|
312
|
+
transcription: {
|
|
313
|
+
language: { description: "Language of the audio." },
|
|
314
|
+
returnLanguage: { description: "Return the detected language." },
|
|
315
|
+
temperature: { description: "Sampling temperature." },
|
|
316
|
+
timestampGranularities: { description: "Timestamp granularities to return." },
|
|
317
|
+
diarize: { description: "Identify speakers in the transcription." },
|
|
318
|
+
contextBias: { description: "Vocabulary and context to guide transcription." }
|
|
319
|
+
},
|
|
320
|
+
speech: {
|
|
321
|
+
refAudio: { description: "Reference audio for voice cloning, overriding voice." },
|
|
322
|
+
expressiveness: { description: "Speech expressiveness, from 1 to 5." },
|
|
323
|
+
phonemeHints: { description: "Pronunciation hints as IPA phonemes." }
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
const documentedLanguageModels = {
|
|
327
|
+
"labs-leanstral-1-5": true,
|
|
328
|
+
"magistral-medium-latest": true,
|
|
329
|
+
"magistral-small-latest": true,
|
|
330
|
+
"ministral-14b-latest": true,
|
|
331
|
+
"ministral-8b-latest": true,
|
|
332
|
+
"mistral-large-latest": true,
|
|
333
|
+
"mistral-medium-latest": true,
|
|
334
|
+
"mistral-small-latest": true,
|
|
335
|
+
"voxtral-small-latest": false,
|
|
336
|
+
"zai-glm-5-2": false
|
|
337
|
+
};
|
|
296
338
|
const modelsWithoutReasoningEffort = /* @__PURE__ */ new Set([
|
|
297
339
|
"codestral-2508",
|
|
298
340
|
"codestral-latest",
|
|
@@ -315,6 +357,159 @@ const modelsWithLowHighMaxReasoningEffort = /* @__PURE__ */ new Set([
|
|
|
315
357
|
"zai-glm-5-3-flash",
|
|
316
358
|
"zai-glm-latest"
|
|
317
359
|
]);
|
|
360
|
+
const reasoningEffortModelIds = /* @__PURE__ */ new Set([
|
|
361
|
+
"glm-5-2",
|
|
362
|
+
"labs-leanstral-1-5",
|
|
363
|
+
"labs-leanstral-1-5-1",
|
|
364
|
+
"magistral-medium-latest",
|
|
365
|
+
"magistral-small-latest",
|
|
366
|
+
"mistral-large-4",
|
|
367
|
+
"mistral-large-4-0",
|
|
368
|
+
"mistral-medium",
|
|
369
|
+
"mistral-medium-2604",
|
|
370
|
+
"mistral-medium-3",
|
|
371
|
+
"mistral-medium-3-5",
|
|
372
|
+
"mistral-medium-3.5",
|
|
373
|
+
"mistral-medium-latest",
|
|
374
|
+
"mistral-small-2603",
|
|
375
|
+
"mistral-small-latest",
|
|
376
|
+
"mistral-vibe-cli-fast",
|
|
377
|
+
"mistral-vibe-cli-latest",
|
|
378
|
+
"mistral-vibe-cli-with-tools",
|
|
379
|
+
"zai-glm-5-2"
|
|
380
|
+
]);
|
|
381
|
+
function reasoningCapabilities(efforts) {
|
|
382
|
+
return {
|
|
383
|
+
support: efforts.length > 0,
|
|
384
|
+
efforts
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
function createLanguageModelEntry(modelId, image) {
|
|
388
|
+
const reasoning = reasoningCapabilities(modelsWithoutReasoningEffort.has(modelId) ? [] : modelsWithLowHighMaxReasoningEffort.has(modelId) ? [
|
|
389
|
+
"low",
|
|
390
|
+
"high",
|
|
391
|
+
"max"
|
|
392
|
+
] : ["none", "high"]);
|
|
393
|
+
const conversationReasoning = reasoningCapabilities(reasoningEffortModelIds.has(modelId) ? ["none", "high"] : []);
|
|
394
|
+
const chatOnly = { condition: "Only supported on the Chat API." };
|
|
395
|
+
return {
|
|
396
|
+
capabilities: { language: {
|
|
397
|
+
inputs: {
|
|
398
|
+
image: image ?? "unknown",
|
|
399
|
+
audio: "unknown"
|
|
400
|
+
},
|
|
401
|
+
objectGeneration: image != null ? true : "unknown",
|
|
402
|
+
tools: {
|
|
403
|
+
usage: image != null ? true : "unknown",
|
|
404
|
+
streaming: image != null ? true : "unknown"
|
|
405
|
+
},
|
|
406
|
+
reasoning,
|
|
407
|
+
sampling: {
|
|
408
|
+
temperature: "unknown",
|
|
409
|
+
topP: "unknown",
|
|
410
|
+
logprobs: false
|
|
411
|
+
},
|
|
412
|
+
endpoints: { conversation: { reasoning: conversationReasoning } }
|
|
413
|
+
} },
|
|
414
|
+
providerOptions: { language: declareProviderOptions(mistralProviderOptions.language, image != null ? true : "unknown", {
|
|
415
|
+
safePrompt: chatOnly,
|
|
416
|
+
documentImageLimit: chatOnly,
|
|
417
|
+
documentPageLimit: chatOnly,
|
|
418
|
+
parallelToolCalls: chatOnly,
|
|
419
|
+
promptCacheKey: chatOnly,
|
|
420
|
+
reasoningEffort: reasoning.support && !conversationReasoning.support ? chatOnly : reasoning.support
|
|
421
|
+
}) }
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
function createTranscriptionModelEntry(modelId, declared) {
|
|
425
|
+
const languageWithTimestamps = ![
|
|
426
|
+
"voxtral-mini-2507",
|
|
427
|
+
"voxtral-mini-2602",
|
|
428
|
+
"voxtral-mini-latest"
|
|
429
|
+
].includes(modelId);
|
|
430
|
+
const support = declared ? true : "unknown";
|
|
431
|
+
return {
|
|
432
|
+
capabilities: { transcription: {
|
|
433
|
+
transcription: support,
|
|
434
|
+
streaming: false,
|
|
435
|
+
duration: support,
|
|
436
|
+
segments: support,
|
|
437
|
+
language: support,
|
|
438
|
+
languageWithTimestamps,
|
|
439
|
+
timestamps: support,
|
|
440
|
+
diarization: support,
|
|
441
|
+
contextBias: support
|
|
442
|
+
} },
|
|
443
|
+
providerOptions: { transcription: declareProviderOptions(mistralProviderOptions.transcription, support, {
|
|
444
|
+
returnLanguage: { condition: "Only supported when language is not pinned." },
|
|
445
|
+
timestampGranularities: languageWithTimestamps ? support : { condition: "Only supported when language is not pinned." }
|
|
446
|
+
}) }
|
|
447
|
+
};
|
|
448
|
+
}
|
|
449
|
+
function createSpeechModelEntry(declared) {
|
|
450
|
+
const support = declared ? true : "unknown";
|
|
451
|
+
return {
|
|
452
|
+
capabilities: { speech: {
|
|
453
|
+
instructions: false,
|
|
454
|
+
savedVoices: support,
|
|
455
|
+
referenceAudio: support,
|
|
456
|
+
nonStreaming: true,
|
|
457
|
+
outputFormats: [
|
|
458
|
+
"pcm",
|
|
459
|
+
"wav",
|
|
460
|
+
"mp3",
|
|
461
|
+
"flac",
|
|
462
|
+
"opus"
|
|
463
|
+
]
|
|
464
|
+
} },
|
|
465
|
+
providerOptions: { speech: declareProviderOptions(mistralProviderOptions.speech, support, {}) }
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
function createEmbeddingModelEntry(defaultDimensions, customDimensions) {
|
|
469
|
+
return {
|
|
470
|
+
capabilities: { embedding: {
|
|
471
|
+
defaultDimensions,
|
|
472
|
+
customDimensions
|
|
473
|
+
} },
|
|
474
|
+
providerOptions: { embedding: declareProviderOptions(mistralProviderOptions.embedding, true, {
|
|
475
|
+
outputDimension: customDimensions,
|
|
476
|
+
outputDtype: customDimensions
|
|
477
|
+
}) }
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
const mistralModelCatalog = {
|
|
481
|
+
...Object.fromEntries(Object.entries(documentedLanguageModels).map(([modelId, image]) => [modelId, createLanguageModelEntry(modelId, image)])),
|
|
482
|
+
"voxtral-mini-transcribe-3-0": createTranscriptionModelEntry("voxtral-mini-transcribe-3-0", true),
|
|
483
|
+
"voxtral-small-transcribe-3-0": createTranscriptionModelEntry("voxtral-small-transcribe-3-0", true),
|
|
484
|
+
"voxtral-mini-latest": createTranscriptionModelEntry("voxtral-mini-latest", true),
|
|
485
|
+
"voxtral-mini-tts-3-0": createSpeechModelEntry(true),
|
|
486
|
+
"voxtral-mini-tts-2603": createSpeechModelEntry(true),
|
|
487
|
+
"mistral-embed": createEmbeddingModelEntry(1024, false),
|
|
488
|
+
"codestral-embed": createEmbeddingModelEntry(1536, true)
|
|
489
|
+
};
|
|
490
|
+
function findModelEntry(modelId) {
|
|
491
|
+
return Object.prototype.hasOwnProperty.call(mistralModelCatalog, modelId) ? mistralModelCatalog[modelId] : void 0;
|
|
492
|
+
}
|
|
493
|
+
function getMistralLanguageModelEntry(modelId) {
|
|
494
|
+
const entry = findModelEntry(modelId);
|
|
495
|
+
return entry?.capabilities.language != null && entry.providerOptions?.language != null ? {
|
|
496
|
+
capabilities: { language: entry.capabilities.language },
|
|
497
|
+
providerOptions: { language: entry.providerOptions.language }
|
|
498
|
+
} : createLanguageModelEntry(modelId);
|
|
499
|
+
}
|
|
500
|
+
function getMistralTranscriptionModelEntry(modelId) {
|
|
501
|
+
const capabilities = findModelEntry(modelId)?.capabilities.transcription;
|
|
502
|
+
return capabilities != null ? { capabilities: { transcription: capabilities } } : createTranscriptionModelEntry(modelId, false);
|
|
503
|
+
}
|
|
504
|
+
function getMistralSpeechModelEntry(modelId) {
|
|
505
|
+
const capabilities = findModelEntry(modelId)?.capabilities.speech;
|
|
506
|
+
return capabilities != null ? { capabilities: { speech: capabilities } } : createSpeechModelEntry(false);
|
|
507
|
+
}
|
|
508
|
+
function declareProviderOptions(definitions, support, exceptions) {
|
|
509
|
+
return Object.fromEntries(Object.keys(definitions).map((option) => [option, exceptions[option] ?? support]));
|
|
510
|
+
}
|
|
511
|
+
//#endregion
|
|
512
|
+
//#region src/mistral-chat-language-model.ts
|
|
318
513
|
var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
319
514
|
static [WORKFLOW_SERIALIZE](model) {
|
|
320
515
|
return serializeModelOptions({
|
|
@@ -346,24 +541,15 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
346
541
|
type: "unsupported",
|
|
347
542
|
feature: "topK"
|
|
348
543
|
});
|
|
349
|
-
const
|
|
544
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(this.modelId).capabilities.language;
|
|
350
545
|
let resolvedReasoningEffort;
|
|
351
|
-
if (
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
high: "high",
|
|
359
|
-
max: "max"
|
|
360
|
-
} : {
|
|
361
|
-
none: "none",
|
|
362
|
-
high: "high"
|
|
363
|
-
},
|
|
364
|
-
warnings
|
|
365
|
-
});
|
|
366
|
-
} else if (isCustomReasoning(reasoning)) warnings.push({
|
|
546
|
+
if (reasoningCapabilities.support) resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
547
|
+
reasoning,
|
|
548
|
+
providerOptionsEffort: options.reasoningEffort,
|
|
549
|
+
effortMap: Object.fromEntries(reasoningCapabilities.efforts.map((effort) => [effort, effort])),
|
|
550
|
+
warnings
|
|
551
|
+
});
|
|
552
|
+
else if (isCustomReasoning(reasoning)) warnings.push({
|
|
367
553
|
type: "unsupported",
|
|
368
554
|
feature: "reasoning",
|
|
369
555
|
details: "This model does not support reasoning configuration."
|
|
@@ -417,7 +603,7 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
417
603
|
const { args: body, warnings } = await this.getArgs(options);
|
|
418
604
|
const { responseHeaders, value: response, rawValue: rawResponse } = await postJsonToApi({
|
|
419
605
|
url: `${this.config.baseURL}/chat/completions`,
|
|
420
|
-
headers: combineHeaders(this.config.headers
|
|
606
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
421
607
|
body,
|
|
422
608
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
423
609
|
successfulResponseHandler: createJsonResponseHandler(mistralChatResponseSchema),
|
|
@@ -476,7 +662,7 @@ var MistralChatLanguageModel = class MistralChatLanguageModel {
|
|
|
476
662
|
};
|
|
477
663
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
478
664
|
url: `${this.config.baseURL}/chat/completions`,
|
|
479
|
-
headers: combineHeaders(this.config.headers
|
|
665
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
480
666
|
body,
|
|
481
667
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
482
668
|
successfulResponseHandler: createEventSourceResponseHandler(mistralChatChunkSchema),
|
|
@@ -875,27 +1061,6 @@ function prepareConversationTools({ tools, toolChoice }) {
|
|
|
875
1061
|
}
|
|
876
1062
|
//#endregion
|
|
877
1063
|
//#region src/mistral-conversation-language-model.ts
|
|
878
|
-
const reasoningEffortModelIds = /* @__PURE__ */ new Set([
|
|
879
|
-
"glm-5-2",
|
|
880
|
-
"labs-leanstral-1-5",
|
|
881
|
-
"labs-leanstral-1-5-1",
|
|
882
|
-
"magistral-medium-latest",
|
|
883
|
-
"magistral-small-latest",
|
|
884
|
-
"mistral-large-4",
|
|
885
|
-
"mistral-large-4-0",
|
|
886
|
-
"mistral-medium",
|
|
887
|
-
"mistral-medium-2604",
|
|
888
|
-
"mistral-medium-3",
|
|
889
|
-
"mistral-medium-3-5",
|
|
890
|
-
"mistral-medium-3.5",
|
|
891
|
-
"mistral-medium-latest",
|
|
892
|
-
"mistral-small-2603",
|
|
893
|
-
"mistral-small-latest",
|
|
894
|
-
"mistral-vibe-cli-fast",
|
|
895
|
-
"mistral-vibe-cli-latest",
|
|
896
|
-
"mistral-vibe-cli-with-tools",
|
|
897
|
-
"zai-glm-5-2"
|
|
898
|
-
]);
|
|
899
1064
|
var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
900
1065
|
static [WORKFLOW_SERIALIZE](model) {
|
|
901
1066
|
return serializeModelOptions({
|
|
@@ -927,15 +1092,12 @@ var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
|
927
1092
|
type: "unsupported",
|
|
928
1093
|
feature: "topK"
|
|
929
1094
|
});
|
|
930
|
-
const
|
|
1095
|
+
const { reasoning: reasoningCapabilities } = getMistralLanguageModelEntry(this.modelId).capabilities.language.endpoints.conversation;
|
|
931
1096
|
let resolvedReasoningEffort;
|
|
932
|
-
if (
|
|
1097
|
+
if (reasoningCapabilities.support) resolvedReasoningEffort = mapReasoningToProviderEffort({
|
|
933
1098
|
reasoning,
|
|
934
1099
|
providerOptionsEffort: options.reasoningEffort,
|
|
935
|
-
effortMap:
|
|
936
|
-
none: "none",
|
|
937
|
-
high: "high"
|
|
938
|
-
},
|
|
1100
|
+
effortMap: Object.fromEntries(reasoningCapabilities.efforts.map((effort) => [effort, effort])),
|
|
939
1101
|
warnings
|
|
940
1102
|
});
|
|
941
1103
|
else if (isCustomReasoning(reasoning)) warnings.push({
|
|
@@ -1004,7 +1166,7 @@ var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
|
1004
1166
|
const { args: body, warnings } = await this.getArgs(options);
|
|
1005
1167
|
const { value: response, rawValue: rawResponse, responseHeaders } = await postJsonToApi({
|
|
1006
1168
|
url: `${this.config.baseURL}/conversations`,
|
|
1007
|
-
headers: combineHeaders(this.config.headers
|
|
1169
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1008
1170
|
body,
|
|
1009
1171
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
1010
1172
|
successfulResponseHandler: createJsonResponseHandler(mistralConversationResponseSchema),
|
|
@@ -1063,7 +1225,7 @@ var MistralConversationLanguageModel = class MistralConversationLanguageModel {
|
|
|
1063
1225
|
};
|
|
1064
1226
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
1065
1227
|
url: `${this.config.baseURL}/conversations`,
|
|
1066
|
-
headers: combineHeaders(this.config.headers
|
|
1228
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1067
1229
|
body,
|
|
1068
1230
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
1069
1231
|
successfulResponseHandler: createEventSourceResponseHandler(mistralConversationChunkSchema),
|
|
@@ -1456,7 +1618,7 @@ var MistralEmbeddingModel = class MistralEmbeddingModel {
|
|
|
1456
1618
|
}) ?? {};
|
|
1457
1619
|
const { responseHeaders, value: response, rawValue } = await postJsonToApi({
|
|
1458
1620
|
url: `${this.config.baseURL}/embeddings`,
|
|
1459
|
-
headers: combineHeaders(this.config.headers
|
|
1621
|
+
headers: combineHeaders(await resolve(this.config.headers), headers),
|
|
1460
1622
|
body: {
|
|
1461
1623
|
model: this.modelId,
|
|
1462
1624
|
input: values,
|
|
@@ -1532,20 +1694,15 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1532
1694
|
providerOptions,
|
|
1533
1695
|
schema: mistralSpeechModelOptions
|
|
1534
1696
|
});
|
|
1697
|
+
const { speech } = getMistralSpeechModelEntry(this.modelId).capabilities;
|
|
1535
1698
|
let responseFormat = "mp3";
|
|
1536
|
-
if (
|
|
1537
|
-
"pcm",
|
|
1538
|
-
"wav",
|
|
1539
|
-
"mp3",
|
|
1540
|
-
"flac",
|
|
1541
|
-
"opus"
|
|
1542
|
-
].includes(outputFormat)) responseFormat = outputFormat;
|
|
1699
|
+
if (speech.outputFormats.includes(outputFormat)) responseFormat = outputFormat;
|
|
1543
1700
|
else warnings.push({
|
|
1544
1701
|
type: "unsupported",
|
|
1545
1702
|
feature: "outputFormat",
|
|
1546
1703
|
details: `Unsupported output format: ${outputFormat}. Using mp3 instead.`
|
|
1547
1704
|
});
|
|
1548
|
-
if (instructions != null) warnings.push({
|
|
1705
|
+
if (speech.instructions === false && instructions != null) warnings.push({
|
|
1549
1706
|
type: "unsupported",
|
|
1550
1707
|
feature: "instructions",
|
|
1551
1708
|
details: "Mistral speech models do not support the `instructions` option. Use a reference audio clip to guide delivery."
|
|
@@ -1585,7 +1742,7 @@ var MistralSpeechModel = class MistralSpeechModel {
|
|
|
1585
1742
|
const { requestBody, requestBodyValues, warnings } = await this.getArgs(options);
|
|
1586
1743
|
const { value: response, responseHeaders, rawValue: rawResponse } = await postToApi({
|
|
1587
1744
|
url: `${this.config.baseURL}/audio/speech`,
|
|
1588
|
-
headers: combineHeaders({ "Content-Type": "application/json" }, this.config.headers
|
|
1745
|
+
headers: combineHeaders({ "Content-Type": "application/json" }, await resolve(this.config.headers), options.headers),
|
|
1589
1746
|
body: {
|
|
1590
1747
|
content: JSON.stringify(requestBody),
|
|
1591
1748
|
values: requestBodyValues
|
|
@@ -1672,11 +1829,7 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
1672
1829
|
providerOptions,
|
|
1673
1830
|
schema: mistralTranscriptionModelOptions
|
|
1674
1831
|
});
|
|
1675
|
-
if (
|
|
1676
|
-
"voxtral-mini-2507",
|
|
1677
|
-
"voxtral-mini-2602",
|
|
1678
|
-
"voxtral-mini-latest"
|
|
1679
|
-
].includes(this.modelId) && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1832
|
+
if (!getMistralTranscriptionModelEntry(this.modelId).capabilities.transcription.languageWithTimestamps && mistralOptions?.language != null && mistralOptions.timestampGranularities != null) throw new InvalidArgumentError({
|
|
1680
1833
|
argument: "providerOptions",
|
|
1681
1834
|
message: "providerOptions.mistral.language cannot be combined with providerOptions.mistral.timestampGranularities"
|
|
1682
1835
|
});
|
|
@@ -1706,7 +1859,7 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
1706
1859
|
const { formData, warnings } = await this.getArgs(options);
|
|
1707
1860
|
const { value: response, responseHeaders, rawValue: rawResponse } = await postFormDataToApi({
|
|
1708
1861
|
url: `${this.config.baseURL}/audio/transcriptions`,
|
|
1709
|
-
headers: combineHeaders(this.config.headers
|
|
1862
|
+
headers: combineHeaders(await resolve(this.config.headers), options.headers),
|
|
1710
1863
|
formData,
|
|
1711
1864
|
failedResponseHandler: mistralFailedResponseHandler,
|
|
1712
1865
|
successfulResponseHandler: createJsonResponseHandler(mistralTranscriptionResponseSchema),
|
|
@@ -1782,7 +1935,7 @@ const mistralTranscriptionResponseSchema = lazySchema(() => zodSchema(z.object({
|
|
|
1782
1935
|
})));
|
|
1783
1936
|
//#endregion
|
|
1784
1937
|
//#region src/version.ts
|
|
1785
|
-
const VERSION = "4.0.
|
|
1938
|
+
const VERSION = "4.0.77";
|
|
1786
1939
|
//#endregion
|
|
1787
1940
|
//#region src/tool/web-search.ts
|
|
1788
1941
|
const inputSchema = lazySchema(() => zodSchema(z.object({ arguments: z.string() })));
|
|
@@ -1814,14 +1967,14 @@ const mistralTools = {
|
|
|
1814
1967
|
*/
|
|
1815
1968
|
function createMistral(options = {}) {
|
|
1816
1969
|
const baseURL = withoutTrailingSlash(options.baseURL) ?? "https://api.mistral.ai/v1";
|
|
1817
|
-
const getHeaders = () => withUserAgentSuffix({
|
|
1970
|
+
const getHeaders = () => resolveWith(options.apiKey, (apiKey) => withUserAgentSuffix({
|
|
1818
1971
|
Authorization: `Bearer ${loadApiKey({
|
|
1819
|
-
apiKey
|
|
1972
|
+
apiKey,
|
|
1820
1973
|
environmentVariableName: "MISTRAL_API_KEY",
|
|
1821
1974
|
description: "Mistral"
|
|
1822
1975
|
})}`,
|
|
1823
1976
|
...options.headers
|
|
1824
|
-
}, `ai-sdk-mistral/${VERSION}`);
|
|
1977
|
+
}, `ai-sdk-mistral/${VERSION}`));
|
|
1825
1978
|
const createChatModel = (modelId) => new MistralChatLanguageModel(modelId, {
|
|
1826
1979
|
provider: "mistral.chat",
|
|
1827
1980
|
baseURL,
|