@ai-sdk/xai 4.0.0-beta.17 → 4.0.0-beta.19

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
+ ## 4.0.0-beta.19
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [986c6fd]
8
+ - Updated dependencies [493295c]
9
+ - @ai-sdk/provider-utils@5.0.0-beta.8
10
+ - @ai-sdk/openai-compatible@3.0.0-beta.11
11
+
12
+ ## 4.0.0-beta.18
13
+
14
+ ### Patch Changes
15
+
16
+ - 9f20868: fix(provider/xai): correct finish reason for tool calls
17
+
3
18
  ## 4.0.0-beta.17
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -115,11 +115,11 @@ type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string
115
115
  declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
116
116
  output: string;
117
117
  error?: string | undefined;
118
- }, object>;
118
+ }, object, {}>;
119
119
  declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
120
120
  output: string;
121
121
  error?: string | undefined;
122
- }>;
122
+ }, {}>;
123
123
 
124
124
  declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
125
125
  name: string;
@@ -132,32 +132,32 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
132
132
  allowedTools?: string[];
133
133
  headers?: Record<string, string>;
134
134
  authorization?: string;
135
- }>;
135
+ }, {}>;
136
136
  declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
137
137
  name: string;
138
138
  arguments: string;
139
139
  result: unknown;
140
- }>;
140
+ }, {}>;
141
141
 
142
142
  declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
143
143
  description: string;
144
144
  objects?: string[] | undefined;
145
- }, object>;
145
+ }, object, {}>;
146
146
  declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
147
147
  description: string;
148
148
  objects?: string[] | undefined;
149
- }>;
149
+ }, {}>;
150
150
 
151
151
  declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
152
152
  description: string;
153
153
  transcript?: string | undefined;
154
154
  duration?: number | undefined;
155
- }, object>;
155
+ }, object, {}>;
156
156
  declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
157
157
  description: string;
158
158
  transcript?: string | undefined;
159
159
  duration?: number | undefined;
160
- }>;
160
+ }, {}>;
161
161
 
162
162
  declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
163
163
  query: string;
@@ -170,7 +170,7 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
170
170
  allowedDomains?: string[];
171
171
  excludedDomains?: string[];
172
172
  enableImageUnderstanding?: boolean;
173
- }>;
173
+ }, {}>;
174
174
  declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
175
175
  query: string;
176
176
  sources: Array<{
@@ -178,7 +178,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
178
178
  url: string;
179
179
  snippet: string;
180
180
  }>;
181
- }>;
181
+ }, {}>;
182
182
 
183
183
  declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
184
184
  query: string;
@@ -195,7 +195,7 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
195
195
  toDate?: string;
196
196
  enableImageUnderstanding?: boolean;
197
197
  enableVideoUnderstanding?: boolean;
198
- }>;
198
+ }, {}>;
199
199
  declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
200
200
  query: string;
201
201
  posts: Array<{
@@ -204,16 +204,16 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
204
204
  url: string;
205
205
  likes: number;
206
206
  }>;
207
- }>;
207
+ }, {}>;
208
208
 
209
209
  declare const xaiTools: {
210
210
  codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
211
211
  output: string;
212
212
  error?: string | undefined;
213
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
213
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
214
214
  output: string;
215
215
  error?: string | undefined;
216
- }>;
216
+ }, {}>;
217
217
  fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
218
218
  queries: string[];
219
219
  results: null | {
@@ -225,7 +225,7 @@ declare const xaiTools: {
225
225
  }, {
226
226
  vectorStoreIds: string[];
227
227
  maxNumResults?: number;
228
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
228
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
229
229
  queries: string[];
230
230
  results: null | {
231
231
  fileId: string;
@@ -233,7 +233,7 @@ declare const xaiTools: {
233
233
  score: number;
234
234
  text: string;
235
235
  }[];
236
- }>;
236
+ }, {}>;
237
237
  mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
238
238
  name: string;
239
239
  arguments: string;
@@ -245,27 +245,27 @@ declare const xaiTools: {
245
245
  allowedTools?: string[];
246
246
  headers?: Record<string, string>;
247
247
  authorization?: string;
248
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
248
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
249
249
  name: string;
250
250
  arguments: string;
251
251
  result: unknown;
252
- }>;
252
+ }, {}>;
253
253
  viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
254
254
  description: string;
255
255
  objects?: string[] | undefined;
256
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
256
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
257
257
  description: string;
258
258
  objects?: string[] | undefined;
259
- }>;
259
+ }, {}>;
260
260
  viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
261
261
  description: string;
262
262
  transcript?: string | undefined;
263
263
  duration?: number | undefined;
264
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
264
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
265
265
  description: string;
266
266
  transcript?: string | undefined;
267
267
  duration?: number | undefined;
