@ai-sdk/xai 4.0.9 → 4.0.10
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 +11 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +35 -9
- package/dist/index.js.map +1 -1
- package/docs/01-xai.mdx +27 -40
- package/package.json +6 -6
- package/src/responses/xai-responses-language-model-options.ts +1 -0
- package/src/xai-chat-language-model-options.ts +1 -0
- package/src/xai-video-model.ts +51 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0f93c57: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
|
|
8
|
+
- d25a084: feat (provider/xai): add grok-4.5 model id
|
|
9
|
+
- Updated dependencies [0f93c57]
|
|
10
|
+
- @ai-sdk/provider@4.0.3
|
|
11
|
+
- @ai-sdk/openai-compatible@3.0.7
|
|
12
|
+
- @ai-sdk/provider-utils@5.0.7
|
|
13
|
+
|
|
3
14
|
## 4.0.9
|
|
4
15
|
|
|
5
16
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
|
3
3
|
import { InferSchema, FetchFunction, WebSocketConstructor } from '@ai-sdk/provider-utils';
|
|
4
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.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-latest' | (string & {});
|
|
6
|
+
type XaiChatModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-4.5' | 'grok-latest' | (string & {});
|
|
7
7
|
declare const xaiLanguageModelChatOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
none: "none";
|
|
@@ -72,7 +72,7 @@ declare const xaiFilePartProviderOptions: z.ZodObject<{
|
|
|
72
72
|
}, z.core.$strip>;
|
|
73
73
|
type XaiFilePartProviderOptions = z.infer<typeof xaiFilePartProviderOptions>;
|
|
74
74
|
|
|
75
|
-
type XaiResponsesModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-latest' | (string & {});
|
|
75
|
+
type XaiResponsesModelId = 'grok-4.20-non-reasoning' | 'grok-4.20-reasoning' | 'grok-4.3' | 'grok-4.5' | 'grok-latest' | (string & {});
|
|
76
76
|
/**
|
|
77
77
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
78
78
|
*/
|
package/dist/index.js
CHANGED
|
@@ -3474,7 +3474,7 @@ var xaiTools = {
|
|
|
3474
3474
|
};
|
|
3475
3475
|
|
|
3476
3476
|
// src/version.ts
|
|
3477
|
-
var VERSION = true ? "4.0.
|
|
3477
|
+
var VERSION = true ? "4.0.10" : "0.0.0-test";
|
|
3478
3478
|
|
|
3479
3479
|
// src/files/xai-files.ts
|
|
3480
3480
|
import {
|
|
@@ -3587,6 +3587,7 @@ import {
|
|
|
3587
3587
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
3588
3588
|
delay,
|
|
3589
3589
|
getFromApi as getFromApi2,
|
|
3590
|
+
getTopLevelMediaType as getTopLevelMediaType3,
|
|
3590
3591
|
parseProviderOptions as parseProviderOptions7,
|
|
3591
3592
|
postJsonToApi as postJsonToApi4
|
|
3592
3593
|
} from "@ai-sdk/provider-utils";
|
|
@@ -3661,17 +3662,28 @@ function resolveStartImage(options) {
|
|
|
3661
3662
|
var _a;
|
|
3662
3663
|
return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
|
|
3663
3664
|
}
|
|
3665
|
+
var isVideoFile = (file) => file.mediaType != null && getTopLevelMediaType3(file.mediaType) === "video";
|
|
3664
3666
|
function fileToXaiImageUrl(file) {
|
|
3665
|
-
var _a;
|
|
3666
3667
|
if (file.type === "url") {
|
|
3667
3668
|
return file.url;
|
|
3668
3669
|
}
|
|
3669
3670
|
const base64Data = typeof file.data === "string" ? file.data : convertUint8ArrayToBase64(file.data);
|
|
3670
|
-
return `data:${
|
|
3671
|
+
return `data:${file.mediaType};base64,${base64Data}`;
|
|
3671
3672
|
}
|
|
3672
|
-
function resolveReferenceImages(options, xaiOptions) {
|
|
3673
|
+
function resolveReferenceImages(options, xaiOptions, warnings) {
|
|
3673
3674
|
if (options.inputReferences != null && options.inputReferences.length > 0) {
|
|
3674
|
-
|
|
3675
|
+
const imageReferences = options.inputReferences.filter((reference) => {
|
|
3676
|
+
if (isVideoFile(reference)) {
|
|
3677
|
+
warnings.push({
|
|
3678
|
+
type: "unsupported",
|
|
3679
|
+
feature: "inputReferences",
|
|
3680
|
+
details: 'xAI reference-to-video accepts image references only. The video reference was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video.'
|
|
3681
|
+
});
|
|
3682
|
+
return false;
|
|
3683
|
+
}
|
|
3684
|
+
return true;
|
|
3685
|
+
});
|
|
3686
|
+
return imageReferences.map((reference) => ({
|
|
3675
3687
|
url: fileToXaiImageUrl(reference)
|
|
3676
3688
|
}));
|
|
3677
3689
|
}
|
|
@@ -3809,17 +3821,31 @@ var XaiVideoModel = class {
|
|
|
3809
3821
|
}
|
|
3810
3822
|
const startImage = resolveStartImage(options);
|
|
3811
3823
|
if (startImage != null) {
|
|
3812
|
-
|
|
3824
|
+
if (isVideoFile(startImage)) {
|
|
3825
|
+
const fromFrameImages = getFirstFrameImage(options) != null;
|
|
3826
|
+
warnings.push({
|
|
3827
|
+
type: "unsupported",
|
|
3828
|
+
feature: fromFrameImages ? "frameImages" : "image",
|
|
3829
|
+
details: 'xAI does not accept a video as a start/frame image. The video was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video instead.'
|
|
3830
|
+
});
|
|
3831
|
+
} else {
|
|
3832
|
+
body.image = { url: fileToXaiImageUrl(startImage) };
|
|
3833
|
+
}
|
|
3813
3834
|
}
|
|
3814
|
-
|
|
3835
|
+
const lastFrameImage = getLastFrameImage(options);
|
|
3836
|
+
if (lastFrameImage != null) {
|
|
3815
3837
|
warnings.push({
|
|
3816
3838
|
type: "unsupported",
|
|
3817
3839
|
feature: "frameImages",
|
|
3818
|
-
details: `xAI video models do not support last_frame. Use providerOptions.xai.mode "extend-video" to continue from a video's last frame. The last frame image was ignored.`
|
|
3840
|
+
details: isVideoFile(lastFrameImage) ? 'xAI does not accept a video as a start/frame image. The video last frame was ignored. Use providerOptions.xai.mode "extend-video" to continue from a video instead.' : `xAI video models do not support last_frame. Use providerOptions.xai.mode "extend-video" to continue from a video's last frame. The last frame image was ignored.`
|
|
3819
3841
|
});
|
|
3820
3842
|
}
|
|
3821
3843
|
if (hasReferenceImages) {
|
|
3822
|
-
const referenceImages = resolveReferenceImages(
|
|
3844
|
+
const referenceImages = resolveReferenceImages(
|
|
3845
|
+
options,
|
|
3846
|
+
xaiOptions,
|
|
3847
|
+
warnings
|
|
3848
|
+
);
|
|
3823
3849
|
if (referenceImages != null) {
|
|
3824
3850
|
body.reference_images = referenceImages;
|
|
3825
3851
|
}
|