@ai-sdk/xai 4.0.0-beta.7 → 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 +660 -9
- package/README.md +2 -0
- package/dist/index.d.ts +213 -68
- package/dist/index.js +2074 -781
- 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 +31 -1
- package/src/responses/{xai-responses-options.ts → xai-responses-language-model-options.ts} +12 -7
- package/src/responses/xai-responses-language-model.ts +157 -60
- 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 -377
- package/dist/index.mjs +0 -3070
- 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,29 @@ 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";
|
|
70
76
|
}>>;
|
|
71
77
|
reasoningSummary: z.ZodOptional<z.ZodEnum<{
|
|
72
78
|
auto: "auto";
|
|
@@ -93,8 +99,8 @@ declare const xaiImageModelOptions: z.ZodObject<{
|
|
|
93
99
|
}>>;
|
|
94
100
|
quality: z.ZodOptional<z.ZodEnum<{
|
|
95
101
|
low: "low";
|
|
96
|
-
high: "high";
|
|
97
102
|
medium: "medium";
|
|
103
|
+
high: "high";
|
|
98
104
|
}>>;
|
|
99
105
|
user: z.ZodOptional<z.ZodString>;
|
|
100
106
|
}, z.core.$strip>;
|
|
@@ -102,26 +108,117 @@ type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
|
102
108
|
|
|
103
109
|
type XaiVideoModelId = 'grok-imagine-video' | (string & {});
|
|
104
110
|
|
|
105
|
-
|
|
111
|
+
declare const resolutionSchema: z.ZodEnum<{
|
|
112
|
+
"480p": "480p";
|
|
113
|
+
"720p": "720p";
|
|
114
|
+
}>;
|
|
115
|
+
type XaiVideoResolution = z.infer<typeof resolutionSchema>;
|
|
116
|
+
interface XaiVideoSharedOptions {
|
|
106
117
|
pollIntervalMs?: number | null;
|
|
107
118
|
pollTimeoutMs?: number | null;
|
|
108
|
-
resolution?:
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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>;
|
|
112
209
|
|
|
113
210
|
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
114
211
|
|
|
115
|
-
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.
|
|
212
|
+
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
116
213
|
output: string;
|
|
117
214
|
error?: string | undefined;
|
|
118
|
-
}, object>;
|
|
119
|
-
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>, {
|
|
120
217
|
output: string;
|
|
121
218
|
error?: string | undefined;
|
|
122
|
-
}>;
|
|
219
|
+
}, {}>;
|
|
123
220
|
|
|
124
|
-
declare const mcpServerToolFactory: _ai_sdk_provider_utils.
|
|
221
|
+
declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
125
222
|
name: string;
|
|
126
223
|
arguments: string;
|
|
127
224
|
result: unknown;
|
|
@@ -132,34 +229,34 @@ declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
132
229
|
allowedTools?: string[];
|
|
133
230
|
headers?: Record<string, string>;
|
|
134
231
|
authorization?: string;
|
|
135
|
-
}>;
|
|
136
|
-
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<{}, {
|
|
137
234
|
name: string;
|
|
138
235
|
arguments: string;
|
|
139
236
|
result: unknown;
|
|
140
|
-
}>;
|
|
237
|
+
}, {}>;
|
|
141
238
|
|
|
142
|
-
declare const viewImageToolFactory: _ai_sdk_provider_utils.
|
|
239
|
+
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
143
240
|
description: string;
|
|
144
241
|
objects?: string[] | undefined;
|
|
145
|
-
}, object>;
|
|
146
|
-
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>, {
|
|
147
244
|
description: string;
|
|
148
245
|
objects?: string[] | undefined;
|
|
149
|
-
}>;
|
|
246
|
+
}, {}>;
|
|
150
247
|
|
|
151
|
-
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.
|
|
248
|
+
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
152
249
|
description: string;
|
|
153
250
|
transcript?: string | undefined;
|
|
154
251
|
duration?: number | undefined;
|
|
155
|
-
}, object>;
|
|
156
|
-
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>, {
|
|
157
254
|
description: string;
|
|
158
255
|
transcript?: string | undefined;
|
|
159
256
|
duration?: number | undefined;
|
|
160
|
-
}>;
|
|
257
|
+
}, {}>;
|
|
161
258
|
|
|
162
|
-
declare const webSearchToolFactory: _ai_sdk_provider_utils.
|
|
259
|
+
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
163
260
|
query: string;
|
|
164
261
|
sources: Array<{
|
|
165
262
|
title: string;
|
|
@@ -169,18 +266,19 @@ declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWi
|
|
|
169
266
|
}, {
|
|
170
267
|
allowedDomains?: string[];
|
|
171
268
|
excludedDomains?: string[];
|
|
269
|
+
enableImageSearch?: boolean;
|
|
172
270
|
enableImageUnderstanding?: boolean;
|
|
173
|
-
}>;
|
|
174
|
-
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<{}, {
|
|
175
273
|
query: string;
|
|
176
274
|
sources: Array<{
|
|
177
275
|
title: string;
|
|
178
276
|
url: string;
|
|
179
277
|
snippet: string;
|
|
180
278
|
}>;
|
|
181
|
-
}>;
|
|
279
|
+
}, {}>;
|
|
182
280
|
|
|
183
|
-
declare const xSearchToolFactory: _ai_sdk_provider_utils.
|
|
281
|
+
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
184
282
|
query: string;
|
|
185
283
|
posts: Array<{
|
|
186
284
|
author: string;
|
|
@@ -195,8 +293,8 @@ declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWith
|
|
|
195
293
|
toDate?: string;
|
|
196
294
|
enableImageUnderstanding?: boolean;
|
|
197
295
|
enableVideoUnderstanding?: boolean;
|
|
198
|
-
}>;
|
|
199
|
-
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<{}, {
|
|
200
298
|
query: string;
|
|
201
299
|
posts: Array<{
|
|
202
300
|
author: string;
|
|
@@ -204,17 +302,17 @@ declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_
|
|
|
204
302
|
url: string;
|
|
205
303
|
likes: number;
|
|
206
304
|
}>;
|
|
207
|
-
}>;
|
|
305
|
+
}, {}>;
|
|
208
306
|
|
|
209
307
|
declare const xaiTools: {
|
|
210
|
-
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.
|
|
308
|
+
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
211
309
|
output: string;
|
|
212
310
|
error?: string | undefined;
|
|
213
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
311
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
214
312
|
output: string;
|
|
215
313
|
error?: string | undefined;
|
|
216
|
-
}>;
|
|
217
|
-
fileSearch: (args: Parameters<_ai_sdk_provider_utils.
|
|
314
|
+
}, {}>;
|
|
315
|
+
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
218
316
|
queries: string[];
|
|
219
317
|
results: null | {
|
|
220
318
|
fileId: string;
|
|
@@ -225,7 +323,7 @@ declare const xaiTools: {
|
|
|
225
323
|
}, {
|
|
226
324
|
vectorStoreIds: string[];
|
|
227
325
|
maxNumResults?: number;
|
|
228
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
326
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
229
327
|
queries: string[];
|
|
230
328
|
results: null | {
|
|
231
329
|
fileId: string;
|
|
@@ -233,8 +331,8 @@ declare const xaiTools: {
|
|
|
233
331
|
score: number;
|
|
234
332
|
text: string;
|
|
235
333
|
}[];
|
|
236
|
-
}>;
|
|
237
|
-
mcpServer: (args: Parameters<_ai_sdk_provider_utils.
|
|
334
|
+
}, {}>;
|
|
335
|
+
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
238
336
|
name: string;
|
|
239
337
|
arguments: string;
|
|
240
338
|
result: unknown;
|
|
@@ -245,28 +343,28 @@ declare const xaiTools: {
|
|
|
245
343
|
allowedTools?: string[];
|
|
246
344
|
headers?: Record<string, string>;
|
|
247
345
|
authorization?: string;
|
|
248
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
346
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
249
347
|
name: string;
|
|
250
348
|
arguments: string;
|
|
251
349
|
result: unknown;
|
|
252
|
-
}>;
|
|
253
|
-
viewImage: (args?: Parameters<_ai_sdk_provider_utils.
|
|
350
|
+
}, {}>;
|
|
351
|
+
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
254
352
|
description: string;
|
|
255
353
|
objects?: string[] | undefined;
|
|
256
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
354
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
257
355
|
description: string;
|
|
258
356
|
objects?: string[] | undefined;
|
|
259
|
-
}>;
|
|
260
|
-
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.
|
|
357
|
+
}, {}>;
|
|
358
|
+
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<Record<string, never>, {
|
|
261
359
|
description: string;
|
|
262
360
|
transcript?: string | undefined;
|
|
263
361
|
duration?: number | undefined;
|
|
264
|
-
}, object>>[0]) => _ai_sdk_provider_utils.
|
|
362
|
+
}, object, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<Record<string, never>, {
|
|
265
363
|
description: string;
|
|
266
364
|
transcript?: string | undefined;
|
|
267
365
|
duration?: number | undefined;
|
|
268
|
-
}>;
|
|
269
|
-
webSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
366
|
+
}, {}>;
|
|
367
|
+
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
270
368
|
query: string;
|
|
271
369
|
sources: Array<{
|
|
272
370
|
title: string;
|
|
@@ -276,16 +374,17 @@ declare const xaiTools: {
|
|
|
276
374
|
}, {
|
|
277
375
|
allowedDomains?: string[];
|
|
278
376
|
excludedDomains?: string[];
|
|
377
|
+
enableImageSearch?: boolean;
|
|
279
378
|
enableImageUnderstanding?: boolean;
|
|
280
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
379
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
281
380
|
query: string;
|
|
282
381
|
sources: Array<{
|
|
283
382
|
title: string;
|
|
284
383
|
url: string;
|
|
285
384
|
snippet: string;
|
|
286
385
|
}>;
|
|
287
|
-
}>;
|
|
288
|
-
xSearch: (args?: Parameters<_ai_sdk_provider_utils.
|
|
386
|
+
}, {}>;
|
|
387
|
+
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderExecutedToolFactory<{}, {
|
|
289
388
|
query: string;
|
|
290
389
|
posts: Array<{
|
|
291
390
|
author: string;
|
|
@@ -300,7 +399,7 @@ declare const xaiTools: {
|
|
|
300
399
|
toDate?: string;
|
|
301
400
|
enableImageUnderstanding?: boolean;
|
|
302
401
|
enableVideoUnderstanding?: boolean;
|
|
303
|
-
}>>[0]) => _ai_sdk_provider_utils.
|
|
402
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
|
|
304
403
|
query: string;
|
|
305
404
|
posts: Array<{
|
|
306
405
|
author: string;
|
|
@@ -308,39 +407,60 @@ declare const xaiTools: {
|
|
|
308
407
|
url: string;
|
|
309
408
|
likes: number;
|
|
310
409
|
}>;
|
|
311
|
-
}>;
|
|
410
|
+
}, {}>;
|
|
312
411
|
};
|
|
313
412
|
|
|
314
|
-
interface XaiProvider extends
|
|
315
|
-
(modelId: XaiResponsesModelId):
|
|
413
|
+
interface XaiProvider extends ProviderV4 {
|
|
414
|
+
(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
316
415
|
/**
|
|
317
416
|
* Creates an Xai language model for text generation.
|
|
318
417
|
*/
|
|
319
|
-
languageModel(modelId: XaiResponsesModelId):
|
|
418
|
+
languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
320
419
|
/**
|
|
321
420
|
* Creates an Xai chat model for text generation.
|
|
322
421
|
*/
|
|
323
|
-
chat: (modelId: XaiChatModelId) =>
|
|
422
|
+
chat: (modelId: XaiChatModelId) => LanguageModelV4;
|
|
324
423
|
/**
|
|
325
424
|
* Creates an Xai responses model for text generation.
|
|
326
425
|
*/
|
|
327
|
-
responses: (modelId: XaiResponsesModelId) =>
|
|
426
|
+
responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
|
|
328
427
|
/**
|
|
329
428
|
* Creates an Xai image model for image generation.
|
|
330
429
|
*/
|
|
331
|
-
image(modelId: XaiImageModelId):
|
|
430
|
+
image(modelId: XaiImageModelId): ImageModelV4;
|
|
332
431
|
/**
|
|
333
432
|
* Creates an Xai image model for image generation.
|
|
334
433
|
*/
|
|
335
|
-
imageModel(modelId: XaiImageModelId):
|
|
434
|
+
imageModel(modelId: XaiImageModelId): ImageModelV4;
|
|
336
435
|
/**
|
|
337
436
|
* Creates an Xai video model for video generation.
|
|
338
437
|
*/
|
|
339
|
-
video(modelId: XaiVideoModelId):
|
|
438
|
+
video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
340
439
|
/**
|
|
341
440
|
* Creates an Xai video model for video generation.
|
|
342
441
|
*/
|
|
343
|
-
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;
|
|
344
464
|
/**
|
|
345
465
|
* Server-side agentic tools for use with the responses API.
|
|
346
466
|
*/
|
|
@@ -372,6 +492,31 @@ interface XaiProviderSettings {
|
|
|
372
492
|
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
|
373
493
|
declare const xai: XaiProvider;
|
|
374
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
|
+
|
|
375
520
|
declare const VERSION: string;
|
|
376
521
|
|
|
377
|
-
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 };
|