@ai-sdk/xai 4.0.0-beta.34 → 4.0.0-beta.36
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 +31 -0
- package/dist/index.js +847 -763
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
- package/src/responses/xai-responses-language-model.ts +20 -3
- package/src/xai-chat-language-model.ts +20 -3
- package/src/xai-image-model.ts +19 -2
- package/dist/index.d.mts +0 -451
- package/dist/index.mjs +0 -3390
- package/dist/index.mjs.map +0 -1
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.36",
|
|
4
|
+
"type": "module",
|
|
4
5
|
"license": "Apache-2.0",
|
|
5
6
|
"sideEffects": false,
|
|
6
7
|
"main": "./dist/index.js",
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
8
8
|
"types": "./dist/index.d.ts",
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/**/*",
|
|
@@ -24,21 +24,21 @@
|
|
|
24
24
|
"./package.json": "./package.json",
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
|
-
"import": "./dist/index.
|
|
28
|
-
"
|
|
27
|
+
"import": "./dist/index.js",
|
|
28
|
+
"default": "./dist/index.js"
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "3.0.0-beta.
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.0-beta.
|
|
34
|
-
"@ai-sdk/provider": "4.0.0-beta.
|
|
32
|
+
"@ai-sdk/openai-compatible": "3.0.0-beta.25",
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.0-beta.20",
|
|
34
|
+
"@ai-sdk/provider": "4.0.0-beta.12"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
|
38
38
|
"tsup": "^8",
|
|
39
39
|
"typescript": "5.8.3",
|
|
40
40
|
"zod": "3.25.76",
|
|
41
|
-
"@ai-sdk/test-server": "2.0.0-beta.
|
|
41
|
+
"@ai-sdk/test-server": "2.0.0-beta.1",
|
|
42
42
|
"@vercel/ai-tsconfig": "0.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
parseProviderOptions,
|
|
20
20
|
ParseResult,
|
|
21
21
|
postJsonToApi,
|
|
22
|
+
serializeModelOptions,
|
|
23
|
+
WORKFLOW_SERIALIZE,
|
|
24
|
+
WORKFLOW_DESERIALIZE,
|
|
22
25
|
} from '@ai-sdk/provider-utils';
|
|
23
26
|
import { z } from 'zod/v4';
|
|
24
27
|
import { getResponseMetadata } from '../get-response-metadata';
|
|
@@ -40,7 +43,7 @@ import { prepareResponsesTools } from './xai-responses-prepare-tools';
|
|
|
40
43
|
type XaiResponsesConfig = {
|
|
41
44
|
provider: string;
|
|
42
45
|
baseURL: string | undefined;
|
|
43
|
-
headers
|
|
46
|
+
headers?: () => Record<string, string | undefined>;
|
|
44
47
|
generateId: () => string;
|
|
45
48
|
fetch?: FetchFunction;
|
|
46
49
|
};
|
|
@@ -52,6 +55,20 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
|
|
|
52
55
|
|
|
53
56
|
private readonly config: XaiResponsesConfig;
|
|
54
57
|
|
|
58
|
+
static [WORKFLOW_SERIALIZE](model: XaiResponsesLanguageModel) {
|
|
59
|
+
return serializeModelOptions({
|
|
60
|
+
modelId: model.modelId,
|
|
61
|
+
config: model.config,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
66
|
+
modelId: XaiResponsesModelId;
|
|
67
|
+
config: XaiResponsesConfig;
|
|
68
|
+
}) {
|
|
69
|
+
return new XaiResponsesLanguageModel(options.modelId, options.config);
|
|
70
|
+
}
|
|
71
|
+
|
|
55
72
|
constructor(modelId: XaiResponsesModelId, config: XaiResponsesConfig) {
|
|
56
73
|
this.modelId = modelId;
|
|
57
74
|
this.config = config;
|
|
@@ -246,7 +263,7 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
|
|
|
246
263
|
rawValue: rawResponse,
|
|
247
264
|
} = await postJsonToApi({
|
|
248
265
|
url: `${this.config.baseURL ?? 'https://api.x.ai/v1'}/responses`,
|
|
249
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
266
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
250
267
|
body,
|
|
251
268
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
252
269
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -473,7 +490,7 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
|
|
|
473
490
|
|
|
474
491
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
475
492
|
url: `${this.config.baseURL ?? 'https://api.x.ai/v1'}/responses`,
|
|
476
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
493
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
477
494
|
body,
|
|
478
495
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
479
496
|
successfulResponseHandler: createEventSourceResponseHandler(
|
|
@@ -22,6 +22,9 @@ import {
|
|
|
22
22
|
ParseResult,
|
|
23
23
|
postJsonToApi,
|
|
24
24
|
safeParseJSON,
|
|
25
|
+
serializeModelOptions,
|
|
26
|
+
WORKFLOW_SERIALIZE,
|
|
27
|
+
WORKFLOW_DESERIALIZE,
|
|
25
28
|
} from '@ai-sdk/provider-utils';
|
|
26
29
|
import { z } from 'zod/v4';
|
|
27
30
|
import { convertToXaiChatMessages } from './convert-to-xai-chat-messages';
|
|
@@ -38,7 +41,7 @@ import { prepareTools } from './xai-prepare-tools';
|
|
|
38
41
|
type XaiChatConfig = {
|
|
39
42
|
provider: string;
|
|
40
43
|
baseURL: string | undefined;
|
|
41
|
-
headers
|
|
44
|
+
headers?: () => Record<string, string | undefined>;
|
|
42
45
|
generateId: () => string;
|
|
43
46
|
fetch?: FetchFunction;
|
|
44
47
|
};
|
|
@@ -50,6 +53,20 @@ export class XaiChatLanguageModel implements LanguageModelV4 {
|
|
|
50
53
|
|
|
51
54
|
private readonly config: XaiChatConfig;
|
|
52
55
|
|
|
56
|
+
static [WORKFLOW_SERIALIZE](model: XaiChatLanguageModel) {
|
|
57
|
+
return serializeModelOptions({
|
|
58
|
+
modelId: model.modelId,
|
|
59
|
+
config: model.config,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
64
|
+
modelId: XaiChatModelId;
|
|
65
|
+
config: XaiChatConfig;
|
|
66
|
+
}) {
|
|
67
|
+
return new XaiChatLanguageModel(options.modelId, options.config);
|
|
68
|
+
}
|
|
69
|
+
|
|
53
70
|
constructor(modelId: XaiChatModelId, config: XaiChatConfig) {
|
|
54
71
|
this.modelId = modelId;
|
|
55
72
|
this.config = config;
|
|
@@ -233,7 +250,7 @@ export class XaiChatLanguageModel implements LanguageModelV4 {
|
|
|
233
250
|
rawValue: rawResponse,
|
|
234
251
|
} = await postJsonToApi({
|
|
235
252
|
url,
|
|
236
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
253
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
237
254
|
body,
|
|
238
255
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
239
256
|
successfulResponseHandler: createJsonResponseHandler(
|
|
@@ -346,7 +363,7 @@ export class XaiChatLanguageModel implements LanguageModelV4 {
|
|
|
346
363
|
|
|
347
364
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
348
365
|
url,
|
|
349
|
-
headers: combineHeaders(this.config.headers(), options.headers),
|
|
366
|
+
headers: combineHeaders(this.config.headers?.(), options.headers),
|
|
350
367
|
body,
|
|
351
368
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
352
369
|
successfulResponseHandler: async ({ response }) => {
|
package/src/xai-image-model.ts
CHANGED
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
getFromApi,
|
|
10
10
|
parseProviderOptions,
|
|
11
11
|
postJsonToApi,
|
|
12
|
+
serializeModelOptions,
|
|
13
|
+
WORKFLOW_SERIALIZE,
|
|
14
|
+
WORKFLOW_DESERIALIZE,
|
|
12
15
|
} from '@ai-sdk/provider-utils';
|
|
13
16
|
import { z } from 'zod/v4';
|
|
14
17
|
import { xaiFailedResponseHandler } from './xai-error';
|
|
@@ -18,7 +21,7 @@ import { XaiImageModelId } from './xai-image-settings';
|
|
|
18
21
|
interface XaiImageModelConfig {
|
|
19
22
|
provider: string;
|
|
20
23
|
baseURL: string | undefined;
|
|
21
|
-
headers
|
|
24
|
+
headers?: () => Record<string, string | undefined>;
|
|
22
25
|
fetch?: FetchFunction;
|
|
23
26
|
_internal?: {
|
|
24
27
|
currentDate?: () => Date;
|
|
@@ -33,6 +36,20 @@ export class XaiImageModel implements ImageModelV4 {
|
|
|
33
36
|
return this.config.provider;
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
static [WORKFLOW_SERIALIZE](model: XaiImageModel) {
|
|
40
|
+
return serializeModelOptions({
|
|
41
|
+
modelId: model.modelId,
|
|
42
|
+
config: model.config,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static [WORKFLOW_DESERIALIZE](options: {
|
|
47
|
+
modelId: XaiImageModelId;
|
|
48
|
+
config: XaiImageModelConfig;
|
|
49
|
+
}) {
|
|
50
|
+
return new XaiImageModel(options.modelId, options.config);
|
|
51
|
+
}
|
|
52
|
+
|
|
36
53
|
constructor(
|
|
37
54
|
readonly modelId: XaiImageModelId,
|
|
38
55
|
private config: XaiImageModelConfig,
|
|
@@ -135,7 +152,7 @@ export class XaiImageModel implements ImageModelV4 {
|
|
|
135
152
|
const currentDate = this.config._internal?.currentDate?.() ?? new Date();
|
|
136
153
|
const { value: response, responseHeaders } = await postJsonToApi({
|
|
137
154
|
url: `${baseURL}${endpoint}`,
|
|
138
|
-
headers: combineHeaders(this.config.headers(), headers),
|
|
155
|
+
headers: combineHeaders(this.config.headers?.(), headers),
|
|
139
156
|
body,
|
|
140
157
|
failedResponseHandler: xaiFailedResponseHandler,
|
|
141
158
|
successfulResponseHandler: createJsonResponseHandler(
|
package/dist/index.d.mts
DELETED
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod/v4';
|
|
2
|
-
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
|
-
import { InferSchema, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
|
-
import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4, FilesV4 } from '@ai-sdk/provider';
|
|
5
|
-
|
|
6
|
-
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | (string & {});
|
|
7
|
-
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
8
|
-
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
|
-
low: "low";
|
|
10
|
-
high: "high";
|
|
11
|
-
}>>;
|
|
12
|
-
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
13
|
-
topLogprobs: z.ZodOptional<z.ZodNumber>;
|
|
14
|
-
parallel_function_calling: z.ZodOptional<z.ZodBoolean>;
|
|
15
|
-
searchParameters: z.ZodOptional<z.ZodObject<{
|
|
16
|
-
mode: z.ZodEnum<{
|
|
17
|
-
off: "off";
|
|
18
|
-
auto: "auto";
|
|
19
|
-
on: "on";
|
|
20
|
-
}>;
|
|
21
|
-
returnCitations: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
-
fromDate: z.ZodOptional<z.ZodString>;
|
|
23
|
-
toDate: z.ZodOptional<z.ZodString>;
|
|
24
|
-
maxSearchResults: z.ZodOptional<z.ZodNumber>;
|
|
25
|
-
sources: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
26
|
-
type: z.ZodLiteral<"web">;
|
|
27
|
-
country: z.ZodOptional<z.ZodString>;
|
|
28
|
-
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
-
allowedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
-
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
32
|
-
type: z.ZodLiteral<"x">;
|
|
33
|
-
excludedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
-
includedXHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
-
postFavoriteCount: z.ZodOptional<z.ZodNumber>;
|
|
36
|
-
postViewCount: z.ZodOptional<z.ZodNumber>;
|
|
37
|
-
xHandles: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
38
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
39
|
-
type: z.ZodLiteral<"news">;
|
|
40
|
-
country: z.ZodOptional<z.ZodString>;
|
|
41
|
-
excludedWebsites: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
-
safeSearch: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
44
|
-
type: z.ZodLiteral<"rss">;
|
|
45
|
-
links: z.ZodArray<z.ZodString>;
|
|
46
|
-
}, z.core.$strip>]>>>;
|
|
47
|
-
}, z.core.$strip>>;
|
|
48
|
-
}, z.core.$strip>;
|
|
49
|
-
type XaiLanguageModelChatOptions = z.infer<typeof xaiLanguageModelChatOptions>;
|
|
50
|
-
|
|
51
|
-
declare const xaiErrorDataSchema: z.ZodObject<{
|
|
52
|
-
error: z.ZodObject<{
|
|
53
|
-
message: z.ZodString;
|
|
54
|
-
type: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
55
|
-
param: z.ZodOptional<z.ZodNullable<z.ZodAny>>;
|
|
56
|
-
code: z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>>>;
|
|
57
|
-
}, z.core.$strip>;
|
|
58
|
-
}, z.core.$strip>;
|
|
59
|
-
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
|
-
|
|
61
|
-
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-0309-reasoning' | 'grok-4.20-multi-agent-0309' | (string & {});
|
|
62
|
-
/**
|
|
63
|
-
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
64
|
-
*/
|
|
65
|
-
declare const xaiLanguageModelResponsesOptions: z.ZodObject<{
|
|
66
|
-
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
67
|
-
low: "low";
|
|
68
|
-
high: "high";
|
|
69
|
-
medium: "medium";
|
|
70
|
-
}>>;
|
|
71
|
-
reasoningSummary: z.ZodOptional<z.ZodEnum<{
|
|
72
|
-
auto: "auto";
|
|
73
|
-
concise: "concise";
|
|
74
|
-
detailed: "detailed";
|
|
75
|
-
}>>;
|
|
76
|
-
logprobs: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
-
topLogprobs: z.ZodOptional<z.ZodNumber>;
|
|
78
|
-
store: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
-
previousResponseId: z.ZodOptional<z.ZodString>;
|
|
80
|
-
include: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodEnum<{
|
|
81
|
-
"file_search_call.results": "file_search_call.results";
|
|
82
|
-
}>>>>;
|
|
83
|
-
}, z.core.$strip>;
|
|
84
|
-
type XaiLanguageModelResponsesOptions = z.infer<typeof xaiLanguageModelResponsesOptions>;
|
|
85
|
-
|
|
86
|
-
declare const xaiImageModelOptions: z.ZodObject<{
|
|
87
|
-
aspect_ratio: z.ZodOptional<z.ZodString>;
|
|
88
|
-
output_format: z.ZodOptional<z.ZodString>;
|
|
89
|
-
sync_mode: z.ZodOptional<z.ZodBoolean>;
|
|
90
|
-
resolution: z.ZodOptional<z.ZodEnum<{
|
|
91
|
-
"1k": "1k";
|
|
92
|
-
"2k": "2k";
|
|
93
|
-
}>>;
|
|
94
|
-
quality: z.ZodOptional<z.ZodEnum<{
|
|
95
|
-
low: "low";
|
|
96
|
-
high: "high";
|
|
97
|
-
medium: "medium";
|
|
98
|
-
}>>;
|
|
99
|
-
user: z.ZodOptional<z.ZodString>;
|
|
100
|
-
}, z.core.$strip>;
|
|
101
|
-
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
102
|
-
|
|
103
|
-
type XaiVideoModelId = 'grok-imagine-video' | (string & {});
|
|
104
|
-
|
|
105
|
-
declare const resolutionSchema: z.ZodEnum<{
|
|
106
|
-
"480p": "480p";
|
|
107
|
-
"720p": "720p";
|
|
108
|
-
}>;
|
|
109
|
-
type XaiVideoResolution = z.infer<typeof resolutionSchema>;
|
|
110
|
-
interface XaiVideoSharedOptions {
|
|
111
|
-
pollIntervalMs?: number | null;
|
|
112
|
-
pollTimeoutMs?: number | null;
|
|
113
|
-
resolution?: XaiVideoResolution | null;
|
|
114
|
-
}
|
|
115
|
-
interface XaiVideoEditModeOptions extends XaiVideoSharedOptions {
|
|
116
|
-
/**
|
|
117
|
-
* Select edit-video mode explicitly for best autocomplete and narrowing.
|
|
118
|
-
*/
|
|
119
|
-
mode: 'edit-video';
|
|
120
|
-
/** Source video URL to edit. */
|
|
121
|
-
videoUrl: string;
|
|
122
|
-
}
|
|
123
|
-
interface XaiVideoExtendModeOptions extends XaiVideoSharedOptions {
|
|
124
|
-
/**
|
|
125
|
-
* Select extend-video mode explicitly for best autocomplete and narrowing.
|
|
126
|
-
*/
|
|
127
|
-
mode: 'extend-video';
|
|
128
|
-
/** Source video URL to extend from its last frame. */
|
|
129
|
-
videoUrl: string;
|
|
130
|
-
}
|
|
131
|
-
interface XaiVideoReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
132
|
-
/**
|
|
133
|
-
* Select reference-to-video mode explicitly for best autocomplete and narrowing.
|
|
134
|
-
*/
|
|
135
|
-
mode: 'reference-to-video';
|
|
136
|
-
/** Reference image URLs (1-7) for R2V generation. */
|
|
137
|
-
referenceImageUrls: string[];
|
|
138
|
-
}
|
|
139
|
-
interface XaiVideoGenerationOptions extends XaiVideoSharedOptions {
|
|
140
|
-
mode?: undefined;
|
|
141
|
-
videoUrl?: undefined;
|
|
142
|
-
referenceImageUrls?: undefined;
|
|
143
|
-
}
|
|
144
|
-
interface XaiLegacyEditVideoOptions extends XaiVideoSharedOptions {
|
|
145
|
-
/**
|
|
146
|
-
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
147
|
-
* `videoUrl` behaves like edit-video.
|
|
148
|
-
*/
|
|
149
|
-
mode?: undefined;
|
|
150
|
-
videoUrl: string;
|
|
151
|
-
}
|
|
152
|
-
interface XaiLegacyReferenceToVideoOptions extends XaiVideoSharedOptions {
|
|
153
|
-
/**
|
|
154
|
-
* Legacy backward-compatible shape: omitting `mode` while providing
|
|
155
|
-
* `referenceImageUrls` behaves like reference-to-video.
|
|
156
|
-
*/
|
|
157
|
-
mode?: undefined;
|
|
158
|
-
referenceImageUrls: string[];
|
|
159
|
-
}
|
|
160
|
-
/**
|
|
161
|
-
* Provider options for xAI video generation.
|
|
162
|
-
*
|
|
163
|
-
* Use the `mode` option to select the operation:
|
|
164
|
-
*
|
|
165
|
-
* - `'edit-video'` + `videoUrl` -- video editing (`POST /v1/videos/edits`)
|
|
166
|
-
* - `'extend-video'` + `videoUrl` -- video extension (`POST /v1/videos/extensions`)
|
|
167
|
-
* - `'reference-to-video'` + `referenceImageUrls` -- R2V generation (`POST /v1/videos/generations`)
|
|
168
|
-
* - no `mode` -- standard generation from text prompts or image input
|
|
169
|
-
*
|
|
170
|
-
* Runtime remains backward compatible with legacy auto-detected provider
|
|
171
|
-
* options, but the public TypeScript type is intentionally explicit so editors
|
|
172
|
-
* can suggest valid modes and flag invalid field combinations.
|
|
173
|
-
*/
|
|
174
|
-
type XaiVideoModelOptions = XaiVideoGenerationOptions | XaiVideoEditModeOptions | XaiVideoExtendModeOptions | XaiVideoReferenceToVideoOptions | XaiLegacyEditVideoOptions | XaiLegacyReferenceToVideoOptions;
|
|
175
|
-
|
|
176
|
-
declare const xaiFilesOptionsSchema: _ai_sdk_provider_utils.LazySchema<{
|
|
177
|
-
[x: string]: unknown;
|
|
178
|
-
teamId?: string | undefined;
|
|
179
|
-
filePath?: string | undefined;
|
|
180
|
-
}>;
|
|
181
|
-
type XaiFilesOptions = InferSchema<typeof xaiFilesOptionsSchema>;
|
|
182
|
-
|
|
183
|
-
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
184
|
-
|
|
185
|
-
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
186
|
-
output: string;
|
|
187
|
-
error?: string | undefined;
|
|
188
|
-
}, object, {}>;
|
|
189
|
-
declare const codeExecution: (args?: Parameters<typeof codeExecutionToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
190
|
-
output: string;
|
|
191
|
-
error?: string | undefined;
|
|
192
|
-
}, {}>;
|
|
193
|
-
|
|
194
|
-
declare const mcpServerToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
195
|
-
name: string;
|
|
196
|
-
arguments: string;
|
|
197
|
-
result: unknown;
|
|
198
|
-
}, {
|
|
199
|
-
serverUrl: string;
|
|
200
|
-
serverLabel?: string;
|
|
201
|
-
serverDescription?: string;
|
|
202
|
-
allowedTools?: string[];
|
|
203
|
-
headers?: Record<string, string>;
|
|
204
|
-
authorization?: string;
|
|
205
|
-
}, {}>;
|
|
206
|
-
declare const mcpServer: (args: Parameters<typeof mcpServerToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
207
|
-
name: string;
|
|
208
|
-
arguments: string;
|
|
209
|
-
result: unknown;
|
|
210
|
-
}, {}>;
|
|
211
|
-
|
|
212
|
-
declare const viewImageToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
213
|
-
description: string;
|
|
214
|
-
objects?: string[] | undefined;
|
|
215
|
-
}, object, {}>;
|
|
216
|
-
declare const viewImage: (args?: Parameters<typeof viewImageToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
217
|
-
description: string;
|
|
218
|
-
objects?: string[] | undefined;
|
|
219
|
-
}, {}>;
|
|
220
|
-
|
|
221
|
-
declare const viewXVideoToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
222
|
-
description: string;
|
|
223
|
-
transcript?: string | undefined;
|
|
224
|
-
duration?: number | undefined;
|
|
225
|
-
}, object, {}>;
|
|
226
|
-
declare const viewXVideo: (args?: Parameters<typeof viewXVideoToolFactory>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
227
|
-
description: string;
|
|
228
|
-
transcript?: string | undefined;
|
|
229
|
-
duration?: number | undefined;
|
|
230
|
-
}, {}>;
|
|
231
|
-
|
|
232
|
-
declare const webSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
233
|
-
query: string;
|
|
234
|
-
sources: Array<{
|
|
235
|
-
title: string;
|
|
236
|
-
url: string;
|
|
237
|
-
snippet: string;
|
|
238
|
-
}>;
|
|
239
|
-
}, {
|
|
240
|
-
allowedDomains?: string[];
|
|
241
|
-
excludedDomains?: string[];
|
|
242
|
-
enableImageUnderstanding?: boolean;
|
|
243
|
-
}, {}>;
|
|
244
|
-
declare const webSearch: (args?: Parameters<typeof webSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
245
|
-
query: string;
|
|
246
|
-
sources: Array<{
|
|
247
|
-
title: string;
|
|
248
|
-
url: string;
|
|
249
|
-
snippet: string;
|
|
250
|
-
}>;
|
|
251
|
-
}, {}>;
|
|
252
|
-
|
|
253
|
-
declare const xSearchToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
254
|
-
query: string;
|
|
255
|
-
posts: Array<{
|
|
256
|
-
author: string;
|
|
257
|
-
text: string;
|
|
258
|
-
url: string;
|
|
259
|
-
likes: number;
|
|
260
|
-
}>;
|
|
261
|
-
}, {
|
|
262
|
-
allowedXHandles?: string[];
|
|
263
|
-
excludedXHandles?: string[];
|
|
264
|
-
fromDate?: string;
|
|
265
|
-
toDate?: string;
|
|
266
|
-
enableImageUnderstanding?: boolean;
|
|
267
|
-
enableVideoUnderstanding?: boolean;
|
|
268
|
-
}, {}>;
|
|
269
|
-
declare const xSearch: (args?: Parameters<typeof xSearchToolFactory>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
270
|
-
query: string;
|
|
271
|
-
posts: Array<{
|
|
272
|
-
author: string;
|
|
273
|
-
text: string;
|
|
274
|
-
url: string;
|
|
275
|
-
likes: number;
|
|
276
|
-
}>;
|
|
277
|
-
}, {}>;
|
|
278
|
-
|
|
279
|
-
declare const xaiTools: {
|
|
280
|
-
codeExecution: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
281
|
-
output: string;
|
|
282
|
-
error?: string | undefined;
|
|
283
|
-
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
284
|
-
output: string;
|
|
285
|
-
error?: string | undefined;
|
|
286
|
-
}, {}>;
|
|
287
|
-
fileSearch: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
288
|
-
queries: string[];
|
|
289
|
-
results: null | {
|
|
290
|
-
fileId: string;
|
|
291
|
-
filename: string;
|
|
292
|
-
score: number;
|
|
293
|
-
text: string;
|
|
294
|
-
}[];
|
|
295
|
-
}, {
|
|
296
|
-
vectorStoreIds: string[];
|
|
297
|
-
maxNumResults?: number;
|
|
298
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
299
|
-
queries: string[];
|
|
300
|
-
results: null | {
|
|
301
|
-
fileId: string;
|
|
302
|
-
filename: string;
|
|
303
|
-
score: number;
|
|
304
|
-
text: string;
|
|
305
|
-
}[];
|
|
306
|
-
}, {}>;
|
|
307
|
-
mcpServer: (args: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
308
|
-
name: string;
|
|
309
|
-
arguments: string;
|
|
310
|
-
result: unknown;
|
|
311
|
-
}, {
|
|
312
|
-
serverUrl: string;
|
|
313
|
-
serverLabel?: string;
|
|
314
|
-
serverDescription?: string;
|
|
315
|
-
allowedTools?: string[];
|
|
316
|
-
headers?: Record<string, string>;
|
|
317
|
-
authorization?: string;
|
|
318
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
319
|
-
name: string;
|
|
320
|
-
arguments: string;
|
|
321
|
-
result: unknown;
|
|
322
|
-
}, {}>;
|
|
323
|
-
viewImage: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
324
|
-
description: string;
|
|
325
|
-
objects?: string[] | undefined;
|
|
326
|
-
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
327
|
-
description: string;
|
|
328
|
-
objects?: string[] | undefined;
|
|
329
|
-
}, {}>;
|
|
330
|
-
viewXVideo: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
331
|
-
description: string;
|
|
332
|
-
transcript?: string | undefined;
|
|
333
|
-
duration?: number | undefined;
|
|
334
|
-
}, object, {}>>[0]) => _ai_sdk_provider_utils.Tool<Record<string, never>, {
|
|
335
|
-
description: string;
|
|
336
|
-
transcript?: string | undefined;
|
|
337
|
-
duration?: number | undefined;
|
|
338
|
-
}, {}>;
|
|
339
|
-
webSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
340
|
-
query: string;
|
|
341
|
-
sources: Array<{
|
|
342
|
-
title: string;
|
|
343
|
-
url: string;
|
|
344
|
-
snippet: string;
|
|
345
|
-
}>;
|
|
346
|
-
}, {
|
|
347
|
-
allowedDomains?: string[];
|
|
348
|
-
excludedDomains?: string[];
|
|
349
|
-
enableImageUnderstanding?: boolean;
|
|
350
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
351
|
-
query: string;
|
|
352
|
-
sources: Array<{
|
|
353
|
-
title: string;
|
|
354
|
-
url: string;
|
|
355
|
-
snippet: string;
|
|
356
|
-
}>;
|
|
357
|
-
}, {}>;
|
|
358
|
-
xSearch: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{}, {
|
|
359
|
-
query: string;
|
|
360
|
-
posts: Array<{
|
|
361
|
-
author: string;
|
|
362
|
-
text: string;
|
|
363
|
-
url: string;
|
|
364
|
-
likes: number;
|
|
365
|
-
}>;
|
|
366
|
-
}, {
|
|
367
|
-
allowedXHandles?: string[];
|
|
368
|
-
excludedXHandles?: string[];
|
|
369
|
-
fromDate?: string;
|
|
370
|
-
toDate?: string;
|
|
371
|
-
enableImageUnderstanding?: boolean;
|
|
372
|
-
enableVideoUnderstanding?: boolean;
|
|
373
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{}, {
|
|
374
|
-
query: string;
|
|
375
|
-
posts: Array<{
|
|
376
|
-
author: string;
|
|
377
|
-
text: string;
|
|
378
|
-
url: string;
|
|
379
|
-
likes: number;
|
|
380
|
-
}>;
|
|
381
|
-
}, {}>;
|
|
382
|
-
};
|
|
383
|
-
|
|
384
|
-
interface XaiProvider extends ProviderV4 {
|
|
385
|
-
(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
386
|
-
/**
|
|
387
|
-
* Creates an Xai language model for text generation.
|
|
388
|
-
*/
|
|
389
|
-
languageModel(modelId: XaiResponsesModelId): LanguageModelV4;
|
|
390
|
-
/**
|
|
391
|
-
* Creates an Xai chat model for text generation.
|
|
392
|
-
*/
|
|
393
|
-
chat: (modelId: XaiChatModelId) => LanguageModelV4;
|
|
394
|
-
/**
|
|
395
|
-
* Creates an Xai responses model for text generation.
|
|
396
|
-
*/
|
|
397
|
-
responses: (modelId: XaiResponsesModelId) => LanguageModelV4;
|
|
398
|
-
/**
|
|
399
|
-
* Creates an Xai image model for image generation.
|
|
400
|
-
*/
|
|
401
|
-
image(modelId: XaiImageModelId): ImageModelV4;
|
|
402
|
-
/**
|
|
403
|
-
* Creates an Xai image model for image generation.
|
|
404
|
-
*/
|
|
405
|
-
imageModel(modelId: XaiImageModelId): ImageModelV4;
|
|
406
|
-
/**
|
|
407
|
-
* Creates an Xai video model for video generation.
|
|
408
|
-
*/
|
|
409
|
-
video(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
410
|
-
/**
|
|
411
|
-
* Creates an Xai video model for video generation.
|
|
412
|
-
*/
|
|
413
|
-
videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
|
|
414
|
-
/**
|
|
415
|
-
* Returns the xAI files interface for uploading files.
|
|
416
|
-
*/
|
|
417
|
-
files(): FilesV4;
|
|
418
|
-
/**
|
|
419
|
-
* Server-side agentic tools for use with the responses API.
|
|
420
|
-
*/
|
|
421
|
-
tools: typeof xaiTools;
|
|
422
|
-
/**
|
|
423
|
-
* @deprecated Use `embeddingModel` instead.
|
|
424
|
-
*/
|
|
425
|
-
textEmbeddingModel(modelId: string): never;
|
|
426
|
-
}
|
|
427
|
-
interface XaiProviderSettings {
|
|
428
|
-
/**
|
|
429
|
-
* Base URL for the xAI API calls.
|
|
430
|
-
*/
|
|
431
|
-
baseURL?: string;
|
|
432
|
-
/**
|
|
433
|
-
* API key for authenticating requests.
|
|
434
|
-
*/
|
|
435
|
-
apiKey?: string;
|
|
436
|
-
/**
|
|
437
|
-
* Custom headers to include in the requests.
|
|
438
|
-
*/
|
|
439
|
-
headers?: Record<string, string>;
|
|
440
|
-
/**
|
|
441
|
-
* Custom fetch implementation. You can use it as a middleware to intercept requests,
|
|
442
|
-
* or to provide a custom fetch implementation for e.g. testing.
|
|
443
|
-
*/
|
|
444
|
-
fetch?: FetchFunction;
|
|
445
|
-
}
|
|
446
|
-
declare function createXai(options?: XaiProviderSettings): XaiProvider;
|
|
447
|
-
declare const xai: XaiProvider;
|
|
448
|
-
|
|
449
|
-
declare const VERSION: string;
|
|
450
|
-
|
|
451
|
-
export { 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 XaiVideoModelId, type XaiVideoModelOptions, type XaiVideoModelOptions as XaiVideoProviderOptions, codeExecution, createXai, mcpServer, viewImage, viewXVideo, webSearch, xSearch, xai, xaiTools };
|