@ai-sdk/xai 3.0.0-beta.33 → 3.0.0-beta.35

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,20 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.0-beta.35
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [bb36798]
8
+ - @ai-sdk/provider@3.0.0-beta.15
9
+ - @ai-sdk/openai-compatible@2.0.0-beta.32
10
+ - @ai-sdk/provider-utils@4.0.0-beta.31
11
+
12
+ ## 3.0.0-beta.34
13
+
14
+ ### Patch Changes
15
+
16
+ - 5ad1bbe: feat: xai server-side tool calling
17
+
3
18
  ## 3.0.0-beta.33
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
5
 
5
6
  type XaiChatModelId = '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 & {});
@@ -55,8 +56,162 @@ declare const xaiErrorDataSchema: z.ZodObject<{
55
56
  }, z.core.$strip>;
56
57
  type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
57
58
 
59
+ type XaiResponsesModelId = 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
60
+ declare const xaiResponsesProviderOptions: z.ZodObject<{
61
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
62
+ low: "low";
63
+ high: "high";
64
+ }>>;
65
+ }, z.core.$strip>;
66
+ type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
67
+
58
68
  type XaiImageModelId = 'grok-2-image' | (string & {});
59
69
 
70
+ declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
71
+ output: string;
72
+ error?: string | undefined;
73
+ }, object>;
74
+ declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
75
+ output: string;
76
+ error?: string | undefined;
77
+ }>;
78
+
79
+ declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
80
+ description: string;
81
+ objects?: string[] | undefined;
82
+ }, object>;
83
+ declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
84
+ description: string;
85
+ objects?: string[] | undefined;
86
+ }>;
87
+
88
+ declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
89
+ description: string;
90
+ transcript?: string | undefined;
91
+ duration?: number | undefined;
92
+ }, object>;
93
+ declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
94
+ description: string;
95
+ transcript?: string | undefined;
96
+ duration?: number | undefined;
97
+ }>;
98
+
99
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
100
+ query: string;
101
+ sources: Array<{
102
+ title: string;
103
+ url: string;
104
+ snippet: string;
105
+ }>;
106
+ }, {
107
+ allowedDomains?: string[];
108
+ excludedDomains?: string[];
109
+ enableImageUnderstanding?: boolean;
110
+ }>;
111
+ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
112
+ query: string;
113
+ sources: Array<{
114
+ title: string;
115
+ url: string;
116
+ snippet: string;
117
+ }>;
118
+ }>;
119
+
120
+ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
121
+ query: string;
122
+ posts: Array<{
123
+ author: string;
124
+ text: string;
125
+ url: string;
126
+ likes: number;
127
+ }>;
128
+ }, {
129
+ allowedXHandles?: string[];
130
+ excludedXHandles?: string[];
131
+ fromDate?: string;
132
+ toDate?: string;
133
+ enableImageUnderstanding?: boolean;
134
+ enableVideoUnderstanding?: boolean;
135
+ }>;
136
+ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
137
+ query: string;
138
+ posts: Array<{
139
+ author: string;
140
+ text: string;
141
+ url: string;
142
+ likes: number;
143
+ }>;
144
+ }>;
145
+
146
+ declare const xaiTools: {
147
+ codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
148
+ output: string;
149
+ error?: string | undefined;
150
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
151
+ output: string;
152
+ error?: string | undefined;
153
+ }>;
154
+ viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
155
+ description: string;
156
+ objects?: string[] | undefined;
157
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
158
+ description: string;
159
+ objects?: string[] | undefined;
160
+ }>;
161
+ viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
162
+ description: string;
163
+ transcript?: string | undefined;
164
+ duration?: number | undefined;
165
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
166
+ description: string;
167
+ transcript?: string | undefined;
168
+ duration?: number | undefined;
169
+ }>;
170
+ webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
171
+ query: string;
172
+ sources: Array<{
173
+ title: string;
174
+ url: string;
175
+ snippet: string;
176
+ }>;
177
+ }, {
178
+ allowedDomains?: string[];
179
+ excludedDomains?: string[];
180
+ enableImageUnderstanding?: boolean;
181
+ }>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
182
+ query: string;
183
+ sources: Array<{
184
+ title: string;
185
+ url: string;
186
+ snippet: string;
187
+ }>;
188
+ }>;
189
+ xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
190
+ query: string;
191
+ posts: Array<{
192
+ author: string;
193
+ text: string;
194
+ url: string;
195
+ likes: number;
196
+ }>;
197
+ }, {
198
+ allowedXHandles?: string[];
199
+ excludedXHandles?: string[];
200
+ fromDate?: string;
201
+ toDate?: string;
202
+ enableImageUnderstanding?: boolean;
203
+ enableVideoUnderstanding?: boolean;
204
+ }>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
205
+ query: string;
206
+ posts: Array<{
207
+ author: string;
208
+ text: string;
209
+ url: string;
210
+ likes: number;
211
+ }>;
212
+ }>;
213
+ };
214
+
60
215
  interface XaiProvider extends ProviderV3 {
61
216
  /**
62
217
  Creates an Xai chat model for text generation.
@@ -71,6 +226,10 @@ interface XaiProvider extends ProviderV3 {
71
226
  */
72
227
  chat: (modelId: XaiChatModelId) => LanguageModelV3;
73
228
  /**
229
+ Creates an Xai responses model for agentic tool calling.
230
+ */
231
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
232
+ /**
74
233
  Creates an Xai image model for image generation.
75
234
  */
76
235
  image(modelId: XaiImageModelId): ImageModelV3;
@@ -78,6 +237,10 @@ interface XaiProvider extends ProviderV3 {
78
237
  Creates an Xai image model for image generation.
79
238
  */
80
239
  imageModel(modelId: XaiImageModelId): ImageModelV3;
240
+ /**
241
+ Server-side agentic tools for use with the responses API.
242
+ */
243
+ tools: typeof xaiTools;
81
244
  }
82
245
  interface XaiProviderSettings {
83
246
  /**
@@ -103,4 +266,4 @@ declare const xai: XaiProvider;
103
266
 
104
267
  declare const VERSION: string;
105
268
 
106
- export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, createXai, xai };
269
+ export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod/v4';
2
2
  import { ProviderV3, LanguageModelV3, ImageModelV3 } from '@ai-sdk/provider';
3
+ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
4
5
 
5
6
  type XaiChatModelId = '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 & {});
@@ -55,8 +56,162 @@ declare const xaiErrorDataSchema: z.ZodObject<{
55
56
  }, z.core.$strip>;
56
57
  type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
57
58
 
59
+ type XaiResponsesModelId = 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
60
+ declare const xaiResponsesProviderOptions: z.ZodObject<{
61
+ reasoningEffort: z.ZodOptional<z.ZodEnum<{
62
+ low: "low";
63
+ high: "high";
64
+ }>>;
65
+ }, z.core.$strip>;
66
+ type XaiResponsesProviderOptions = z.infer<typeof xaiResponsesProviderOptions>;
67
+
58
68
  type XaiImageModelId = 'grok-2-image' | (string & {});
59
69
 
70
+ declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
71
+ output: string;
72
+ error?: string | undefined;
73
+ }, object>;
74
+ declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
75
+ output: string;
76
+ error?: string | undefined;
77
+ }>;
78
+
79
+ declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
80
+ description: string;
81
+ objects?: string[] | undefined;
82
+ }, object>;
83
+ declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
84
+ description: string;
85
+ objects?: string[] | undefined;
86
+ }>;
87
+
88
+ declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
89
+ description: string;
90
+ transcript?: string | undefined;
91
+ duration?: number | undefined;
92
+ }, object>;
93
+ declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
94
+ description: string;
95
+ transcript?: string | undefined;
96
+ duration?: number | undefined;
97
+ }>;
98
+
99
+ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
100
+ query: string;
101
+ sources: Array<{
102
+ title: string;
103
+ url: string;
104
+ snippet: string;
105
+ }>;
106
+ }, {
107
+ allowedDomains?: string[];
108
+ excludedDomains?: string[];
109
+ enableImageUnderstanding?: boolean;
110
+ }>;
111
+ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
112
+ query: string;
113
+ sources: Array<{
114
+ title: string;
115
+ url: string;
116
+ snippet: string;
117
+ }>;
118
+ }>;
119
+
120
+ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
121
+ query: string;
122
+ posts: Array<{
123
+ author: string;
124
+ text: string;
125
+ url: string;
126
+ likes: number;
127
+ }>;
128
+ }, {
129
+ allowedXHandles?: string[];
130
+ excludedXHandles?: string[];
131
+ fromDate?: string;
132
+ toDate?: string;
133
+ enableImageUnderstanding?: boolean;
134
+ enableVideoUnderstanding?: boolean;
135
+ }>;
136
+ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
137
+ query: string;
138
+ posts: Array<{
139
+ author: string;
140
+ text: string;
141
+ url: string;
142
+ likes: number;
143
+ }>;
144
+ }>;
145
+
146
+ declare const xaiTools: {
147
+ codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
148
+ output: string;
149
+ error?: string | undefined;
150
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
151
+ output: string;
152
+ error?: string | undefined;
153
+ }>;
154
+ viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
155
+ description: string;
156
+ objects?: string[] | undefined;
157
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
158
+ description: string;
159
+ objects?: string[] | undefined;
160
+ }>;
161
+ viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
162
+ description: string;
163
+ transcript?: string | undefined;
164
+ duration?: number | undefined;
165
+ }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
166
+ description: string;
167
+ transcript?: string | undefined;
168
+ duration?: number | undefined;
169
+ }>;
170
+ webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
171
+ query: string;
172
+ sources: Array<{
173
+ title: string;
174
+ url: string;
175
+ snippet: string;
176
+ }>;
177
+ }, {
178
+ allowedDomains?: string[];
179
+ excludedDomains?: string[];
180
+ enableImageUnderstanding?: boolean;
181
+ }>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
182
+ query: string;
183
+ sources: Array<{
184
+ title: string;
185
+ url: string;
186
+ snippet: string;
187
+ }>;
188
+ }>;
189
+ xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderDefinedToolFactoryWithOutputSchema<Record<string, never>, {
190
+ query: string;
191
+ posts: Array<{
192
+ author: string;
193
+ text: string;
194
+ url: string;
195
+ likes: number;
196
+ }>;
197
+ }, {
198
+ allowedXHandles?: string[];
199
+ excludedXHandles?: string[];
200
+ fromDate?: string;
201
+ toDate?: string;
202
+ enableImageUnderstanding?: boolean;
203
+ enableVideoUnderstanding?: boolean;
204
+ }>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
205
+ query: string;
206
+ posts: Array<{
207
+ author: string;
208
+ text: string;
209
+ url: string;
210
+ likes: number;
211
+ }>;
212
+ }>;
213
+ };
214
+
60
215
  interface XaiProvider extends ProviderV3 {
61
216
  /**
62
217
  Creates an Xai chat model for text generation.
@@ -71,6 +226,10 @@ interface XaiProvider extends ProviderV3 {
71
226
  */
72
227
  chat: (modelId: XaiChatModelId) => LanguageModelV3;
73
228
  /**
229
+ Creates an Xai responses model for agentic tool calling.
230
+ */
231
+ responses: (modelId: XaiResponsesModelId) => LanguageModelV3;
232
+ /**
74
233
  Creates an Xai image model for image generation.
75
234
  */
76
235
  image(modelId: XaiImageModelId): ImageModelV3;
@@ -78,6 +237,10 @@ interface XaiProvider extends ProviderV3 {
78
237
  Creates an Xai image model for image generation.
79
238
  */
80
239
  imageModel(modelId: XaiImageModelId): ImageModelV3;
240
+ /**
241
+ Server-side agentic tools for use with the responses API.
242
+ */
243
+ tools: typeof xaiTools;
81
244
  }
82
245
  interface XaiProviderSettings {
83
246
  /**
@@ -103,4 +266,4 @@ declare const xai: XaiProvider;
103
266
 
104
267
  declare const VERSION: string;
105
268
 
106
- export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, createXai, xai };
269
+ export { VERSION, type XaiErrorData, type XaiProvider, type XaiProviderOptions, type XaiProviderSettings, type XaiResponsesProviderOptions, codeExecution, createXai, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };