@friendliai/ai-provider 0.3.2 → 1.0.0-beta.1

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 CHANGED
@@ -1,5 +1,38 @@
1
1
  # @friendliai/ai-provider
2
2
 
3
+ ## 1.0.0-beta.1
4
+
5
+ ### Minor Changes
6
+
7
+ - 2ffbb78: ### Provider Tools Improvements
8
+ - **Renamed tool functions** for cleaner API:
9
+ - `webSearchBetaTool()` → `webSearch()`
10
+ - `webUrlBetaTool()` → `webUrl()`
11
+ - `mathCalendarBetaTool()` → `mathCalendar()`
12
+ - `mathStatisticsBetaTool()` → `mathStatistics()`
13
+ - `mathCalculatorBetaTool()` → `mathCalculator()`
14
+ - `codePythonInterpreterBetaTool()` → `codePythonInterpreter()`
15
+ - **Added streaming support for provider-executed tools**: Tool calls and results from Friendli's built-in tools (web search, calculator, etc.) are now properly streamed, allowing users to see tool execution progress in real-time.
16
+ - **Fixed tool type compatibility**: Provider tools now correctly implement the AI SDK `Tool` type with `inputSchema`, resolving type errors when using `friendli.tools.*` with `generateText` or `streamText`.
17
+
18
+ ## 1.0.0-beta.0
19
+
20
+ ### Major Changes
21
+
22
+ - 3044ef8: Entering the AI ​​SDK v6 compatible migration
23
+
24
+ ## 0.3.4
25
+
26
+ ### Patch Changes
27
+
28
+ - 795d5bf: add minimax-m2 in FSE
29
+
30
+ ## 0.3.3
31
+
32
+ ### Patch Changes
33
+
34
+ - a6180ef: add deepseek v3.1 in FSE
35
+
3
36
  ## 0.3.2
4
37
 
5
38
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,11 +1,65 @@
1
- import { LanguageModelV2ProviderDefinedTool, ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod';
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV3, SpeechModelV3 } from '@ai-sdk/provider';
3
+ import { Tool, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- declare const FriendliAIServerlessModelIds: readonly ["LGAI-EXAONE/EXAONE-4.0.1-32B", "skt/A.X-4.0", "skt/A.X-3.1", "naver-hyperclovax/HyperCLOVAX-SEED-Think-14B", "deepseek-ai/DeepSeek-R1-0528", "meta-llama/Llama-4-Maverick-17B-128E-Instruct", "meta-llama/Llama-4-Scout-17B-16E-Instruct", "meta-llama/Llama-3.3-70B-Instruct", "meta-llama-3.3-70b-instruct", "meta-llama/Llama-3.1-8B-Instruct", "meta-llama-3.1-8b-instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507", "Qwen/Qwen3-235B-A22B-Instruct-2507", "Qwen/Qwen3-30B-A3B", "Qwen/Qwen3-32B", "google/gemma-3-27b-it", "mistralai/Mistral-Small-3.1-24B-Instruct-2503", "mistralai/Devstral-Small-2505", "mistralai/Magistral-Small-2506"];
5
+ declare const friendliaiErrorSchema: z.ZodObject<{
6
+ message: z.ZodString;
7
+ error: z.ZodRecord<z.ZodString, z.ZodAny>;
8
+ }, z.core.$strip>;
9
+ type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
10
+
11
+ declare const FriendliAIServerlessModelIds: readonly ["MiniMaxAI/MiniMax-M2", "zai-org/GLM-4.6", "LGAI-EXAONE/EXAONE-4.0.1-32B", "skt/A.X-4.0", "skt/A.X-3.1", "naver-hyperclovax/HyperCLOVAX-SEED-Think-14B", "deepseek-ai/DeepSeek-V3.1", "deepseek-ai/DeepSeek-R1-0528", "meta-llama/Llama-4-Maverick-17B-128E-Instruct", "meta-llama/Llama-4-Scout-17B-16E-Instruct", "meta-llama/Llama-3.3-70B-Instruct", "meta-llama-3.3-70b-instruct", "meta-llama/Llama-3.1-8B-Instruct", "meta-llama-3.1-8b-instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507", "Qwen/Qwen3-235B-A22B-Instruct-2507", "Qwen/Qwen3-30B-A3B", "Qwen/Qwen3-32B", "google/gemma-3-27b-it", "mistralai/Mistral-Small-3.1-24B-Instruct-2503", "mistralai/Devstral-Small-2505", "mistralai/Magistral-Small-2506"];
6
12
  type FriendliAIServerlessModelId = (typeof FriendliAIServerlessModelIds)[number];
7
13
  type FriendliAILanguageModelId = FriendliAIServerlessModelId | (string & {});
8
14
 
15
+ /**
16
+ * Friendli built-in tools for serverless tool-assisted API.
17
+ *
18
+ * @remarks
19
+ * These tools are currently in **Beta**. While we strive to provide a stable
20
+ * and reliable experience, this feature is still under active development.
21
+ *
22
+ * @see https://friendli.ai/docs/guides/serverless_endpoints/tool-assisted-api
23
+ */
24
+ /**
25
+ * Web search tool - searches the web for information.
26
+ * @beta
27
+ */
28
+ declare function webSearch(): Tool;
29
+ /**
30
+ * Web URL tool - fetches content from a specific URL.
31
+ * @beta
32
+ */
33
+ declare function webUrl(): Tool;
34
+ /**
35
+ * Math calendar tool - performs calendar-related calculations.
36
+ * @beta
37
+ */
38
+ declare function mathCalendar(): Tool;
39
+ /**
40
+ * Math statistics tool - performs statistical calculations.
41
+ * @beta
42
+ */
43
+ declare function mathStatistics(): Tool;
44
+ /**
45
+ * Math calculator tool - performs arithmetic calculations.
46
+ * @beta
47
+ */
48
+ declare function mathCalculator(): Tool;
49
+ /**
50
+ * Python interpreter tool - executes Python code.
51
+ * @beta
52
+ */
53
+ declare function codePythonInterpreter(): Tool;
54
+ declare const friendliTools: {
55
+ webSearch: typeof webSearch;
56
+ webUrl: typeof webUrl;
57
+ mathCalendar: typeof mathCalendar;
58
+ mathStatistics: typeof mathStatistics;
59
+ mathCalculator: typeof mathCalculator;
60
+ codePythonInterpreter: typeof codePythonInterpreter;
61
+ };
62
+
9
63
  type Pricing = {
10
64
  inputToken?: number;
11
65
  outputToken?: number;
@@ -27,21 +81,6 @@ type FriendliAvailableModelsResponse = {
27
81
  models: FriendliAvailableModel[];
28
82
  };
29
83
 
30
- declare function webUrlBetaTool(): LanguageModelV2ProviderDefinedTool;
31
- declare function webSearchBetaTool(): LanguageModelV2ProviderDefinedTool;
32
- declare function mathCalendarBetaTool(): LanguageModelV2ProviderDefinedTool;
33
- declare function mathStatisticsBetaTool(): LanguageModelV2ProviderDefinedTool;
34
- declare function mathCalculatorBetaTool(): LanguageModelV2ProviderDefinedTool;
35
- declare function codePythonInterpreterBetaTool(): LanguageModelV2ProviderDefinedTool;
36
- declare const friendliTools: {
37
- webSearchBetaTool: typeof webSearchBetaTool;
38
- webUrlBetaTool: typeof webUrlBetaTool;
39
- mathCalendarBetaTool: typeof mathCalendarBetaTool;
40
- mathStatisticsBetaTool: typeof mathStatisticsBetaTool;
41
- mathCalculatorBetaTool: typeof mathCalculatorBetaTool;
42
- codePythonInterpreterBetaTool: typeof codePythonInterpreterBetaTool;
43
- };
44
-
45
84
  interface FriendliAIProviderSettings {
46
85
  /**
47
86
  * FriendliAI API key. (FRIENDLI_TOKEN)
@@ -65,52 +104,52 @@ interface FriendliAIProviderSettings {
65
104
  */
66
105
  fetch?: FetchFunction;
67
106
  }
68
- interface FriendliAIProvider extends ProviderV2 {
107
+ interface FriendliAIProvider extends ProviderV3 {
69
108
  /**
70
109
  * Creates a model for text generation.
71
110
  */
72
- (modelId: FriendliAILanguageModelId): LanguageModelV2;
111
+ (modelId: FriendliAILanguageModelId): LanguageModelV3;
73
112
  /**
74
113
  * Creates a chat model for text generation.
75
114
  */
76
- languageModel(modelId: FriendliAILanguageModelId): LanguageModelV2;
115
+ languageModel(modelId: FriendliAILanguageModelId): LanguageModelV3;
77
116
  /**
78
117
  * Creates a chat model for text generation.
79
118
  */
80
- chat(modelId: FriendliAILanguageModelId): LanguageModelV2;
119
+ chat(modelId: FriendliAILanguageModelId): LanguageModelV3;
81
120
  /**
82
121
  * Creates a completion model for text generation.
83
122
  */
84
- completion(modelId: FriendliAILanguageModelId): LanguageModelV2;
123
+ completion(modelId: FriendliAILanguageModelId): LanguageModelV3;
85
124
  /**
86
- * Creates a text embedding model for text generation.
125
+ * Creates an embedding model for text generation.
87
126
  * TODO: Implement for Dedicated users
88
127
  */
89
- embedding(modelId: string & {}): LanguageModelV2;
90
- textEmbeddingModel(modelId: string & {}): LanguageModelV2;
128
+ embedding(modelId: string & {}): LanguageModelV3;
129
+ embeddingModel(modelId: string & {}): LanguageModelV3;
91
130
  /**
92
131
  * Returns the available models and their metadata.
93
132
  */
94
133
  getAvailableModels(options?: {
95
134
  graphqlURL?: string;
96
135
  }): Promise<FriendliAvailableModelsResponse>;
97
- embedding(modelId: string & {}): EmbeddingModelV2<string>;
98
- textEmbeddingModel(modelId: string & {}): EmbeddingModelV2<string>;
136
+ embedding(modelId: string & {}): EmbeddingModelV3;
137
+ embeddingModel(modelId: string & {}): EmbeddingModelV3;
99
138
  /**
100
139
  * Creates a model for image generation.
101
140
  * TODO: Implement for Dedicated users
102
141
  */
103
- imageModel(modelId: string & {}): ImageModelV2;
142
+ imageModel(modelId: string & {}): ImageModelV3;
104
143
  /**
105
144
  * Creates a model for transcription.
106
145
  * TODO: Implement for Dedicated users
107
146
  */
108
- transcription(modelId: string & {}): TranscriptionModelV2;
147
+ transcription(modelId: string & {}): TranscriptionModelV3;
109
148
  /**
110
149
  * Creates a model for speech generation.
111
150
  * TODO: Implement for Dedicated users
112
151
  */
113
- speech(modelId: string & {}): SpeechModelV2;
152
+ speech(modelId: string & {}): SpeechModelV3;
114
153
  /**
115
154
  * Friendli-specific tools.
116
155
  */
@@ -125,10 +164,4 @@ declare function createFriendli(options?: FriendliAIProviderSettings): FriendliA
125
164
  */
126
165
  declare const friendli: FriendliAIProvider;
127
166
 
128
- declare const friendliaiErrorSchema: z.ZodObject<{
129
- message: z.ZodString;
130
- error: z.ZodRecord<z.ZodString, z.ZodAny>;
131
- }, z.core.$strip>;
132
- type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
133
-
134
167
  export { type FriendliAIErrorData, type FriendliAIProvider, type FriendliAIProviderSettings, type FriendliAvailableModel, type FriendliAvailableModelsResponse, createFriendli, friendli };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,65 @@
1
- import { LanguageModelV2ProviderDefinedTool, ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
2
- import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod';
1
+ import { z } from 'zod/v4';
2
+ import { ProviderV3, LanguageModelV3, EmbeddingModelV3, ImageModelV3, TranscriptionModelV3, SpeechModelV3 } from '@ai-sdk/provider';
3
+ import { Tool, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
- declare const FriendliAIServerlessModelIds: readonly ["LGAI-EXAONE/EXAONE-4.0.1-32B", "skt/A.X-4.0", "skt/A.X-3.1", "naver-hyperclovax/HyperCLOVAX-SEED-Think-14B", "deepseek-ai/DeepSeek-R1-0528", "meta-llama/Llama-4-Maverick-17B-128E-Instruct", "meta-llama/Llama-4-Scout-17B-16E-Instruct", "meta-llama/Llama-3.3-70B-Instruct", "meta-llama-3.3-70b-instruct", "meta-llama/Llama-3.1-8B-Instruct", "meta-llama-3.1-8b-instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507", "Qwen/Qwen3-235B-A22B-Instruct-2507", "Qwen/Qwen3-30B-A3B", "Qwen/Qwen3-32B", "google/gemma-3-27b-it", "mistralai/Mistral-Small-3.1-24B-Instruct-2503", "mistralai/Devstral-Small-2505", "mistralai/Magistral-Small-2506"];
5
+ declare const friendliaiErrorSchema: z.ZodObject<{
6
+ message: z.ZodString;
7
+ error: z.ZodRecord<z.ZodString, z.ZodAny>;
8
+ }, z.core.$strip>;
9
+ type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
10
+
11
+ declare const FriendliAIServerlessModelIds: readonly ["MiniMaxAI/MiniMax-M2", "zai-org/GLM-4.6", "LGAI-EXAONE/EXAONE-4.0.1-32B", "skt/A.X-4.0", "skt/A.X-3.1", "naver-hyperclovax/HyperCLOVAX-SEED-Think-14B", "deepseek-ai/DeepSeek-V3.1", "deepseek-ai/DeepSeek-R1-0528", "meta-llama/Llama-4-Maverick-17B-128E-Instruct", "meta-llama/Llama-4-Scout-17B-16E-Instruct", "meta-llama/Llama-3.3-70B-Instruct", "meta-llama-3.3-70b-instruct", "meta-llama/Llama-3.1-8B-Instruct", "meta-llama-3.1-8b-instruct", "Qwen/Qwen3-235B-A22B-Thinking-2507", "Qwen/Qwen3-235B-A22B-Instruct-2507", "Qwen/Qwen3-30B-A3B", "Qwen/Qwen3-32B", "google/gemma-3-27b-it", "mistralai/Mistral-Small-3.1-24B-Instruct-2503", "mistralai/Devstral-Small-2505", "mistralai/Magistral-Small-2506"];
6
12
  type FriendliAIServerlessModelId = (typeof FriendliAIServerlessModelIds)[number];
7
13
  type FriendliAILanguageModelId = FriendliAIServerlessModelId | (string & {});
8
14
 
15
+ /**
16
+ * Friendli built-in tools for serverless tool-assisted API.
17
+ *
18
+ * @remarks
19
+ * These tools are currently in **Beta**. While we strive to provide a stable
20
+ * and reliable experience, this feature is still under active development.
21
+ *
22
+ * @see https://friendli.ai/docs/guides/serverless_endpoints/tool-assisted-api
23
+ */
24
+ /**
25
+ * Web search tool - searches the web for information.
26
+ * @beta
27
+ */
28
+ declare function webSearch(): Tool;
29
+ /**
30
+ * Web URL tool - fetches content from a specific URL.
31
+ * @beta
32
+ */
33
+ declare function webUrl(): Tool;
34
+ /**
35
+ * Math calendar tool - performs calendar-related calculations.
36
+ * @beta
37
+ */
38
+ declare function mathCalendar(): Tool;
39
+ /**
40
+ * Math statistics tool - performs statistical calculations.
41
+ * @beta
42
+ */
43
+ declare function mathStatistics(): Tool;
44
+ /**
45
+ * Math calculator tool - performs arithmetic calculations.
46
+ * @beta
47
+ */
48
+ declare function mathCalculator(): Tool;
49
+ /**
50
+ * Python interpreter tool - executes Python code.
51
+ * @beta
52
+ */
53
+ declare function codePythonInterpreter(): Tool;
54
+ declare const friendliTools: {
55
+ webSearch: typeof webSearch;
56
+ webUrl: typeof webUrl;
57
+ mathCalendar: typeof mathCalendar;
58
+ mathStatistics: typeof mathStatistics;
59
+ mathCalculator: typeof mathCalculator;
60
+ codePythonInterpreter: typeof codePythonInterpreter;
61
+ };
62
+
9
63
  type Pricing = {
10
64
  inputToken?: number;
11
65
  outputToken?: number;
@@ -27,21 +81,6 @@ type FriendliAvailableModelsResponse = {
27
81
  models: FriendliAvailableModel[];
28
82
  };
29
83
 
30
- declare function webUrlBetaTool(): LanguageModelV2ProviderDefinedTool;
31
- declare function webSearchBetaTool(): LanguageModelV2ProviderDefinedTool;
32
- declare function mathCalendarBetaTool(): LanguageModelV2ProviderDefinedTool;
33
- declare function mathStatisticsBetaTool(): LanguageModelV2ProviderDefinedTool;
34
- declare function mathCalculatorBetaTool(): LanguageModelV2ProviderDefinedTool;
35
- declare function codePythonInterpreterBetaTool(): LanguageModelV2ProviderDefinedTool;
36
- declare const friendliTools: {
37
- webSearchBetaTool: typeof webSearchBetaTool;
38
- webUrlBetaTool: typeof webUrlBetaTool;
39
- mathCalendarBetaTool: typeof mathCalendarBetaTool;
40
- mathStatisticsBetaTool: typeof mathStatisticsBetaTool;
41
- mathCalculatorBetaTool: typeof mathCalculatorBetaTool;
42
- codePythonInterpreterBetaTool: typeof codePythonInterpreterBetaTool;
43
- };
44
-
45
84
  interface FriendliAIProviderSettings {
46
85
  /**
47
86
  * FriendliAI API key. (FRIENDLI_TOKEN)
@@ -65,52 +104,52 @@ interface FriendliAIProviderSettings {
65
104
  */
66
105
  fetch?: FetchFunction;
67
106
  }
68
- interface FriendliAIProvider extends ProviderV2 {
107
+ interface FriendliAIProvider extends ProviderV3 {
69
108
  /**
70
109
  * Creates a model for text generation.
71
110
  */
72
- (modelId: FriendliAILanguageModelId): LanguageModelV2;
111
+ (modelId: FriendliAILanguageModelId): LanguageModelV3;
73
112
  /**
74
113
  * Creates a chat model for text generation.
75
114
  */
76
- languageModel(modelId: FriendliAILanguageModelId): LanguageModelV2;
115
+ languageModel(modelId: FriendliAILanguageModelId): LanguageModelV3;
77
116
  /**
78
117
  * Creates a chat model for text generation.
79
118
  */
80
- chat(modelId: FriendliAILanguageModelId): LanguageModelV2;
119
+ chat(modelId: FriendliAILanguageModelId): LanguageModelV3;
81
120
  /**
82
121
  * Creates a completion model for text generation.
83
122
  */
84
- completion(modelId: FriendliAILanguageModelId): LanguageModelV2;
123
+ completion(modelId: FriendliAILanguageModelId): LanguageModelV3;
85
124
  /**
86
- * Creates a text embedding model for text generation.
125
+ * Creates an embedding model for text generation.
87
126
  * TODO: Implement for Dedicated users
88
127
  */
89
- embedding(modelId: string & {}): LanguageModelV2;
90
- textEmbeddingModel(modelId: string & {}): LanguageModelV2;
128
+ embedding(modelId: string & {}): LanguageModelV3;
129
+ embeddingModel(modelId: string & {}): LanguageModelV3;
91
130
  /**
92
131
  * Returns the available models and their metadata.
93
132
  */
94
133
  getAvailableModels(options?: {
95
134
  graphqlURL?: string;
96
135
  }): Promise<FriendliAvailableModelsResponse>;
97
- embedding(modelId: string & {}): EmbeddingModelV2<string>;
98
- textEmbeddingModel(modelId: string & {}): EmbeddingModelV2<string>;
136
+ embedding(modelId: string & {}): EmbeddingModelV3;
137
+ embeddingModel(modelId: string & {}): EmbeddingModelV3;
99
138
  /**
100
139
  * Creates a model for image generation.
101
140
  * TODO: Implement for Dedicated users
102
141
  */
103
- imageModel(modelId: string & {}): ImageModelV2;
142
+ imageModel(modelId: string & {}): ImageModelV3;
104
143
  /**
105
144
  * Creates a model for transcription.
106
145
  * TODO: Implement for Dedicated users
107
146
  */
108
- transcription(modelId: string & {}): TranscriptionModelV2;
147
+ transcription(modelId: string & {}): TranscriptionModelV3;
109
148
  /**
110
149
  * Creates a model for speech generation.
111
150
  * TODO: Implement for Dedicated users
112
151
  */
113
- speech(modelId: string & {}): SpeechModelV2;
152
+ speech(modelId: string & {}): SpeechModelV3;
114
153
  /**
115
154
  * Friendli-specific tools.
116
155
  */
@@ -125,10 +164,4 @@ declare function createFriendli(options?: FriendliAIProviderSettings): FriendliA
125
164
  */
126
165
  declare const friendli: FriendliAIProvider;
127
166
 
128
- declare const friendliaiErrorSchema: z.ZodObject<{
129
- message: z.ZodString;
130
- error: z.ZodRecord<z.ZodString, z.ZodAny>;
131
- }, z.core.$strip>;
132
- type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
133
-
134
167
  export { type FriendliAIErrorData, type FriendliAIProvider, type FriendliAIProviderSettings, type FriendliAvailableModel, type FriendliAvailableModelsResponse, createFriendli, friendli };