@ai-sdk/mistral 3.0.73 → 3.0.75

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.
@@ -1,3 +1,8 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
1
6
  import { z } from 'zod/v4';
2
7
 
3
8
  // https://docs.mistral.ai/getting-started/models/models_overview/
@@ -24,48 +29,52 @@ export type MistralChatModelId =
24
29
  | 'magistral-small-2509'
25
30
  | (string & {});
26
31
 
27
- export const mistralLanguageModelOptions = z.object({
28
- /**
29
- * Whether to inject a safety prompt before all conversations.
30
- *
31
- * Defaults to `false`.
32
- */
33
- safePrompt: z.boolean().optional(),
32
+ export const mistralLanguageModelOptions = lazySchema(() =>
33
+ zodSchema(
34
+ z.object({
35
+ /**
36
+ * Whether to inject a safety prompt before all conversations.
37
+ *
38
+ * Defaults to `false`.
39
+ */
40
+ safePrompt: z.boolean().optional(),
34
41
 
35
- documentImageLimit: z.number().optional(),
36
- documentPageLimit: z.number().optional(),
42
+ documentImageLimit: z.number().optional(),
43
+ documentPageLimit: z.number().optional(),
37
44
 
38
- /**
39
- * Whether to use structured outputs.
40
- *
41
- * @default true
42
- */
43
- structuredOutputs: z.boolean().optional(),
45
+ /**
46
+ * Whether to use structured outputs.
47
+ *
48
+ * @default true
49
+ */
50
+ structuredOutputs: z.boolean().optional(),
44
51
 
45
- /**
46
- * Whether to use strict JSON schema validation.
47
- *
48
- * @default false
49
- */
50
- strictJsonSchema: z.boolean().optional(),
52
+ /**
53
+ * Whether to use strict JSON schema validation.
54
+ *
55
+ * @default false
56
+ */
57
+ strictJsonSchema: z.boolean().optional(),
51
58
 
52
- /**
53
- * Whether to enable parallel function calling during tool use.
54
- * When set to false, the model will use at most one tool per response.
55
- *
56
- * @default true
57
- */
58
- parallelToolCalls: z.boolean().optional(),
59
+ /**
60
+ * Whether to enable parallel function calling during tool use.
61
+ * When set to false, the model will use at most one tool per response.
62
+ *
63
+ * @default true
64
+ */
65
+ parallelToolCalls: z.boolean().optional(),
59
66
 
60
- /**
61
- * Controls the reasoning effort for models that support adjustable reasoning.
62
- *
63
- * - `'high'`: Enable reasoning
64
- * - `'none'`: Disable reasoning
65
- */
66
- reasoningEffort: z.enum(['high', 'none']).optional(),
67
- });
67
+ /**
68
+ * Controls the reasoning effort for models that support adjustable reasoning.
69
+ *
70
+ * - `'high'`: Enable reasoning
71
+ * - `'none'`: Disable reasoning
72
+ */
73
+ reasoningEffort: z.enum(['high', 'none']).optional(),
74
+ }),
75
+ ),
76
+ );
68
77
 
69
- export type MistralLanguageModelOptions = z.infer<
78
+ export type MistralLanguageModelOptions = InferSchema<
70
79
  typeof mistralLanguageModelOptions
71
80
  >;
@@ -3,6 +3,8 @@ import {
3
3
  type EmbeddingModelV3,
4
4
  } from '@ai-sdk/provider';
