@friendliai/ai-provider 1.0.0-beta.0 → 1.0.0-beta.2

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,11 +1,48 @@
1
1
  # @friendliai/ai-provider
2
2
 
3
+ ## 1.0.0-beta.2
4
+
5
+ ### Minor Changes
6
+
7
+ - 049179d: Add Linkup integrated tool helper (`friendli.tools.linkupSearch`) for Tool Assisted API.
8
+
9
+ ### Patch Changes
10
+
11
+ - 049179d: Support Friendli serverless chat options (`topK` -> `top_k`, sampling providerOptions) and improve error propagation for HTTP and streaming tool-assisted responses.
12
+
13
+ ## 1.0.0-beta.1
14
+
15
+ ### Minor Changes
16
+
17
+ - 2ffbb78: ### Provider Tools Improvements
18
+ - **Renamed tool functions** for cleaner API:
19
+ - `webSearchBetaTool()` → `webSearch()`
20
+ - `webUrlBetaTool()` → `webUrl()`
21
+ - `mathCalendarBetaTool()` → `mathCalendar()`
22
+ - `mathStatisticsBetaTool()` → `mathStatistics()`
23
+ - `mathCalculatorBetaTool()` → `mathCalculator()`
24
+ - `codePythonInterpreterBetaTool()` → `codePythonInterpreter()`
25
+ - **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.
26
+ - **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`.
27
+
3
28
  ## 1.0.0-beta.0
4
29
 
5
30
  ### Major Changes
6
31
 
7
32
  - 3044ef8: Entering the AI ​​SDK v6 compatible migration
8
33
 
34
+ ## 0.3.4
35
+
36
+ ### Patch Changes
37
+
38
+ - 795d5bf: add minimax-m2 in FSE
39
+
40
+ ## 0.3.3
41
+
42
+ ### Patch Changes
43
+
44
+ - a6180ef: add deepseek v3.1 in FSE
45
+
9
46
  ## 0.3.2
10
47
 
11
48
  ### Patch Changes
package/README.md CHANGED
@@ -27,8 +27,28 @@ const { text } = await generateText({
27
27
  model: friendli('meta-llama-3.3-70b-instruct'),
28
28
  prompt: 'What is the meaning of life?',
29
29
  maxTokens: 20,
30
+ topK: 10,
31
+ providerOptions: {
32
+ friendliai: {
33
+ minP: 0.2,
34
+ },
35
+ },
30
36
  });
31
37
  console.log(text);
32
38
  ```
33
39
 
40
+ ### Provider Options
41
+
42
+ You can pass Friendli-specific parameters using `providerOptions.friendliai`. For backward compatibility, the `friendli` key is also supported.
43
+
44
+ Supported options (camelCase):
45
+
46
+ - `minP`
47
+ - `repetitionPenalty`
48
+ - `xtcThreshold`
49
+ - `xtcProbability`
50
+ - `parallelToolCalls`
51
+ - `regex` (BETA: Force output to satisfy a regular expression)
52
+ - `chat_template_kwargs`
53
+
34
54
  For more details, see the [official documentation](https://friendli.ai/docs/).
package/dist/index.d.mts CHANGED
@@ -1,30 +1,64 @@
1
1
  import { z } from 'zod/v4';
2
- import { LanguageModelV2ProviderDefinedTool, ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
3
- import { FetchFunction } from '@ai-sdk/provider-utils';
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 friendliaiErrorSchema: z.ZodObject<{
5
+ declare const friendliaiErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
6
+ error: z.ZodObject<{
7
+ message: z.ZodString;
8
+ }, z.core.$loose>;
9
+ }, z.core.$loose>, z.ZodObject<{
6
10
  message: z.ZodString;
7
- error: z.ZodRecord<z.ZodString, z.ZodAny>;
8
- }, z.core.$strip>;
11
+ error: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
12
+ }, z.core.$strip>]>;
9
13
  type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
10
14
 
11
- 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"];
15
+ 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"];
12
16
  type FriendliAIServerlessModelId = (typeof FriendliAIServerlessModelIds)[number];
13
17
  type FriendliAILanguageModelId = FriendliAIServerlessModelId | (string & {});
14
18
 
