@ai-sdk/mistral 0.0.0-1c33ba03-20260114162300
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 +1775 -0
- package/LICENSE +13 -0
- package/README.md +35 -0
- package/dist/index.d.mts +78 -0
- package/dist/index.d.ts +78 -0
- package/dist/index.js +888 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +883 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Copyright 2023 Vercel, Inc.
|
|
2
|
+
|
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
you may not use this file except in compliance with the License.
|
|
5
|
+
You may obtain a copy of the License at
|
|
6
|
+
|
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
|
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
See the License for the specific language governing permissions and
|
|
13
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# AI SDK - Mistral Provider
|
|
2
|
+
|
|
3
|
+
The **[Mistral provider](https://ai-sdk.dev/providers/ai-sdk-providers/mistral)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the Mistral chat API.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
The Mistral provider is available in the `@ai-sdk/mistral` module. You can install it with
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm i @ai-sdk/mistral
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Provider Instance
|
|
14
|
+
|
|
15
|
+
You can import the default provider instance `mistral` from `@ai-sdk/mistral`:
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import { mistral } from '@ai-sdk/mistral';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Example
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
import { mistral } from '@ai-sdk/mistral';
|
|
25
|
+
import { generateText } from 'ai';
|
|
26
|
+
|
|
27
|
+
const { text } = await generateText({
|
|
28
|
+
model: mistral('mistral-large-latest'),
|
|
29
|
+
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
30
|
+
});
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Documentation
|
|
34
|
+
|
|
35
|
+
Please check out the **[Mistral provider](https://ai-sdk.dev/providers/ai-sdk-providers/mistral)** for more information.
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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 };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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 };
|