@ai-sdk/xai 3.0.105 → 3.0.107

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,24 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.107
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [06fb54c]
8
+ - @ai-sdk/provider-utils@4.0.39
9
+ - @ai-sdk/openai-compatible@2.0.60
10
+
11
+ ## 3.0.106
12
+
13
+ ### Patch Changes
14
+
15
+ - e1af05f: feat (video): support video (not just image) reference inputs in `inputReferences` for reference-to-video generation
16
+ - 1ce0d1c: feat (provider/xai): add grok-4.5 model id
17
+ - Updated dependencies [e1af05f]
18
+ - @ai-sdk/provider@3.0.14
19
+ - @ai-sdk/openai-compatible@2.0.59
20
+ - @ai-sdk/provider-utils@4.0.38
21
+
3
22
  ## 3.0.105
4
23
 
5
24
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 }
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- type XaiChatModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
6
+ type XaiChatModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (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.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
75
+ type XaiResponsesModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
76
76
  /**
77
77
  * @see https://docs.x.ai/docs/api-reference#create-new-response
78
78
  */
package/dist/index.d.ts CHANGED
@@ -3,7 +3,7 @@ import { ProviderV3, LanguageModelV3, ImageModelV3, Experimental_VideoModelV3 }
3
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
4
4
  import { FetchFunction } from '@ai-sdk/provider-utils';
5
5
 
6
- type XaiChatModelId = 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
6
+ type XaiChatModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (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.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
75
+ type XaiResponsesModelId = 'grok-4.5' | 'grok-4.3' | 'grok-4.20-0309-reasoning' | 'grok-4.20-0309-non-reasoning' | 'grok-4.20-multi-agent-0309' | 'grok-build-0.1' | (string & {});
76
76
  /**
77
77
  * @see https://docs.x.ai/docs/api-reference#create-new-response
78
78
  */
package/dist/index.js CHANGED
@@ -2891,7 +2891,7 @@ var xaiTools = {
2891
2891
  };
2892
2892
 
2893
2893
  // src/version.ts
2894
- var VERSION = true ? "3.0.105" : "0.0.0-test";
2894
+ var VERSION = true ? "3.0.107" : "0.0.0-test";
2895
2895
 
2896
2896
  // src/xai-video-model.ts
2897
2897
  var import_provider6 = require("@ai-sdk/provider");
@@ -2967,17 +2967,32 @@ function resolveStartImage(options) {
2967
2967
  var _a;
2968
2968
  return (_a = getFirstFrameImage(options)) != null ? _a : options.image;
2969
2969
  }
2970
+ function getTopLevelMediaType(mediaType) {
2971
+ const slashIndex = mediaType.indexOf("/");
2972
+ return slashIndex === -1 ? mediaType : mediaType.substring(0, slashIndex);
2973
+ }
2974
+ var isVideoFile = (file) => file.mediaType != null && getTopLevelMediaType(file.mediaType) === "video";
2970
2975
  function fileToXaiImageUrl(file) {
2971
- var _a;
2972
2976
  if (file.type === "url") {
2973
2977
  return file.url;
2974
2978
  }
2975
2979
  const base64Data = typeof file.data === "string" ? file.data : (0, import_provider_utils16.convertUint8ArrayToBase64)(file.data);
2976
- return `data:${(_a = file.mediaType) != null ? _a : "image/png"};base64,${base64Data}`;
2980
+ return `data:${file.mediaType};base64,${base64Data}`;
2977
2981
  }
2978
- function resolveReferenceImages(options, xaiOptions) {
2982
+ function resolveReferenceImages(options, xaiOptions, warnings) {
2979
2983
  if (options.inputReferences != null && options.inputReferences.length > 0) {
2980
- return options.inputReferences.map((reference) => ({
2984
+ const imageReferences = options.inputReferences.filter((reference) => {
2985
+ if (isVideoFile(reference)) {
2986
+ warnings.push({
2987
+ type: "unsupported",
2988
+ feature: "inputReferences",
2989
+ 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.'
2990
+ });
2991
+ return false;
2992
+ }
2993
+ return true;
2994
+ });
2995
+ return imageReferences.map((reference) => ({
2981
2996
  url: fileToXaiImageUrl(reference)
2982
2997
  }));
2983
2998
  }
@@ -3115,17 +3130,31 @@ var XaiVideoModel = class {
3115
3130
  }
3116
3131
  const startImage = resolveStartImage(options);
3117
3132
  if (startImage != null) {
3118
- body.image = { url: fileToXaiImageUrl(startImage) };
3133
+ if (isVideoFile(startImage)) {
3134
+ const fromFrameImages = getFirstFrameImage(options) != null;
3135
+ warnings.push({
3136
+ type: "unsupported",
3137
+ feature: fromFrameImages ? "frameImages" : "image",
3138
+ 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.'
3139
+ });
3140
+ } else {
3141
+ body.image = { url: fileToXaiImageUrl(startImage) };
3142
+ }
3119
3143
  }
3120
- if (getLastFrameImage(options) != null) {
3144
+ const lastFrameImage = getLastFrameImage(options);
3145
+ if (lastFrameImage != null) {
3121
3146
  warnings.push({
3122
3147
  type: "unsupported",
3123
3148
  feature: "frameImages",
3124
- 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.`
3149
+ 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.`
3125
3150
  });
3126
3151
  }
3127
3152
  if (hasReferenceImages) {
3128
- const referenceImages = resolveReferenceImages(options, xaiOptions);
3153
+ const referenceImages = resolveReferenceImages(
3154
+ options,
3155
+ xaiOptions,
3156
+ warnings
3157
+ );
3129
3158
  if (referenceImages != null) {
3130
3159
  body.reference_images = referenceImages;
3131
3160
  }