@ai-sdk/mistral 4.0.0-beta.3 → 4.0.0-beta.30

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.
@@ -2,26 +2,24 @@ import { z } from 'zod/v4';
2
2
 
3
3
  // https://docs.mistral.ai/getting-started/models/models_overview/
4
4
  export type MistralChatModelId =
5
- // premier
6
5
  | 'ministral-3b-latest'
7
6
  | 'ministral-8b-latest'
7
+ | 'ministral-14b-latest'
8
8
  | 'mistral-large-latest'
9
9
  | 'mistral-medium-latest'
10
+ | 'mistral-large-2512'
10
11
  | 'mistral-medium-2508'
11
12
  | 'mistral-medium-2505'
12
- | 'mistral-small-latest'
13
+ | 'mistral-small-2506'
13
14
  | 'pixtral-large-latest'
15
+ // reasoning config support models
16
+ | 'mistral-small-latest'
17
+ | 'mistral-small-2603'
14
18
  // reasoning models
15
- | 'magistral-small-2507'
16
- | 'magistral-medium-2507'
17
- | 'magistral-small-2506'
18
- | 'magistral-medium-2506'
19
- // free
20
- | 'pixtral-12b-2409'
21
- // legacy
22
- | 'open-mistral-7b'
23
- | 'open-mixtral-8x7b'
24
- | 'open-mixtral-8x22b'
19
+ | 'magistral-medium-latest'
20
+ | 'magistral-small-latest'
21
+ | 'magistral-medium-2509'
22
+ | 'magistral-small-2509'
25
23
  | (string & {});
26
24
 
