@ai-sdk/mistral 4.0.55 → 4.0.56
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 +11 -0
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/mistral-transcription-model.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/mistral
|
|
2
2
|
|
|
3
|
+
## 4.0.56
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8c65988: feat(ai): add telemetry to speech generation and transcription, including
|
|
8
|
+
provider usage propagation and experimental streaming lifecycle callbacks
|
|
9
|
+
- Updated dependencies [8c65988]
|
|
10
|
+
- Updated dependencies [527a163]
|
|
11
|
+
- @ai-sdk/provider@4.0.21
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.53
|
|
13
|
+
|
|
3
14
|
## 4.0.55
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -988,6 +988,7 @@ var MistralTranscriptionModel = class MistralTranscriptionModel {
|
|
|
988
988
|
language: response.language ?? void 0,
|
|
989
989
|
durationInSeconds: response.usage?.prompt_audio_seconds ?? segments.at(-1)?.endSecond ?? void 0,
|
|
990
990
|
warnings,
|
|
991
|
+
...response.usage != null && { usage: response.usage },
|
|
991
992
|
response: {
|
|
992
993
|
timestamp: currentDate,
|
|
993
994
|
modelId: response.model,
|
|
@@ -1028,7 +1029,7 @@ const mistralTranscriptionResponseSchema = z.object({
|
|
|
1028
1029
|
});
|
|
1029
1030
|
//#endregion
|
|
1030
1031
|
//#region src/version.ts
|
|
1031
|
-
const VERSION = "4.0.
|
|
1032
|
+
const VERSION = "4.0.56";
|
|
1032
1033
|
//#endregion
|
|
1033
1034
|
//#region src/mistral-provider.ts
|
|
1034
1035
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["_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/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/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 { 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-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 = 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});\n\nexport type MistralLanguageModelChatOptions = z.infer<\n typeof mistralLanguageModelChatOptions\n>;\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralErrorDataSchema = 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\nexport type MistralErrorData = z.infer<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 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 mistralLanguageModelChatOptions,\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// https://api.mistral.ai/v1/models (2026-09-10)\nconst reasoningEffortModelIds = new Set<MistralChatModelId>([\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-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 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: mistralLanguageModelChatOptions,\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 },\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 let finishReason: LanguageModelV4FinishReason = {\n unified: 'other',\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<z.infer<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 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(content: z.infer<typeof mistralContentSchema>) {\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 = 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 = 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({ name: z.string(), arguments: z.string() }),\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// 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 = 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","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 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 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,\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 = z.object({\n data: z.array(z.object({ embedding: z.array(z.number()) })),\n usage: z.object({ prompt_tokens: z.number() }).nullish(),\n});\n","import { z } from 'zod/v4';\n\nexport type MistralSpeechModelId =\n | 'voxtral-mini-tts-2603'\n | 'voxtral-mini-tts-latest'\n | (string & {});\n\nexport const mistralSpeechModelOptions = 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\nexport type MistralSpeechModelOptions = z.infer<\n typeof mistralSpeechModelOptions\n>;\n","import type { SharedV4Warning, SpeechModelV4 } from '@ai-sdk/provider';\nimport {\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 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 = z.object({\n audio_data: z.string(),\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 | (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 * The sampling temperature.\n */\n temperature: z.number().optional(),\n\n /**\n * The timestamp granularities to include in the transcription response.\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 */\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 * Mistral requires each item to omit commas and whitespace. Use\n * underscores to represent multi-word phrases.\n */\n contextBias: z\n .array(\n z\n .string()\n .min(1)\n .regex(\n /^[^\\s,]+$/,\n 'Context bias items must not contain commas or whitespace.',\n ),\n )\n .max(100)\n .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 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 // Mistral documents these options as mutually incompatible. Rejecting the\n // combination locally provides a stable SDK error instead of an API 4xx.\n if (\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 const formData = new FormData();\n const blob =\n audio instanceof Uint8Array\n ? new Blob([audio])\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(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: {\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 = 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","// 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 {\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 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';\n\nexport interface MistralProvider extends ProviderV4 {\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 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 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.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,iCAAiC,QAAQ;CAC/D,2BAA2B,qCAAqC,QAAQ;AAC1E,CAAC,CAAC,CACD,SAAS,EAAE,KAAK,CAAC;AAIpB,SAAgB,oBACd,OACsB;CACtB,IAAI,SAAS,MACX,OAAO,6BAA6B;CAGtC,MAAM,eAAe,MAAM;CAC3B,MAAM,m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EACtD,IAAI,YACF,MAAM,IAAI,MACR,mEACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,YAAY;CACrB,SAAS,iBAAiB;CAC1B,SAAS,gBAAgB;CACzB,SAAS,qBAAqB;CAC9B,SAAS,SAAS;CAClB,SAAS,cAAc;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"}
|
|
1
|
+
{"version":3,"file":"index.js","names":["_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/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/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 { 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-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 = 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});\n\nexport type MistralLanguageModelChatOptions = z.infer<\n typeof mistralLanguageModelChatOptions\n>;\n","import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';\nimport { z } from 'zod/v4';\n\nconst mistralErrorDataSchema = 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\nexport type MistralErrorData = z.infer<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 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 mistralLanguageModelChatOptions,\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// https://api.mistral.ai/v1/models (2026-09-10)\nconst reasoningEffortModelIds = new Set<MistralChatModelId>([\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-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 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: mistralLanguageModelChatOptions,\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 },\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 let finishReason: LanguageModelV4FinishReason = {\n unified: 'other',\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<z.infer<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 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(content: z.infer<typeof mistralContentSchema>) {\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 = 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 = 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({ name: z.string(), arguments: z.string() }),\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// 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 = 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","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 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 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,\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 = z.object({\n data: z.array(z.object({ embedding: z.array(z.number()) })),\n usage: z.object({ prompt_tokens: z.number() }).nullish(),\n});\n","import { z } from 'zod/v4';\n\nexport type MistralSpeechModelId =\n | 'voxtral-mini-tts-2603'\n | 'voxtral-mini-tts-latest'\n | (string & {});\n\nexport const mistralSpeechModelOptions = 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\nexport type MistralSpeechModelOptions = z.infer<\n typeof mistralSpeechModelOptions\n>;\n","import type { SharedV4Warning, SpeechModelV4 } from '@ai-sdk/provider';\nimport {\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 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 = z.object({\n audio_data: z.string(),\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 | (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 * The sampling temperature.\n */\n temperature: z.number().optional(),\n\n /**\n * The timestamp granularities to include in the transcription response.\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 */\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 * Mistral requires each item to omit commas and whitespace. Use\n * underscores to represent multi-word phrases.\n */\n contextBias: z\n .array(\n z\n .string()\n .min(1)\n .regex(\n /^[^\\s,]+$/,\n 'Context bias items must not contain commas or whitespace.',\n ),\n )\n .max(100)\n .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 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 // Mistral documents these options as mutually incompatible. Rejecting the\n // combination locally provides a stable SDK error instead of an API 4xx.\n if (\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 const formData = new FormData();\n const blob =\n audio instanceof Uint8Array\n ? new Blob([audio])\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(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 = 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","// 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 {\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 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';\n\nexport interface MistralProvider extends ProviderV4 {\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 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 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.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;CA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AQ;CACb,GACA,kBAAkB,SACpB;CAEF,MAAM,mBAAmB,YACvB,IAAI,yBAAyB,SAAS;EACpC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;EACf,YAAY,QAAQ;CACtB,CAAC;CAEH,MAAM,wBAAwB,YAC5B,IAAI,sBAAsB,SAAS;EACjC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,qBAAqB,YACzB,IAAI,mBAAmB,SAAS;EAC9B,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,4BAA4B,YAChC,IAAI,0BAA0B,SAAS;EACrC,UAAU;EACV;EACA,SAAS;EACT,OAAO,QAAQ;CACjB,CAAC;CAEH,MAAM,WAAW,SAAU,SAA6B;EACtD,IAAI,YACF,MAAM,IAAI,MACR,mEACF;EAGF,OAAO,gBAAgB,OAAO;CAChC;CAEA,SAAS,uBAAuB;CAChC,SAAS,gBAAgB;CACzB,SAAS,OAAO;CAChB,SAAS,YAAY;CACrB,SAAS,iBAAiB;CAC1B,SAAS,gBAAgB;CACzB,SAAS,qBAAqB;CAC9B,SAAS,SAAS;CAClB,SAAS,cAAc;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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/mistral",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.56",
|
|
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.21",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.53"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@ai-sdk/test-server": "2.0.3",
|
|
@@ -194,6 +194,7 @@ export class MistralTranscriptionModel implements TranscriptionModelV4 {
|
|
|
194
194
|
segments.at(-1)?.endSecond ??
|
|
195
195
|
undefined,
|
|
196
196
|
warnings,
|
|
197
|
+
...(response.usage != null && { usage: response.usage }),
|
|
197
198
|
response: {
|
|
198
199
|
timestamp: currentDate,
|
|
199
200
|
modelId: response.model,
|