@ai-sdk/xai 4.0.0-beta.6 → 4.0.0-beta.75
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 +667 -9
- package/README.md +2 -0
- package/dist/index.d.ts +218 -68
- package/dist/index.js +2081 -779
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +445 -54
- package/package.json +15 -15
- package/src/convert-to-xai-chat-messages.ts +48 -27
- package/src/convert-xai-chat-usage.ts +3 -3
- package/src/files/xai-files-api.ts +16 -0
- package/src/files/xai-files-options.ts +19 -0
- package/src/files/xai-files.ts +94 -0
- package/src/index.ts +9 -4
- package/src/map-xai-finish-reason.ts +2 -2
- package/src/realtime/index.ts +2 -0
- package/src/realtime/xai-realtime-event-mapper.ts +399 -0
- package/src/realtime/xai-realtime-model-options.ts +3 -0
- package/src/realtime/xai-realtime-model.ts +101 -0
- package/src/remove-additional-properties.ts +24 -0
- package/src/responses/convert-to-xai-responses-input.ts +100 -23
- package/src/responses/convert-xai-responses-usage.ts +3 -3
- package/src/responses/map-xai-responses-finish-reason.ts +3 -2
- package/src/responses/xai-responses-api.ts +34 -1
- package/src/responses/{xai-responses-options.ts → xai-responses-language-model-options.ts} +13 -7
- package/src/responses/xai-responses-language-model.ts +173 -64
- package/src/responses/xai-responses-prepare-tools.ts +10 -8
- package/src/tool/code-execution.ts +2 -2
- package/src/tool/file-search.ts +2 -2
- package/src/tool/mcp-server.ts +2 -2
- package/src/tool/view-image.ts +2 -2
- package/src/tool/view-x-video.ts +2 -2
- package/src/tool/web-search.ts +4 -2
- package/src/tool/x-search.ts +2 -2
- package/src/{xai-chat-options.ts → xai-chat-language-model-options.ts} +28 -13
- package/src/xai-chat-language-model.ts +65 -29
- package/src/xai-chat-prompt.ts +2 -1
- package/src/xai-error.ts +13 -3
- package/src/xai-image-model.ts +28 -11
- package/src/xai-prepare-tools.ts +9 -8
- package/src/xai-provider.ts +115 -19
- package/src/xai-speech-model-options.ts +55 -0
- package/src/xai-speech-model.ts +167 -0
- package/src/xai-transcription-model-options.ts +70 -0
- package/src/xai-transcription-model.ts +166 -0
- package/src/xai-video-model-options.ts +145 -0
- package/src/xai-video-model.ts +129 -22
- package/dist/index.d.mts +0 -372
- package/dist/index.mjs +0 -3061
- package/dist/index.mjs.map +0 -1
- package/src/xai-video-options.ts +0 -23
- /package/src/{xai-image-options.ts → xai-image-model-options.ts} +0 -0
package/README.md
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
The **[xAI Grok provider](https://ai-sdk.dev/providers/ai-sdk-providers/xai)** for the [AI SDK](https://ai-sdk.dev/docs)
|
|
4
4
|
contains language model support for the xAI chat and completion APIs.
|
|
5
5
|
|
|
6
|
+
> **Deploying to Vercel?** With Vercel's AI Gateway you can access xAI (and hundreds of models from other providers) — no additional packages, API keys, or extra cost. [Get started with AI Gateway](https://vercel.com/ai-gateway).
|
|
7
|
+
|
|
6
8
|
## Setup
|
|
7
9
|
|
|
8
10
|
The xAI Grok provider is available in the `@ai-sdk/xai` module. You can install it with
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
|
-
import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 } from '@ai-sdk/provider';
|
|
3
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
4
|
-
import { FetchFunction } from '@ai-sdk/provider-utils';
|
|
3
|
+
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
+
import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4, Experimental_RealtimeFactoryV4, SpeechModelV4, TranscriptionModelV4, FilesV4, Experimental_RealtimeModelV4, Experimental_RealtimeModelV4ClientSecretOptions, Experimental_RealtimeModelV4ClientSecretResult, Experimental_RealtimeModelV4ServerEvent, Experimental_RealtimeModelV4ClientEvent, Experimental_RealtimeModelV4SessionConfig } from '@ai-sdk/provider';
|
|
5
5
|
|
|
6
|
-
type XaiChatModelId = 'grok-4-
|
|
6
|
+
type XaiChatModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-latest' | (string & {});
|
|
7
7
|
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
none: "none";
|
|
9
10
|
low: "low";
|
|
11
|
+
medium: "medium";
|
|
10
12
|
high: "high";
|
|
11
13
|
}>>;
|
|
12
14
|
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -48,25 +50,34 @@ declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
|
48
50
|
}, z.core.$strip>;
|
|
49
51
|
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
50
52
|
|
|
51
|
-
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
53
|
+
declare const xaiErrorDataSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
52
54
|
error: z.ZodObject<{
|
|
53
55
|
message: z.ZodString;
|
|
54
56
|
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
57
|
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
56
58
|
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
57
59
|
}, z.core.$strip>;
|
|
58
|
-
}, z.core.$strip
|
|
60
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
61
|
+
code: z.ZodString;
|
|
62
|
+
error: z.ZodString;
|
|
63
|
+
}, z.core.$strip>]>;
|
|
59
64
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
65
|
|
|
61
|
-
type XaiResponsesModelId = 'grok-4-
|
|
66
|
+
type XaiResponsesModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-latest' | (string & {});
|
|
62
67
|
/**
|
|
63
68
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
64
69
|
*/
|
|
65
70
|
declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
|
|
66
71
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
72
|
+
none: "none";
|
|
67
73
|
low: "low";
|
|
68
|
-
high: "high";
|
|
69
74
|
medium: "medium";
|
|
75
|
+
high: "high";
|
|
76
|
+
}>>;
|
|
77
|
+
reasoningSummary: z.ZodOptional<z.ZodEnum<{
|
|
78
|
+
auto: "auto";
|
|
79
|
+
concise: "concise";
|
|
80
|
+
detailed: "detailed";
|
|
70
81
|
}>>;
|
|
71
82
|
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
72
83
|
topLogprobs: z.ZodOptional<z.ZodNumber>;
|
|
@@ -88,8 +99,8 @@ declare const xaiImageModelOptions: z.ZodObject<{
|
|
|
88
99
|
}>>;
|
|
89
100
|
quality: z.ZodOptional<z.ZodEnum<{
|
|
90
101
|
low: "low";
|
|
91
|
-
high: "high";
|
|
92
102
|
medium: "medium";
|
|
103
|
+
high: "high";
|
|
93
104
|
}>>;
|
|
94
105
|
user: z.ZodOptional<z.ZodString>;
|
|
95
106
|
}, z.core.$strip>;
|
|
@@ -97,26 +108,117 @@ type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
|
97
108
|
|
|
98
109
|
type XaiVideoModelId = 'grok-imagine-video' | (string & {});
|
|
99
110
|
|
|
100
|
-
|
|
111
|
+
declare const resolutionSchema: z.ZodEnum<{
|
|
112
|
+
"480p": "480p";
|
|
113
|
+
"720p": "720p";
|
|
114
|
+
}>;
|
|
115
|
+
type XaiVideoResolution = z.infer<typeof resolutionSchema>;
|
|
116
|
+
interface XaiVideoSharedOptions {
|
|
101
117
|
pollIntervalMs?: number | null;
|
|
102
118
|
pollTimeoutMs?: number | null;
|
|
103
|
-
resolution?:
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
119
|
+
resolution?: XaiVideoResolution | null;
|
|
120
|
+
}
|
|
121
|
+
interface XaiVideoEditModeOptions extends XaiVideoSharedOptions {
|
|
122
|
+
/**
|
|
123
|
+
* Select edit-video mode explicitly for best autocomplete and narrowing.
|
|
124
|
+
*/
|
|
125
|
+
mode: 'edit-video';
|
|
126
|
+
/** Source video URL to edit. */
|
|
127
|
+
videoUrl: string;
|
|
128
|
+
}
|
|
129
|
+
interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
|
|
130
|
+
/**
|
|
131
|
+
* Select extend-video mode explicitly for best autocomplete and narrowing.
|
|
132
|
+
*/
|
|
133
|
+
mode: 'extend-video';
|
|
134
|
+
/** Source video URL to extend from its last frame. */
|
|
135
|
+
videoUrl: string;
|
|
136
|
+
}
|
|
137
|
+
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
138
|
+
/**
|
|
139
|
+
* Select reference-to-video mode explicitly for best autocomplete and narrowing.
|
|
140
|
+
*/
|
|
141
|
+
mode: 'reference-to-video';
|
|
142
|
+
/** Reference image URLs (1-7) for R2V generation. */
|
|
143
|
+
referenceImageUrls: string[];
|
|
144
|
+
}
|
|
145
|
+
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions {
|
|
146
|
+
mode?: undefined;
|
|
147
|
+
videoUrl?: undefined;
|
|
148
|
+
referenceImageUrls?: undefined;
|
|
149
|
+
}
|
|
150
|
+
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
151
|
+
/**
|
|
152
|
+
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
153
|
+
* `videoUrl` behaves like edit-video.
|
|
154
|
+
*/
|
|
155
|
+
mode?: undefined;
|
|
156
|
+
videoUrl: string;
|
|
157
|
+
}
|
|
158
|
+
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
159
|
+
/**
|
|
160
|
+
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
161
|
+
* `referenceImageUrls` behaves like reference-to-video.
|
|
162
|
+
*/
|
|
163
|
+
mode?: undefined;
|
|
164
|
+
referenceImageUrls: string[];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Provider options for xAI video generation.
|
|
168
|
+
*
|
|
169
|
+
* Use the `mode` option to select the operation:
|
|
170
|
+
*
|
|
171
|
+
* - `'edit-video'` + `videoUrl` -- video editing (`POST /v1/videos/edits`)
|
|
172
|
+
* - `'extend-video'` + `videoUrl` -- video extension (`POST /v1/videos/extensions`)
|
|
173
|
+
* - `'reference-to-video'` + `referenceImageUrls` -- R2V generation (`POST /v1/videos/generations`)
|
|
174
|
+
* - no `mode` -- standard generation from text prompts or image input
|
|
175
|
+
*
|
|
176
|
+
* Runtime remains backward compatible with legacy auto-detected provider
|
|
177
|
+
* options, but the public TypeScript type is intentionally explicit so editors
|
|
178
|
+
* can suggest valid modes and flag invalid field combinations.
|
|
179
|
+
*/
|
|
180
|
+
type XaiVideoModelOptions = XaiVideoGenerationOptions | XaiVideoEditModeOptions | XaiVideoExtendModeOptions | XaiVideoReferenceToVideoOptions | XaiLegacyEditVideoOptions | XaiLegacyReferenceToVideoOptions;
|
|
181
|
+
|
|
182
|
+
declare const xaiSpeechModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
183
|
+
sampleRate?: 8000 | 16000 | 22050 | 24000 | 44100 | 48000 | null | undefined;
|
|
184
|
+
bitRate?: 32000 | 64000 | 96000 | 128000 | 192000 | null | undefined;
|
|
185
|
+
optimizeStreamingLatency?: 0 | 1 | 2 | null | undefined;
|
|
186
|
+
textNormalization?: boolean | null | undefined;
|
|
187
|
+
}>;
|
|
188
|
+
type XaiSpeechModelOptions = InferSchema<typeof xaiSpeechModelOptionsSchema>;
|
|
189
|
+
|
|
190
|
+
declare const xaiTranscriptionModelOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
191
|
+
audioFormat?: "pcm" | "mulaw" | "alaw" | null | undefined;
|
|
192
|
+
sampleRate?: 8000 | 16000 | 22050 | 24000 | 44100 | 48000 | null | undefined;
|
|
193
|
+
language?: string | null | undefined;
|
|
194
|
+
format?: boolean | null | undefined;
|
|
195
|
+
multichannel?: boolean | null | undefined;
|
|
196
|
+
channels?: number | null | undefined;
|
|
197
|
+
diarize?: boolean | null | undefined;
|
|
198
|
+
keyterm?: string | string[] | null | undefined;
|
|
199
|
+
fillerWords?: boolean | null | undefined;
|
|
200
|
+
}>;
|
|
201
|
+
type XaiTranscriptionModelOptions = InferSchema<typeof xaiTranscriptionModelOptionsSchema>;
|
|
202
|
+
|
|
203
|
+
declare const xaiFilesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
204
|
+
[x: string]: unknown;
|
|
205
|
+
teamId?: string | undefined;
|
|
206
|
+
filePath?: string | undefined;
|
|
207
|
+
}>;
|
|
208
|
+
type XaiFilesOptions = InferSchema<typeof xaiFilesOptionsSchema>;
|
|
107
209
|
|
|
108
210
|
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
109
211
|
|
|
110
|
-
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.
|
|
212
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
111
213
|
output: string;
|
|
112
214
|
error?: string | undefined;
|
|
113
|
-
}, object>;
|
|
114
|
-
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
215
|
+
}, object, {}>;
|
|
216
|
+
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
115
217
|
output: string;
|
|
116
218
|
error?: string | undefined;
|
|
117
|
-
}>;
|
|
219
|
+
}, {}>;
|
|
118
220
|
|
|
119
|
-
declare const mcpServerToolFactory: _ai_sdk_provider_utils.
|
|
221
|
+
declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
120
222
|
name: string;
|
|
121
223
|
arguments: string;
|
|
122
224
|
result: unknown;
|
|
@@ -127,34 +229,34 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
127
229
|
allowedTools?: string[];
|
|
128
230
|
headers?: Record<string, string>;
|
|
129
231
|
authorization?: string;
|
|
130
|
-
}>;
|
|
131
|
-
declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
232
|
+
}, {}>;
|
|
233
|
+
declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
132
234
|
name: string;
|
|
133
235
|
arguments: string;
|
|
134
236
|
result: unknown;
|
|
135
|
-
}>;
|
|
237
|
+
}, {}>;
|
|
136
238
|
|
|
137
|
-
declare const viewImageToolFactory: _ai_sdk_provider_utils.
|
|
239
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
138
240
|
description: string;
|
|
139
241
|
objects?: string[] | undefined;
|
|
140
|
-
}, object>;
|
|
141
|
-
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
242
|
+
}, object, {}>;
|
|
243
|
+
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
142
244
|
description: string;
|
|
143
245
|
objects?: string[] | undefined;
|
|
144
|
-
}>;
|
|
246
|
+
}, {}>;
|
|
145
247
|
|
|
146
|
-
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.
|
|
248
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
147
249
|
description: string;
|
|
148
250
|
transcript?: string | undefined;
|
|
149
251
|
duration?: number | undefined;
|
|
150
|
-
}, object>;
|
|
151
|
-
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
252
|
+
}, object, {}>;
|
|
253
|
+
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
152
254
|
description: string;
|
|
153
255
|
transcript?: string | undefined;
|
|
154
256
|
duration?: number | undefined;
|
|
155
|
-
}>;
|
|
257
|
+
}, {}>;
|
|
156
258
|
|
|
157
|
-
declare const webSearchToolFactory: _ai_sdk_provider_utils.
|
|
259
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
158
260
|
query: string;
|
|
159
261
|
sources: Array<{
|
|
160
262
|
title: string;
|
|
@@ -164,18 +266,19 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
164
266
|
}, {
|
|
165
267
|
allowedDomains?: string[];
|
|
166
268
|
excludedDomains?: string[];
|
|
269
|
+
enableImageSearch?: boolean;
|
|
167
270
|
enableImageUnderstanding?: boolean;
|
|
168
|
-
}>;
|
|
169
|
-
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
271
|
+
}, {}>;
|
|
272
|
+
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
170
273
|
query: string;
|
|
171
274
|
sources: Array<{
|
|
172
275
|
title: string;
|
|
173
276
|
url: string;
|
|
174
277
|
snippet: string;
|
|
175
278
|
}>;
|
|
176
|
-
}>;
|
|
279
|
+
}, {}>;
|
|
177
280
|
|
|
178
|
-
declare const xSearchToolFactory: _ai_sdk_provider_utils.
|
|
281
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
179
282
|
query: string;
|
|
180
283
|
posts: Array<{
|
|
181
284
|
author: string;
|
|
@@ -190,8 +293,8 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
|
|
|
190
293
|
toDate?: string;
|
|
191
294
|
enableImageUnderstanding?: boolean;
|
|
192
295
|
enableVideoUnderstanding?: boolean;
|
|
193
|
-
}>;
|
|
194
|
-
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.
|
|
296
|
+
}, {}>;
|
|
297
|
+
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
195
298
|
query: string;
|
|
196
299
|
posts: Array<{
|
|
197
300
|
author: string;
|
|
@@ -199,17 +302,17 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
|
|
|
199
302
|
url: string;
|
|
200
303
|
likes: number;
|
|
201
304
|
}>;
|
|
202
|
-
}>;
|
|
305
|
+
}, {}>;
|
|
203
306
|
|
|
204
307
|
declare const xaiTools: {
|
|
205
|
-
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.
|
|
308
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
206
309
|
output: string;
|
|
207
310
|
error?: string | undefined;
|
|
208
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
311
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
209
312
|
output: string;
|
|
210
313
|
error?: string | undefined;
|
|
211
|
-
}>;
|
|
212
|
-
fileSearch: (args: Parameters<_ai_sdk_provider_utils.
|
|
314
|
+
}, {}>;
|
|
315
|
+
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
213
316
|
queries: string[];
|
|
214
317
|
results: null | {
|
|
215
318
|
fileId: string;
|
|
@@ -220,7 +323,7 @@ declare const xaiTools: {
|
|
|
220
323
|
}, {
|
|
221
324
|
vectorStoreIds: string[];
|
|
222
325
|
maxNumResults?: number;
|
|
223
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
326
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
224
327
|
queries: string[];
|
|
225
328
|
results: null | {
|
|
226
329
|
fileId: string;
|
|
@@ -228,8 +331,8 @@ declare const xaiTools: {
|
|
|
228
331
|
score: number;
|
|
229
332
|
text: string;
|
|
230
333
|
}[];
|
|
231
|
-
}>;
|
|
232
|
-
mcpServer: (args: Parameters<_ai_sdk_provider_utils.
|
|
334
|
+
}, {}>;
|
|
335
|
+
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
233
336
|
name: string;
|
|
234
337
|
arguments: string;
|
|
235
338
|
result: unknown;
|
|
@@ -240,28 +343,28 @@ declare const xaiTools: {
|
|
|
240
343
|
allowedTools?: string[];
|
|
241
344
|
headers?: Record<string, string>;
|
|
242
345
|
authorization?: string;
|
|
243
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
346
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
244
347
|
name: string;
|
|
245
348
|
arguments: string;
|
|
246
349
|
result: unknown;
|
|
247
|
-
}>;
|
|
248
|
-
viewImage: (args?: Parameters<_ai_sdk_provider_utils.
|
|
350
|
+
}, {}>;
|
|
351
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
249
352
|
description: string;
|
|
250
353
|
objects?: string[] | undefined;
|
|
251
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
354
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
252
355
|
description: string;
|
|
253
356
|
objects?: string[] | undefined;
|
|
254
|
-
}>;
|
|
255
|
-
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.
|
|
357
|
+
}, {}>;
|
|
358
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
256
359
|
description: string;
|
|
257
360
|
transcript?: string | undefined;
|
|
258
361
|
duration?: number | undefined;
|
|
259
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
362
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
260
363
|
description: string;
|
|
261
364
|
transcript?: string | undefined;
|
|
262
365
|
duration?: number | undefined;
|
|
263
|
-
}>;
|
|
264
|
-
webSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
366
|
+
}, {}>;
|
|
367
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
265
368
|
query: string;
|
|
266
369
|
sources: Array<{
|
|
267
370
|
title: string;
|
|
@@ -271,16 +374,17 @@ declare const xaiTools: {
|
|
|
271
374
|
}, {
|
|
272
375
|
allowedDomains?: string[];
|
|
273
376
|
excludedDomains?: string[];
|
|
377
|
+
enableImageSearch?: boolean;
|
|
274
378
|
enableImageUnderstanding?: boolean;
|
|
275
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
379
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
276
380
|
query: string;
|
|
277
381
|
sources: Array<{
|
|
278
382
|
title: string;
|
|
279
383
|
url: string;
|
|
280
384
|
snippet: string;
|
|
281
385
|
}>;
|
|
282
|
-
}>;
|
|
283
|
-
xSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
386
|
+
}, {}>;
|
|
387
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
284
388
|
query: string;
|
|
285
389
|
posts: Array<{
|
|
286
390
|
author: string;
|
|
@@ -295,7 +399,7 @@ declare const xaiTools: {
|
|
|
295
399
|
toDate?: string;
|
|
296
400
|
enableImageUnderstanding?: boolean;
|
|
297
401
|
enableVideoUnderstanding?: boolean;
|
|
298
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
402
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
299
403
|
query: string;
|
|
300
404
|
posts: Array<{
|
|
301
405
|
author: string;
|
|
@@ -303,39 +407,60 @@ declare const xaiTools: {
|
|
|
303
407
|
url: string;
|
|
304
408
|
likes: number;
|
|
305
409
|
}>;
|
|
306
|
-
}>;
|
|
410
|
+
}, {}>;
|
|
307
411
|
};
|
|
308
412
|
|
|
309
|
-
interface XaiProvider extends
|
|
310
|
-
(modelId: XaiResponsesModelId):
|
|
413
|
+
interface XaiProvider extends ProviderV4 {
|
|
414
|
+
(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
311
415
|
/**
|
|
312
416
|
* Creates an Xai language model for text generation.
|
|
313
417
|
*/
|
|
314
|
-
languageModel(modelId: XaiResponsesModelId):
|
|
418
|
+
languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
315
419
|
/**
|
|
316
420
|
* Creates an Xai chat model for text generation.
|
|
317
421
|
*/
|
|
318
|
-
chat: (modelId: XaiChatModelId) =>
|
|
422
|
+
chat: (modelId: XaiChatModelId) => LanguageModelV4;
|
|
319
423
|
/**
|
|
320
424
|
* Creates an Xai responses model for text generation.
|
|
321
425
|
*/
|
|
322
|
-
responses: (modelId: XaiResponsesModelId) =>
|
|
426
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
|
|
323
427
|
/**
|
|
324
428
|
* Creates an Xai image model for image generation.
|
|
325
429
|
*/
|
|
326
|
-
image(modelId: XaiImageModelId):
|
|
430
|
+
image(modelId: XaiImageModelId): ImageModelV4;
|
|
327
431
|
/**
|
|
328
432
|
* Creates an Xai image model for image generation.
|
|
329
433
|
*/
|
|
330
|
-
imageModel(modelId: XaiImageModelId):
|
|
434
|
+
imageModel(modelId: XaiImageModelId): ImageModelV4;
|
|
331
435
|
/**
|
|
332
436
|
* Creates an Xai video model for video generation.
|
|
333
437
|
*/
|
|
334
|
-
video(modelId: XaiVideoModelId):
|
|
438
|
+
video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
335
439
|
/**
|
|
336
440
|
* Creates an Xai video model for video generation.
|
|
337
441
|
*/
|
|
338
|
-
videoModel(modelId: XaiVideoModelId):
|
|
442
|
+
videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
443
|
+
experimental_realtime: Experimental_RealtimeFactoryV4;
|
|
444
|
+
/**
|
|
445
|
+
* Creates an xAI model for speech generation (text-to-speech).
|
|
446
|
+
*/
|
|
447
|
+
speech(): SpeechModelV4;
|
|
448
|
+
/**
|
|
449
|
+
* Creates an xAI model for speech generation (text-to-speech).
|
|
450
|
+
*/
|
|
451
|
+
speechModel(): SpeechModelV4;
|
|
452
|
+
/**
|
|
453
|
+
* Creates an xAI model for speech-to-text transcription.
|
|
454
|
+
*/
|
|
455
|
+
transcription(): TranscriptionModelV4;
|
|
456
|
+
/**
|
|
457
|
+
* Creates an xAI model for speech-to-text transcription.
|
|
458
|
+
*/
|
|
459
|
+
transcriptionModel(): TranscriptionModelV4;
|
|
460
|
+
/**
|
|
461
|
+
* Returns the xAI files interface for uploading files.
|
|
462
|
+
*/
|
|
463
|
+
files(): FilesV4;
|
|
339
464
|
/**
|
|
340
465
|
* Server-side agentic tools for use with the responses API.
|
|
341
466
|
*/
|
|
@@ -367,6 +492,31 @@ interface XaiProviderSettings {
|
|
|
367
492
|
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
|
368
493
|
declare const xai: XaiProvider;
|
|
369
494
|
|
|
495
|
+
type XaiRealtimeModelConfig = {
|
|
496
|
+
provider: string;
|
|
497
|
+
baseURL: string;
|
|
498
|
+
headers: () => Record<string, string | undefined>;
|
|
499
|
+
fetch?: FetchFunction;
|
|
500
|
+
};
|
|
501
|
+
declare class XaiRealtimeModel implements Experimental_RealtimeModelV4 {
|
|
502
|
+
readonly specificationVersion: "v4";
|
|
503
|
+
readonly provider: string;
|
|
504
|
+
readonly modelId: string;
|
|
505
|
+
private readonly config;
|
|
506
|
+
constructor(modelId: string, config: XaiRealtimeModelConfig);
|
|
507
|
+
doCreateClientSecret(options: Experimental_RealtimeModelV4ClientSecretOptions): Promise<Experimental_RealtimeModelV4ClientSecretResult>;
|
|
508
|
+
getWebSocketConfig(options: {
|
|
509
|
+
token: string;
|
|
510
|
+
url: string;
|
|
511
|
+
}): {
|
|
512
|
+
url: string;
|
|
513
|
+
protocols?: string[];
|
|
514
|
+
};
|
|
515
|
+
parseServerEvent(raw: unknown): Experimental_RealtimeModelV4ServerEvent;
|
|
516
|
+
serializeClientEvent(event: Experimental_RealtimeModelV4ClientEvent): unknown;
|
|
517
|
+
buildSessionConfig(config: Experimental_RealtimeModelV4SessionConfig): Record<string, unknown>;
|
|
518
|
+
}
|
|
519
|
+
|
|
370
520
|
declare const VERSION: string;
|
|
371
521
|
|
|
372
|
-
export { VERSION, type XaiErrorData, type XaiImageModelOptions, type XaiImageModelOptions as XaiImageProviderOptions, type XaiLanguageModelChatOptions, type XaiLanguageModelResponsesOptions, type XaiProvider, type XaiLanguageModelChatOptions as XaiProviderOptions, type XaiProviderSettings, type XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions, type XaiVideoModelId, type XaiVideoModelOptions, type XaiVideoModelOptions as XaiVideoProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|
|
522
|
+
export { XaiRealtimeModel as Experimental_XaiRealtimeModel, type XaiRealtimeModelConfig as Experimental_XaiRealtimeModelConfig, VERSION, type XaiErrorData, type XaiFilesOptions, type XaiImageModelOptions, type XaiImageModelOptions as XaiImageProviderOptions, type XaiLanguageModelChatOptions, type XaiLanguageModelResponsesOptions, type XaiProvider, type XaiLanguageModelChatOptions as XaiProviderOptions, type XaiProviderSettings, type XaiLanguageModelResponsesOptions as XaiResponsesProviderOptions, type XaiSpeechModelOptions, type XaiTranscriptionModelOptions, type XaiVideoModelId, type XaiVideoModelOptions, type XaiVideoModelOptions as XaiVideoProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|