27
25
  export const mistralLanguageModelOptions = z.object({
@@ -56,6 +54,14 @@ export const mistralLanguageModelOptions = z.object({
56
54
  * @default true
57
55
  */
58
56
  parallelToolCalls: z.boolean().optional(),
57
+
58
+ /**
59
+ * Controls the reasoning effort for models that support adjustable reasoning.
60
+ *
61
+ * - `'high'`: Enable reasoning
62
+ * - `'none'`: Disable reasoning
63
+ */
64
+ reasoningEffort: z.enum(['high', 'none']).optional(),
59
65
  });
60
66
 
61
67
  export type MistralLanguageModelOptions = z.infer<
@@ -1,5 +1,5 @@
1
1
  import {
2
- EmbeddingModelV3,
2
+ EmbeddingModelV4,
3
3
  TooManyEmbeddingValuesForCallError,
4
4
  } from '@ai-sdk/provider';
5
5
  import {
@@ -7,6 +7,9 @@ import {
7
7
  createJsonResponseHandler,
8
8
  FetchFunction,
9
9
  postJsonToApi,
10
+ serializeModelOptions,
11
+ WORKFLOW_SERIALIZE,
12
+ WORKFLOW_DESERIALIZE,
10
13
  } from '@ai-sdk/provider-utils';
11
14
  import { z } from 'zod/v4';
12
15
  import { MistralEmbeddingModelId } from './mistral-embedding-options';
@@ -15,12 +18,12 @@ import { mistralFailedResponseHandler } from './mistral-error';
15
18
  type MistralEmbeddingConfig = {
16
19
  provider: string;
17
20
  baseURL: string;
18
- headers: () => Record<string, string | undefined>;
21
+ headers?: () => Record<string, string | undefined>;
19
22
  fetch?: FetchFunction;
20
23
  };
21
24
 
22
- export class MistralEmbeddingModel implements EmbeddingModelV3 {
23
- readonly specificationVersion = 'v3';
25
+ export class MistralEmbeddingModel implements EmbeddingModelV4 {
26
+ readonly specificationVersion = 'v4';
24
27
  readonly modelId: MistralEmbeddingModelId;
25
28
  readonly maxEmbeddingsPerCall = 32;
26
29
  readonly supportsParallelCalls = false;
@@ -31,6 +34,20 @@ export class MistralEmbeddingModel implements EmbeddingModelV3 {
31
34
  return this.config.provider;
32
35
  }
33
36
 
37
+ static [WORKFLOW_SERIALIZE](model: MistralEmbeddingModel) {
38
+ return serializeModelOptions({
39
+ modelId: model.modelId,
40
+ config: model.config,
41
+ });
42
+ }
43
+
44
+ static [WORKFLOW_DESERIALIZE](options: {
45
+ modelId: MistralEmbeddingModelId;
46
+ config: MistralEmbeddingConfig;
47
+ }) {
48
+ return new MistralEmbeddingModel(options.modelId, options.config);
49
+ }
50
+
34
51
  constructor(
35
52
  modelId: MistralEmbeddingModelId,
36
53
  config: MistralEmbeddingConfig,
@@ -43,8 +60,8 @@ export class MistralEmbeddingModel implements EmbeddingModelV3 {
43
60
  values,
44
61
  abortSignal,
45
62
  headers,
46
- }: Parameters<EmbeddingModelV3['doEmbed']>[0]): Promise<
47
- Awaited<ReturnType<EmbeddingModelV3['doEmbed']>>
63
+ }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<
64
+ Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>
48
65
  > {
49
66
  if (values.length > this.maxEmbeddingsPerCall) {
50
67
  throw new TooManyEmbeddingValuesForCallError({
@@ -61,7 +78,7 @@ export class MistralEmbeddingModel implements EmbeddingModelV3 {
61
78
  rawValue,
62
79
  } = await postJsonToApi({
63
80
  url: `${this.config.baseURL}/embeddings`,
64
- headers: combineHeaders(this.config.headers(), headers),
81
+ headers: combineHeaders(this.config.headers?.(), headers),
65
82
  body: {
66
83
  model: this.modelId,
67
84
  input: values,
@@ -1,6 +1,6 @@
1
1
  import {
2
- LanguageModelV3CallOptions,
3
- SharedV3Warning,
2
+ LanguageModelV4CallOptions,
3
+ SharedV4Warning,
4
4
  UnsupportedFunctionalityError,
5
5
  } from '@ai-sdk/provider';
6
6
  import { MistralToolChoice } from './mistral-chat-prompt';
@@ -9,8 +9,8 @@ export function prepareTools({
9
9
  tools,
10
10
  toolChoice,
11
11
  }: {
12
- tools: LanguageModelV3CallOptions['tools'];
13
- toolChoice?: LanguageModelV3CallOptions['toolChoice'];
12
+ tools: LanguageModelV4CallOptions['tools'];
13
+ toolChoice?: LanguageModelV4CallOptions['toolChoice'];
14
14
  }): {
15
15
  tools:
16
16
  | Array<{
@@ -24,12 +24,12 @@ export function prepareTools({
24
24
  }>
25
25
  | undefined;
26
26
  toolChoice: MistralToolChoice | undefined;
27
- toolWarnings: SharedV3Warning[];
27
+ toolWarnings: SharedV4Warning[];
28
28
  } {
29
29
  // when the tools array is empty, change it to undefined to prevent errors:
30
30
  tools = tools?.length ? tools : undefined;
31
31
 
32
- const toolWarnings: SharedV3Warning[] = [];
32
+ const toolWarnings: SharedV4Warning[] = [];
33
33
 
34
34
  if (tools == null) {
35
35
  return { tools: undefined, toolChoice: undefined, toolWarnings };
@@ -1,8 +1,8 @@
1
1
  import {
2
- EmbeddingModelV3,
3
- LanguageModelV3,
2
+ EmbeddingModelV4,
3
+ LanguageModelV4,
4
4
  NoSuchModelError,
5
- ProviderV3,
5
+ ProviderV4,
6
6
  } from '@ai-sdk/provider';
7
7
  import {
8
8
  FetchFunction,
@@ -16,38 +16,38 @@ import { MistralEmbeddingModel } from './mistral-embedding-model';
16
16
  import { MistralEmbeddingModelId } from './mistral-embedding-options';
17
17
  import { VERSION } from './version';
18
18
 
19
- export interface MistralProvider extends ProviderV3 {
20
- (modelId: MistralChatModelId): LanguageModelV3;
19
+ export interface MistralProvider extends ProviderV4 {
20
+ (modelId: MistralChatModelId): LanguageModelV4;
21
21
 
22
22
  /**
23
23
  * Creates a model for text generation.
24
24
  */
25
- languageModel(modelId: MistralChatModelId): LanguageModelV3;
25
+ languageModel(modelId: MistralChatModelId): LanguageModelV4;
26
26
 
27
27
  /**
28
28
  * Creates a model for text generation.
29
29
  */
30
- chat(modelId: MistralChatModelId): LanguageModelV3;
30
+ chat(modelId: MistralChatModelId): LanguageModelV4;
31
31
 
32
32
  /**
33
33
  * Creates a model for text embeddings.
34
34
  */
35
- embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
35
+ embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
36
36
 
37
37
  /**
38
38
  * Creates a model for text embeddings.
39
39
  */
40
- embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV3;
40
+ embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV4;
41
41
 
42
42
  /**
43
43
  * @deprecated Use `embedding` instead.
44
44
  */
45
- textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
45
+ textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
46
46
 
47
47
  /**
48
48
  * @deprecated Use `embeddingModel` instead.
49
49
  */
50
- textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
50
+ textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV4;
51
51
  }
52
52
 
53
53
  export interface MistralProviderSettings {
@@ -126,7 +126,7 @@ export function createMistral(
126
126
  return createChatModel(modelId);
127
127
  };
128
128
 
129
- provider.specificationVersion = 'v3' as const;
129
+ provider.specificationVersion = 'v4' as const;
130
130
  provider.languageModel = createChatModel;
131
131
  provider.chat = createChatModel;
132
132
  provider.embedding = createEmbeddingModel;
package/dist/index.d.mts DELETED
@@ -1,78 +0,0 @@
1
- import { ProviderV3, LanguageModelV3, EmbeddingModelV3 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod/v4';
4
-
5
- type MistralChatModelId = 'ministral-3b-latest' | 'ministral-8b-latest' | 'mistral-large-latest' | 'mistral-medium-latest' | 'mistral-medium-2508' | 'mistral-medium-2505' | 'mistral-small-latest' | 'pixtral-large-latest' | 'magistral-small-2507' | 'magistral-medium-2507' | 'magistral-small-2506' | 'magistral-medium-2506' | 'pixtral-12b-2409' | 'open-mistral-7b' | 'open-mixtral-8x7b' | 'open-mixtral-8x22b' | (string & {});
6
- declare const mistralLanguageModelOptions: z.ZodObject<{
7
- safePrompt: z.ZodOptional<z.ZodBoolean>;
8
- documentImageLimit: z.ZodOptional<z.ZodNumber>;
9
- documentPageLimit: z.ZodOptional<z.ZodNumber>;
10
- structuredOutputs: z.ZodOptional<z.ZodBoolean>;
11
- strictJsonSchema: z.ZodOptional<z.ZodBoolean>;
12
- parallelToolCalls: z.ZodOptional<z.ZodBoolean>;
13
- }, z.core.$strip>;
14
- type MistralLanguageModelOptions = z.infer<typeof mistralLanguageModelOptions>;
15
-
16
- type MistralEmbeddingModelId = 'mistral-embed' | (string & {});
17
-
18
- interface MistralProvider extends ProviderV3 {
19
- (modelId: MistralChatModelId): LanguageModelV3;
20
- /**
21
- * Creates a model for text generation.
22
- */
23
- languageModel(modelId: MistralChatModelId): LanguageModelV3;
24
- /**
25
- * Creates a model for text generation.
26
- */
27
- chat(modelId: MistralChatModelId): LanguageModelV3;
28
- /**
29
- * Creates a model for text embeddings.
30
- */
31
- embedding(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
32
- /**
33
- * Creates a model for text embeddings.
34
- */
35
- embeddingModel: (modelId: MistralEmbeddingModelId) => EmbeddingModelV3;
36
- /**
37
- * @deprecated Use `embedding` instead.
38
- */
39
- textEmbedding(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
40
- /**
41
- * @deprecated Use `embeddingModel` instead.
42
- */
43
- textEmbeddingModel(modelId: MistralEmbeddingModelId): EmbeddingModelV3;
44
- }
45
- interface MistralProviderSettings {
46
- /**
47
- * Use a different URL prefix for API calls, e.g. to use proxy servers.
48
- * The default prefix is `https://api.mistral.ai/v1`.
49
- */
50
- baseURL?: string;
51
- /**
52
- * API key that is being send using the `Authorization` header.
53
- * It defaults to the `MISTRAL_API_KEY` environment variable.
54
- */
55
- apiKey?: string;
56
- /**
57
- * Custom headers to include in the requests.
58
- */
59
- headers?: Record<string, string>;
60
- /**
61
- * Custom fetch implementation. You can use it as a middleware to intercept requests,
62
- * or to provide a custom fetch implementation for e.g. testing.
63
- */
64
- fetch?: FetchFunction;
65
- generateId?: () => string;
66
- }
67
- /**
68
- * Create a Mistral AI provider instance.
69
- */
70
- declare function createMistral(options?: MistralProviderSettings): MistralProvider;
71
- /**
72
- * Default Mistral provider instance.
73
- */
74
- declare const mistral: MistralProvider;
75
-
76
- declare const VERSION: string;
77
-
78
- export { type MistralLanguageModelOptions, type MistralProvider, type MistralProviderSettings, VERSION, createMistral, mistral };