@ai-sdk/xai 4.0.0-beta.20 → 4.0.0-beta.23

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,29 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 4.0.0-beta.23
4
+
5
+ ### Patch Changes
6
+
7
+ - c29a26f: feat(provider): add support for provider references and uploading files as supported per provider
8
+ - Updated dependencies [c29a26f]
9
+ - @ai-sdk/openai-compatible@3.0.0-beta.14
10
+ - @ai-sdk/provider-utils@5.0.0-beta.10
11
+ - @ai-sdk/provider@4.0.0-beta.6
12
+
13
+ ## 4.0.0-beta.22
14
+
15
+ ### Patch Changes
16
+
17
+ - f51c95e: feat(provider/xai): add video extension and reference-to-video (R2V) support
18
+
19
+ ## 4.0.0-beta.21
20
+
21
+ ### Patch Changes
22
+
23
+ - 38fc777: Add AI Gateway hint to provider READMEs
24
+ - Updated dependencies [38fc777]
25
+ - @ai-sdk/openai-compatible@3.0.0-beta.13
26
+
3
27
  ## 4.0.0-beta.20
4
28
 
5
29
  ### Patch Changes
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.mts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 } 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, FilesV4 } from '@ai-sdk/provider';
5
5
 
6
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
7
  declare const xaiLanguageModelChatOptions: z.ZodObject<{
@@ -102,13 +102,83 @@ type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
102
102
 
103
103
  type XaiVideoModelId = 'grok-imagine-video' | (string & {});
104
104
 
105
- type XaiVideoModelOptions = {
105
+ declare const resolutionSchema: z.ZodEnum<{
106
+ "480p": "480p";
107
+ "720p": "720p";
108
+ }>;
109
+ type XaiVideoResolution = z.infer<typeof resolutionSchema>;
110
+ interface XaiVideoSharedOptions {
106
111
  pollIntervalMs?: number | null;
107
112
  pollTimeoutMs?: number | null;
108
- resolution?: '480p' | '720p' | null;
109
- videoUrl?: string | null;
110
- [key: string]: unknown;
111
- };
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>;
112
182
 
113
183
  type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
114
184
 
@@ -341,6 +411,10 @@ interface XaiProvider extends ProviderV4 {
341
411
  * Creates an Xai video model for video generation.
342
412
  */
343
413
  videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
414
+ /**
415
+ * Returns the xAI files interface for uploading files.
416
+ */
417
+ files(): FilesV4;
344
418
  /**
345
419
  * Server-side agentic tools for use with the responses API.
346
420
  */
@@ -374,4 +448,4 @@ declare const xai: XaiProvider;
374
448
 
375
449
  declare const VERSION: string;
376
450
 
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 };
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 };
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod/v4';
2
- import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 } 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, FilesV4 } from '@ai-sdk/provider';
5
5
 
6
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
7
  declare const xaiLanguageModelChatOptions: z.ZodObject<{
@@ -102,13 +102,83 @@ type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
102
102
 
103
103
  type XaiVideoModelId = 'grok-imagine-video' | (string & {});
104
104
 
105
- type XaiVideoModelOptions = {
105
+ declare const resolutionSchema: z.ZodEnum<{
106
+ "480p": "480p";
107
+ "720p": "720p";
108
+ }>;
109
+ type XaiVideoResolution = z.infer<typeof resolutionSchema>;
110
+ interface XaiVideoSharedOptions {
106
111
  pollIntervalMs?: number | null;
107
112
  pollTimeoutMs?: number | null;
108
- resolution?: '480p' | '720p' | null;
109
- videoUrl?: string | null;
110
- [key: string]: unknown;
111
- };
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>;
112
182
 
113
183
  type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
114
184
 
@@ -341,6 +411,10 @@ interface XaiProvider extends ProviderV4 {
341
411
  * Creates an Xai video model for video generation.
342
412
  */
343
413
  videoModel(modelId: XaiVideoModelId): Experimental_VideoModelV4;
414
+ /**
415
+ * Returns the xAI files interface for uploading files.
416
+ */
417
+ files(): FilesV4;
344
418
  /**
345
419
  * Server-side agentic tools for use with the responses API.
346
420
  */
@@ -374,4 +448,4 @@ declare const xai: XaiProvider;
374
448
 
375
449
  declare const VERSION: string;
376
450
 
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 };
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 };