268
- }>;
268
+ }, {}>;
269
269
  webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
270
270
  query: string;
271
271
  sources: Array<{
@@ -277,14 +277,14 @@ declare const xaiTools: {
277
277
  allowedDomains?: string[];
278
278
  excludedDomains?: string[];
279
279
  enableImageUnderstanding?: boolean;
280
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
280
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
281
281
  query: string;
282
282
  sources: Array<{
283
283
  title: string;
284
284
  url: string;
285
285
  snippet: string;
286
286
  }>;
287
- }>;
287
+ }, {}>;
288
288
  xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
289
289
  query: string;
290
290
  posts: Array<{
@@ -300,7 +300,7 @@ declare const xaiTools: {
300
300
  toDate?: string;
301
301
  enableImageUnderstanding?: boolean;
302
302
  enableVideoUnderstanding?: boolean;
303
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
303
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
304
304
  query: string;
305
305
  posts: Array<{
306
306
  author: string;
@@ -308,7 +308,7 @@ declare const xaiTools: {
308
308
  url: string;
309
309
  likes: number;
310
310
  }>;
311
- }>;
311
+ }, {}>;
312
312
  };
313
313
 
314
314
  interface XaiProvider extends ProviderV4 {
package/dist/index.d.ts CHANGED
@@ -115,11 +115,11 @@ type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string
115
115
  declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
116
116
  output: string;
117
117
  error?: string | undefined;
118
- }, object>;
118
+ }, object, {}>;
119
119
  declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
120
120
  output: string;
121
121
  error?: string | undefined;
122
- }>;
122
+ }, {}>;
123
123
 
124
124
  declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
125
125
  name: string;
@@ -132,32 +132,32 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
132
132
  allowedTools?: string[];
133
133
  headers?: Record<string, string>;
134
134
  authorization?: string;
135
- }>;
135
+ }, {}>;
136
136
  declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
137
137
  name: string;
138
138
  arguments: string;
139
139
  result: unknown;
140
- }>;
140
+ }, {}>;
141
141
 
142
142
  declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
143
143
  description: string;
144
144
  objects?: string[] | undefined;
145
- }, object>;
145
+ }, object, {}>;
146
146
  declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
147
147
  description: string;
148
148
  objects?: string[] | undefined;
149
- }>;
149
+ }, {}>;
150
150
 
151
151
  declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
152
152
  description: string;
153
153
  transcript?: string | undefined;
154
154
  duration?: number | undefined;
155
- }, object>;
155
+ }, object, {}>;
156
156
  declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
157
157
  description: string;
158
158
  transcript?: string | undefined;
159
159
  duration?: number | undefined;
160
- }>;
160
+ }, {}>;
161
161
 
162
162
  declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
163
163
  query: string;
@@ -170,7 +170,7 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
170
170
  allowedDomains?: string[];
171
171
  excludedDomains?: string[];
172
172
  enableImageUnderstanding?: boolean;
173
- }>;
173
+ }, {}>;
174
174
  declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
175
175
  query: string;
176
176
  sources: Array<{
@@ -178,7 +178,7 @@ declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) =>
178
178
  url: string;
179
179
  snippet: string;
180
180
  }>;
181
- }>;
181
+ }, {}>;
182
182
 
183
183
  declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
184
184
  query: string;
@@ -195,7 +195,7 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
195
195
  toDate?: string;
196
196
  enableImageUnderstanding?: boolean;
197
197
  enableVideoUnderstanding?: boolean;
198
- }>;
198
+ }, {}>;
199
199
  declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
200
200
  query: string;
201
201
  posts: Array<{
@@ -204,16 +204,16 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
204
204
  url: string;
205
205
  likes: number;
206
206
  }>;
207
- }>;
207
+ }, {}>;
208
208
 
209
209
  declare const xaiTools: {
210
210
  codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
211
211
  output: string;
212
212
  error?: string | undefined;
213
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
213
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
214
214
  output: string;
215
215
  error?: string | undefined;
216
- }>;
216
+ }, {}>;
217
217
  fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
218
218
  queries: string[];
219
219
  results: null | {
@@ -225,7 +225,7 @@ declare const xaiTools: {
225
225
  }, {
226
226
  vectorStoreIds: string[];
227
227
  maxNumResults?: number;
228
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
228
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
229
229
  queries: string[];
230
230
  results: null | {
231
231
  fileId: string;
@@ -233,7 +233,7 @@ declare const xaiTools: {
233
233
  score: number;
234
234
  text: string;
235
235
  }[];
236
- }>;
236
+ }, {}>;
237
237
  mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
238
238
  name: string;
239
239
  arguments: string;
@@ -245,27 +245,27 @@ declare const xaiTools: {
245
245
  allowedTools?: string[];
246
246
  headers?: Record<string, string>;
247
247
  authorization?: string;
248
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
248
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
249
249
  name: string;
250
250
  arguments: string;
251
251
  result: unknown;
252
- }>;
252
+ }, {}>;
253
253
  viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