5
5
  import {
6
+ lazySchema,
7
+ zodSchema,
6
8
  combineHeaders,
7
9
  createJsonResponseHandler,
8
10
  postJsonToApi,
@@ -88,7 +90,11 @@ export class MistralEmbeddingModel implements EmbeddingModelV3 {
88
90
 
89
91
  // minimal version of the schema, focussed on what is needed for the implementation
90
92
  // this approach limits breakages when the API changes and increases efficiency
91
- const MistralTextEmbeddingResponseSchema = z.object({
92
- data: z.array(z.object({ embedding: z.array(z.number()) })),
93
- usage: z.object({ prompt_tokens: z.number() }).nullish(),
94
- });
93
+ const MistralTextEmbeddingResponseSchema = lazySchema(() =>
94
+ zodSchema(
95
+ z.object({
96
+ data: z.array(z.object({ embedding: z.array(z.number()) })),
97
+ usage: z.object({ prompt_tokens: z.number() }).nullish(),
98
+ }),
99
+ ),
100
+ );
@@ -1,15 +1,24 @@
1
- import { createJsonErrorResponseHandler } from '@ai-sdk/provider-utils';
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ createJsonErrorResponseHandler,
6
+ } from '@ai-sdk/provider-utils';
2
7
  import { z } from 'zod/v4';
3
8
 
4
- const mistralErrorDataSchema = z.object({
5
- object: z.literal('error'),
6
- message: z.string(),
7
- type: z.string(),
8
- param: z.string().nullable(),
9
- code: z.string().nullable(),
10
- });
9
+ const mistralErrorDataSchema = lazySchema(() =>
10
+ zodSchema(
11
+ z.object({
12
+ object: z.literal('error'),
13
+ message: z.string(),
14
+ type: z.string(),
15
+ param: z.string().nullable(),
16
+ code: z.string().nullable(),
17
+ }),
18
+ ),
19
+ );
11
20
 
12
- export type MistralErrorData = z.infer<typeof mistralErrorDataSchema>;
21
+ export type MistralErrorData = InferSchema<typeof mistralErrorDataSchema>;
13
22
 
14
23
  export const mistralFailedResponseHandler = createJsonErrorResponseHandler({
15
24
  errorSchema: mistralErrorDataSchema,
@@ -1,16 +1,25 @@
1
+ import {
2
+ lazySchema,
3
+ zodSchema,
4
+ type InferSchema,
5
+ } from '@ai-sdk/provider-utils';
1
6
  import { z } from 'zod/v4';
2
7
 
3
8
  export type MistralSpeechModelId = 'voxtral-mini-tts-2603' | (string & {});
4
9
 
5
- export const mistralSpeechModelOptions = z.object({
6
- /**
7
- * Base64-encoded reference audio for one-off voice cloning.
8
- *
9
- * When provided, this takes precedence over the standard `voice` option.
10
- */
11
- refAudio: z.string().min(1).optional(),
12
- });
10
+ export const mistralSpeechModelOptions = lazySchema(() =>
11
+ zodSchema(
12
+ z.object({
13
+ /**
14
+ * Base64-encoded reference audio for one-off voice cloning.
15
+ *
16
+ * When provided, this takes precedence over the standard `voice` option.
17
+ */
18
+ refAudio: z.string().min(1).optional(),
19
+ }),
20
+ ),
21
+ );
13
22
 
14
- export type MistralSpeechModelOptions = z.infer<
23
+ export type MistralSpeechModelOptions = InferSchema<
15
24
  typeof mistralSpeechModelOptions
16
25
  >;
@@ -1,5 +1,7 @@
1
1
  import type { SharedV3Warning, SpeechModelV3 } from '@ai-sdk/provider';
2
2
  import {
3
+ lazySchema,
4
+ zodSchema,
3
5
  combineHeaders,
4
6
  createJsonResponseHandler,
5
7
  parseProviderOptions,
@@ -157,6 +159,10 @@ export class MistralSpeechModel implements SpeechModelV3 {
157
159
  }
158
160
  }
159
161
 
160
- const mistralSpeechResponseSchema = z.object({
161
- audio_data: z.string(),
162
- });
162
+ const mistralSpeechResponseSchema = lazySchema(() =>
163
+ zodSchema(
164
+ z.object({
165
+ audio_data: z.string(),
166
+ }),
167
+ ),
168
+ );