@ai-sdk/xai 3.0.39 → 3.0.41
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 +19 -0
- package/dist/index.d.mts +25 -2
- package/dist/index.d.ts +25 -2
- package/dist/index.js +278 -164
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +264 -146
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +38 -14
- package/package.json +2 -2
- package/src/responses/xai-responses-api.ts +45 -1
- package/src/responses/xai-responses-language-model.ts +109 -5
- package/src/responses/xai-responses-options.ts +5 -1
- package/src/responses/xai-responses-prepare-tools.ts +15 -57
- package/src/tool/file-search.ts +93 -0
- package/src/tool/index.ts +11 -1
- package/src/xai-chat-options.ts +1 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.41
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [9d056e6]
|
|
8
|
+
- @ai-sdk/openai-compatible@2.0.22
|
|
9
|
+
|
|
10
|
+
## 3.0.40
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- 05f3f36: Add native `file_search` server-side tool support:
|
|
15
|
+
|
|
16
|
+
- Add `xai.tools.fileSearch()` for vector store search with `vectorStoreIds` and `maxNumResults` parameters
|
|
17
|
+
- Add `include` option supporting `file_search_call.results` to get inline search results
|
|
18
|
+
- Add `file_search_call` handling in language model for both `doGenerate` and `doStream`
|
|
19
|
+
- Fix invalid `grok-4-1` model type (only `grok-4-1-fast-reasoning` and `grok-4-1-fast-non-reasoning` exist)
|
|
20
|
+
- Fix `toolChoice` for server-side tools: xAI API doesn't support forcing specific server-side tools, now emits warning instead of sending invalid request
|
|
21
|
+
|
|
3
22
|
## 3.0.39
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
-
type XaiChatModelId = 'grok-4-1
|
|
6
|
+
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
7
|
declare const xaiProviderOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -56,7 +56,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
type XaiResponsesModelId = 'grok-4-1
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
60
|
/**
|
|
61
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
62
|
*/
|
|
@@ -68,6 +68,9 @@ declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
|
68
68
|
}>>;
|
|
69
69
|
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
70
|
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
72
|
+
"file_search_call.results": "file_search_call.results";
|
|
73
|
+
}>>>>;
|
|
71
74
|
}, z.core.$strip>;
|
|
72
75
|
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
73
76
|
|
|
@@ -175,6 +178,26 @@ declare const xaiTools: {
|
|
|
175
178
|
output: string;
|
|
176
179
|
error?: string | undefined;
|
|
177
180
|
}>;
|
|
181
|
+
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
182
|
+
queries: string[];
|
|
183
|
+
results: null | {
|
|
184
|
+
fileId: string;
|
|
185
|
+
filename: string;
|
|
186
|
+
score: number;
|
|
187
|
+
text: string;
|
|
188
|
+
}[];
|
|
189
|
+
}, {
|
|
190
|
+
vectorStoreIds: string[];
|
|
191
|
+
maxNumResults?: number;
|
|
192
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
193
|
+
queries: string[];
|
|
194
|
+
results: null | {
|
|
195
|
+
fileId: string;
|
|
196
|
+
filename: string;
|
|
197
|
+
score: number;
|
|
198
|
+
text: string;
|
|
199
|
+
}[];
|
|
200
|
+
}>;
|
|
178
201
|
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
179
202
|
name: string;
|
|
180
203
|
arguments: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
|
|
|
3
3
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
4
|
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
5
5
|
|
|
6
|
-
type XaiChatModelId = 'grok-4-1
|
|
6
|
+
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
7
|
declare const xaiProviderOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -56,7 +56,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
type XaiResponsesModelId = 'grok-4-1
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
60
60
|
/**
|
|
61
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
62
|
*/
|
|
@@ -68,6 +68,9 @@ declare const xaiResponsesProviderOptions: z.ZodObject<{
|
|
|
68
68
|
}>>;
|
|
69
69
|
store: z.ZodOptional<z.ZodBoolean>;
|
|
70
70
|
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
71
|
+
include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
72
|
+
"file_search_call.results": "file_search_call.results";
|
|
73
|
+
}>>>>;
|
|
71
74
|
}, z.core.$strip>;
|
|
72
75
|
type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
|
|
73
76
|
|
|
@@ -175,6 +178,26 @@ declare const xaiTools: {
|
|
|
175
178
|
output: string;
|
|
176
179
|
error?: string | undefined;
|
|
177
180
|
}>;
|
|
181
|
+
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
182
|
+
queries: string[];
|
|
183
|
+
results: null | {
|
|
184
|
+
fileId: string;
|
|
185
|
+
filename: string;
|
|
186
|
+
score: number;
|
|
187
|
+
text: string;
|
|
188
|
+
}[];
|
|
189
|
+
}, {
|
|
190
|
+
vectorStoreIds: string[];
|
|
191
|
+
maxNumResults?: number;
|
|
192
|
+
}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
193
|
+
queries: string[];
|
|
194
|
+
results: null | {
|
|
195
|
+
fileId: string;
|
|
196
|
+
filename: string;
|
|
197
|
+
score: number;
|
|
198
|
+
text: string;
|
|
199
|
+
}[];
|
|
200
|
+
}>;
|
|
178
201
|
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
179
202
|
name: string;
|
|
180
203
|
arguments: string;
|