254
254
  description: string;
255
255
  objects?: string[] | undefined;
256
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
256
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
257
257
  description: string;
258
258
  objects?: string[] | undefined;
259
- }>;
259
+ }, {}>;
260
260
  viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
261
261
  description: string;
262
262
  transcript?: string | undefined;
263
263
  duration?: number | undefined;
264
- }, object>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
264
+ }, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
265
265
  description: string;
266
266
  transcript?: string | undefined;
267
267
  duration?: number | undefined;
268
- }>;
268
+ }, {}>;
269
269
  webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
270
270
  query: string;
271
271
  sources: Array<{
@@ -277,14 +277,14 @@ declare const xaiTools: {
277
277
  allowedDomains?: string[];
278
278
  excludedDomains?: string[];
279
279
  enableImageUnderstanding?: boolean;
280
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
280
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
281
281
  query: string;
282
282
  sources: Array<{
283
283
  title: string;
284
284
  url: string;
285
285
  snippet: string;
286
286
  }>;
287
- }>;
287
+ }, {}>;
288
288
  xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
289
289
  query: string;
290
290
  posts: Array<{
@@ -300,7 +300,7 @@ declare const xaiTools: {
300
300
  toDate?: string;
301
301
  enableImageUnderstanding?: boolean;
302
302
  enableVideoUnderstanding?: boolean;
303
- }>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
303
+ }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
304
304
  query: string;
305
305
  posts: Array<{
306
306
  author: string;
@@ -308,7 +308,7 @@ declare const xaiTools: {
308
308
  url: string;
309
309
  likes: number;
310
310
  }>;
311
- }>;
311
+ }, {}>;
312
312
  };
313
313
 
314
314
  interface XaiProvider extends ProviderV4 {
package/dist/index.js CHANGED
@@ -2139,6 +2139,7 @@ var XaiResponsesLanguageModel = class {
2139
2139
  fetch: this.config.fetch
2140
2140
  });
2141
2141
  const content = [];
2142
+ let hasFunctionCall = false;
2142
2143
  const webSearchSubTools = [
2143
2144
  "web_search",
2144
2145
  "web_search_with_snippets",
@@ -2223,6 +2224,7 @@ var XaiResponsesLanguageModel = class {
2223
2224
  break;
2224
2225
  }
2225
2226
  case "function_call": {
2227
+ hasFunctionCall = true;
2226
2228
  content.push({
2227
2229
  type: "tool-call",
2228
2230
  toolCallId: part.call_id,
@@ -2265,7 +2267,7 @@ var XaiResponsesLanguageModel = class {
2265
2267
  return {
2266
2268
  content,
2267
2269
  finishReason: {
2268
- unified: mapXaiResponsesFinishReason(response.status),
2270
+ unified: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response.status),
2269
2271
  raw: (_n = response.status) != null ? _n : void 0
2270
2272
  },
2271
2273
  usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
@@ -2311,6 +2313,7 @@ var XaiResponsesLanguageModel = class {
2311
2313
  unified: "other",
2312
2314
  raw: void 0
2313
2315
  };
2316
+ let hasFunctionCall = false;
2314
2317
  let usage = void 0;
2315
2318
  let isFirstChunk = true;
2316
2319
  const contentBlocks = {};
@@ -2455,7 +2458,7 @@ var XaiResponsesLanguageModel = class {
2455
2458
  }
2456
2459
  if (response2.status) {
2457
2460
  finishReason = {
2458
- unified: mapXaiResponsesFinishReason(response2.status),
2461
+ unified: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response2.status),
2459
2462
  raw: response2.status
2460
2463
  };
2461
2464
  }
@@ -2648,6 +2651,7 @@ var XaiResponsesLanguageModel = class {
2648
2651
  toolName: part.name
2649
2652
  });
2650
2653
  } else if (event.type === "response.output_item.done") {
2654
+ hasFunctionCall = true;
2651
2655
  ongoingToolCalls[event.output_index] = void 0;
2652
2656
  controller.enqueue({
2653
2657
  type: "tool-input-end",
@@ -2749,7 +2753,7 @@ var xaiTools = {
2749
2753
  };
2750
2754
 
2751
2755
  // src/version.ts
2752
- var VERSION = true ? "4.0.0-beta.17" : "0.0.0-test";
2756
+ var VERSION = true ? "4.0.0-beta.19" : "0.0.0-test";
2753
2757
 
2754
2758
  // src/xai-video-model.ts
2755
2759
  var import_provider6 = require("@ai-sdk/provider");