15
- declare function webUrlBetaTool(): LanguageModelV2ProviderDefinedTool;
16
- declare function webSearchBetaTool(): LanguageModelV2ProviderDefinedTool;
17
- declare function mathCalendarBetaTool(): LanguageModelV2ProviderDefinedTool;
18
- declare function mathStatisticsBetaTool(): LanguageModelV2ProviderDefinedTool;
19
- declare function mathCalculatorBetaTool(): LanguageModelV2ProviderDefinedTool;
20
- declare function codePythonInterpreterBetaTool(): LanguageModelV2ProviderDefinedTool;
19
+ /**
20
+ * Web search tool - searches the web for information.
21
+ * @beta
22
+ */
23
+ declare function webSearch(): Tool;
24
+ /**
25
+ * Web URL tool - fetches content from a specific URL.
26
+ * @beta
27
+ */
28
+ declare function webUrl(): Tool;
29
+ /**
30
+ * Math calendar tool - performs calendar-related calculations.
31
+ * @beta
32
+ */
33
+ declare function mathCalendar(): Tool;
34
+ /**
35
+ * Math statistics tool - performs statistical calculations.
36
+ * @beta
37
+ */
38
+ declare function mathStatistics(): Tool;
39
+ /**
40
+ * Math calculator tool - performs arithmetic calculations.
41
+ * @beta
42
+ */
43
+ declare function mathCalculator(): Tool;
44
+ /**
45
+ * Python interpreter tool - executes Python code.
46
+ * @beta
47
+ */
48
+ declare function codePythonInterpreter(): Tool;
49
+ /**
50
+ * Linkup search tool - searches the web for real-time information with citations.
51
+ * @see https://www.linkup.so
52
+ */
53
+ declare function linkupSearch(): Tool;
21
54
  declare const friendliTools: {
22
- webSearchBetaTool: typeof webSearchBetaTool;
23
- webUrlBetaTool: typeof webUrlBetaTool;
24
- mathCalendarBetaTool: typeof mathCalendarBetaTool;
25
- mathStatisticsBetaTool: typeof mathStatisticsBetaTool;
26
- mathCalculatorBetaTool: typeof mathCalculatorBetaTool;
27
- codePythonInterpreterBetaTool: typeof codePythonInterpreterBetaTool;
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
+ linkupSearch: typeof linkupSearch;
28
62
  };
29
63
 
