@ai-sdk/xai 3.0.69 → 3.0.70

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/dist/index.mjs CHANGED
@@ -888,7 +888,9 @@ var xaiImageModelOptions = z4.object({
888
888
  aspect_ratio: z4.string().optional(),
889
889
  output_format: z4.string().optional(),
890
890
  sync_mode: z4.boolean().optional(),
891
- resolution: z4.enum(["1k", "2k"]).optional()
891
+ resolution: z4.enum(["1k", "2k"]).optional(),
892
+ quality: z4.enum(["low", "medium", "high"]).optional(),
893
+ user: z4.string().optional()
892
894
  });
893
895
 
894
896
  // src/xai-image-model.ts
@@ -914,7 +916,7 @@ var XaiImageModel = class {
914
916
  files,
915
917
  mask
916
918
  }) {
917
- var _a, _b, _c, _d;
919
+ var _a, _b, _c, _d, _e;
918
920
  const warnings = [];
919
921
  if (size != null) {
920
922
  warnings.push({
@@ -947,7 +949,7 @@ var XaiImageModel = class {
947
949
  model: this.modelId,
948
950
  prompt,
949
951
  n,
950
- response_format: "url"
952
+ response_format: "b64_json"
951
953
  };
952
954
  if (aspectRatio != null) {
953
955
  body.aspect_ratio = aspectRatio;
@@ -964,6 +966,12 @@ var XaiImageModel = class {
964
966
  if ((xaiOptions == null ? void 0 : xaiOptions.resolution) != null) {
965
967
  body.resolution = xaiOptions.resolution;
966
968
  }
969
+ if ((xaiOptions == null ? void 0 : xaiOptions.quality) != null) {
970
+ body.quality = xaiOptions.quality;
971
+ }
972
+ if ((xaiOptions == null ? void 0 : xaiOptions.user) != null) {
973
+ body.user = xaiOptions.user;
974
+ }
967
975
  if (imageUrls.length === 1) {
968
976
  body.image = { url: imageUrls[0], type: "image_url" };
969
977
  } else if (imageUrls.length > 1) {
@@ -982,11 +990,14 @@ var XaiImageModel = class {
982
990
  abortSignal,
983
991
  fetch: this.config.fetch
984
992
  });
985
- const downloadedImages = await Promise.all(
986
- response.data.map((image) => this.downloadImage(image.url, abortSignal))
993
+ const hasAllBase64 = response.data.every((image) => image.b64_json != null);
994
+ const images = hasAllBase64 ? response.data.map((image) => image.b64_json) : await Promise.all(
995
+ response.data.map(
996
+ (image) => this.downloadImage(image.url, abortSignal)
997
+ )
987
998
  );
988
999
  return {
989
- images: downloadedImages,
1000
+ images,
990
1001
  warnings,
991
1002
  response: {
992
1003
  timestamp: currentDate,
@@ -997,7 +1008,8 @@ var XaiImageModel = class {
997
1008
  xai: {
998
1009
  images: response.data.map((item) => ({
999
1010
  ...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {}
1000
- }))
1011
+ })),
1012
+ ...((_e = response.usage) == null ? void 0 : _e.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {}
1001
1013
  }
1002
1014
  }
1003
1015
  };
@@ -1016,10 +1028,14 @@ var XaiImageModel = class {
1016
1028
  var xaiImageResponseSchema = z5.object({
1017
1029
  data: z5.array(
1018
1030
  z5.object({
1019
- url: z5.string(),
1031
+ url: z5.string().nullish(),
1032
+ b64_json: z5.string().nullish(),
1020
1033
  revised_prompt: z5.string().nullish()
1021
1034
  })
1022
- )
1035
+ ),
1036
+ usage: z5.object({
1037
+ cost_in_usd_ticks: z5.number().nullish()
1038
+ }).nullish()
1023
1039
  });
1024
1040
 
1025
1041
  // src/responses/xai-responses-language-model.ts
@@ -2720,7 +2736,7 @@ var xaiTools = {
2720
2736
  };
2721
2737
 
2722
2738
  // src/version.ts
2723
- var VERSION = true ? "3.0.69" : "0.0.0-test";
2739
+ var VERSION = true ? "3.0.70" : "0.0.0-test";
2724
2740
 
2725
2741
  // src/xai-video-model.ts
2726
2742
  import {