30
64
  type Pricing = {
@@ -70,53 +104,57 @@ interface FriendliAIProviderSettings {
70
104
  * or to provide a custom fetch implementation for e.g. testing.
71
105
  */
72
106
  fetch?: FetchFunction;
107
+ /**
108
+ * Whether to include usage information in the response.
109
+ */
110
+ includeUsage?: boolean;
73
111
  }
74
- interface FriendliAIProvider extends ProviderV2 {
112
+ interface FriendliAIProvider extends ProviderV3 {
75
113
  /**
76
114
  * Creates a model for text generation.
77
115
  */
78
- (modelId: FriendliAILanguageModelId): LanguageModelV2;
116
+ (modelId: FriendliAILanguageModelId): LanguageModelV3;
79
117
  /**
80
118
  * Creates a chat model for text generation.
81
119
  */
82
- languageModel(modelId: FriendliAILanguageModelId): LanguageModelV2;
120
+ languageModel(modelId: FriendliAILanguageModelId): LanguageModelV3;
83
121
  /**
84
122
  * Creates a chat model for text generation.
85
123
  */
86
- chat(modelId: FriendliAILanguageModelId): LanguageModelV2;
124
+ chat(modelId: FriendliAILanguageModelId): LanguageModelV3;
87
125
  /**
88
126
  * Creates a completion model for text generation.
89
127
  */
90
- completion(modelId: FriendliAILanguageModelId): LanguageModelV2;
128
+ completion(modelId: FriendliAILanguageModelId): LanguageModelV3;
91
129
  /**
92
- * Creates a text embedding model for text generation.
130
+ * Creates an embedding model for text generation.
93
131
  * TODO: Implement for Dedicated users
94
132
  */
95
- embedding(modelId: string & {}): LanguageModelV2;
96
- textEmbeddingModel(modelId: string & {}): LanguageModelV2;
133
+ embedding(modelId: string & {}): LanguageModelV3;
134
+ embeddingModel(modelId: string & {}): LanguageModelV3;
97
135
  /**
98
136
  * Returns the available models and their metadata.
99
137
  */
100
138
  getAvailableModels(options?: {
101
139
  graphqlURL?: string;
102
140
  }): Promise<FriendliAvailableModelsResponse>;
103
- embedding(modelId: string & {}): EmbeddingModelV2<string>;
104
- textEmbeddingModel(modelId: string & {}): EmbeddingModelV2<string>;
141
+ embedding(modelId: string & {}): EmbeddingModelV3;
142
+ embeddingModel(modelId: string & {}): EmbeddingModelV3;
105
143
  /**
106
144
  * Creates a model for image generation.
107
145
  * TODO: Implement for Dedicated users
108
146
  */
109
- imageModel(modelId: string & {}): ImageModelV2;
147
+ imageModel(modelId: string & {}): ImageModelV3;
110
148
  /**
111
149
  * Creates a model for transcription.
112
150
  * TODO: Implement for Dedicated users
113
151
  */
114
- transcription(modelId: string & {}): TranscriptionModelV2;
152
+ transcription(modelId: string & {}): TranscriptionModelV3;
115
153
  /**
116
154
  * Creates a model for speech generation.
117
155
  * TODO: Implement for Dedicated users
118
156
  */
119
- speech(modelId: string & {}): SpeechModelV2;
157
+ speech(modelId: string & {}): SpeechModelV3;
120
158
  /**
121
159
  * Friendli-specific tools.
122
160
  */
package/dist/index.d.ts CHANGED
@@ -1,30 +1,64 @@
1
1
  import { z } from 'zod/v4';
2
- import { LanguageModelV2ProviderDefinedTool, ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2, TranscriptionModelV2, SpeechModelV2 } from '@ai-sdk/provider';
3
- import { FetchFunction } from '@ai-sdk/provider-utils';
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 friendliaiErrorSchema: z.ZodObject<{
5
+ declare const friendliaiErrorSchema: z.ZodUnion<readonly [z.ZodObject<{
6
+ error: z.ZodObject<{
7
+ message: z.ZodString;
8
+ }, z.core.$loose>;
9
+ }, z.core.$loose>, z.ZodObject<{
6
10
  message: z.ZodString;
7
- error: z.ZodRecord<z.ZodString, z.ZodAny>;
8
- }, z.core.$strip>;
11
+ error: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
12
+ }, z.core.$strip>]>;
9
13
  type FriendliAIErrorData = z.infer<typeof friendliaiErrorSchema>;
10
14
 
11
- 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"];
15
+ 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"];
12
16
  type FriendliAIServerlessModelId = (typeof FriendliAIServerlessModelIds)[number];
13
17
  type FriendliAILanguageModelId = FriendliAIServerlessModelId | (string & {});
14
18
 
15
- declare function webUrlBetaTool(): LanguageModelV2ProviderDefinedTool;
16
- declare function webSearchBetaTool(): LanguageModelV2ProviderDefinedTool;
17
- declare function mathCalendarBetaTool(): LanguageModelV2ProviderDefinedTool;
18
- declare function mathStatisticsBetaTool(): LanguageModelV2ProviderDefinedTool;
19
- declare function mathCalculatorBetaTool(): LanguageModelV2ProviderDefinedTool;
20
- declare function codePythonInterpreterBetaTool(): LanguageModelV2ProviderDefinedTool;
19
+ /**
20
+ * Web search tool - searches the web for information.
21
+ * @beta
22
+ */
23
+ declare function webSearch(): Tool;
24
+ /**
25
+ * Web URL tool - fetches content from a specific URL.
26
+ * @beta
27
+ */
28
+ declare function webUrl(): Tool;
29
+ /**
30
+ * Math calendar tool - performs calendar-related calculations.
31
+ * @beta
32
+ */
33
+ declare function mathCalendar(): Tool;
34
+ /**
35
+ * Math statistics tool - performs statistical calculations.
36
+ * @beta
37
+ */
38
+ declare function mathStatistics(): Tool;
39
+ /**
40
+ * Math calculator tool - performs arithmetic calculations.
41
+ * @beta
42
+ */
43
+ declare function mathCalculator(): Tool;
44
+ /**
45
+ * Python interpreter tool - executes Python code.
46
+ * @beta
47
+ */
48
+ declare function codePythonInterpreter(): Tool;
49
+ /**
50
+ * Linkup search tool - searches the web for real-time information with citations.
51
+ * @see https://www.linkup.so
52
+ */
53
+ declare function linkupSearch(): Tool;
21
54
  declare const friendliTools: {
22
- webSearchBetaTool: typeof webSearchBetaTool;
23
- webUrlBetaTool: typeof webUrlBetaTool;
24
- mathCalendarBetaTool: typeof mathCalendarBetaTool;
25
- mathStatisticsBetaTool: typeof mathStatisticsBetaTool;
26
- mathCalculatorBetaTool: typeof mathCalculatorBetaTool;
27
- codePythonInterpreterBetaTool: typeof codePythonInterpreterBetaTool;
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
+ linkupSearch: typeof linkupSearch;
28
62
  };
29
63
 
30
64
  type Pricing = {
@@ -70,53 +104,57 @@ interface FriendliAIProviderSettings {
70
104
  * or to provide a custom fetch implementation for e.g. testing.
71
105
  */
72
106
  fetch?: FetchFunction;
107
+ /**
108
+ * Whether to include usage information in the response.
109
+ */
110
+ includeUsage?: boolean;
73
111
  }
74
- interface FriendliAIProvider extends ProviderV2 {
112
+ interface FriendliAIProvider extends ProviderV3 {
75
113
  /**
76
114
  * Creates a model for text generation.
77
115
  */
78
- (modelId: FriendliAILanguageModelId): LanguageModelV2;
116
+ (modelId: FriendliAILanguageModelId): LanguageModelV3;
79
117
  /**
80
118
  * Creates a chat model for text generation.
81
119
  */
82
- languageModel(modelId: FriendliAILanguageModelId): LanguageModelV2;
120
+ languageModel(modelId: FriendliAILanguageModelId): LanguageModelV3;
83
121
  /**
84
122
  * Creates a chat model for text generation.
85
123
  */
86
- chat(modelId: FriendliAILanguageModelId): LanguageModelV2;
124
+ chat(modelId: FriendliAILanguageModelId): LanguageModelV3;
87
125
  /**
88
126
  * Creates a completion model for text generation.
89
127
  */
90
- completion(modelId: FriendliAILanguageModelId): LanguageModelV2;
128
+ completion(modelId: FriendliAILanguageModelId): LanguageModelV3;
91
129
  /**
92
- * Creates a text embedding model for text generation.
130
+ * Creates an embedding model for text generation.
93
131
  * TODO: Implement for Dedicated users
94
132
  */
95
- embedding(modelId: string & {}): LanguageModelV2;
96
- textEmbeddingModel(modelId: string & {}): LanguageModelV2;
133
+ embedding(modelId: string & {}): LanguageModelV3;
134
+ embeddingModel(modelId: string & {}): LanguageModelV3;
97
135
  /**
98
136
  * Returns the available models and their metadata.
99
137
  */
100
138
  getAvailableModels(options?: {
101
139
  graphqlURL?: string;
102
140
  }): Promise<FriendliAvailableModelsResponse>;
103
- embedding(modelId: string & {}): EmbeddingModelV2<string>;
104
- textEmbeddingModel(modelId: string & {}): EmbeddingModelV2<string>;
141
+ embedding(modelId: string & {}): EmbeddingModelV3;
142
+ embeddingModel(modelId: string & {}): EmbeddingModelV3;
105
143
  /**
106
144
  * Creates a model for image generation.
107
145
  * TODO: Implement for Dedicated users
108
146
  */
109
- imageModel(modelId: string & {}): ImageModelV2;
147
+ imageModel(modelId: string & {}): ImageModelV3;
110
148
  /**
111
149
  * Creates a model for transcription.
112
150
  * TODO: Implement for Dedicated users
113
151
  */
114
- transcription(modelId: string & {}): TranscriptionModelV2;
152
+ transcription(modelId: string & {}): TranscriptionModelV3;
115
153
  /**
116
154
  * Creates a model for speech generation.
117
155
  * TODO: Implement for Dedicated users
118
156
  */
119
- speech(modelId: string & {}): SpeechModelV2;
157
+ speech(modelId: string & {}): SpeechModelV3;
120
158
  /**
121
159
  * Friendli-specific tools.
122
160
  */