@ai-sdk/xai 3.0.69 → 3.0.71
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 +12 -0
- package/dist/index.d.mts +8 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +26 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -10
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +6 -10
- package/package.json +5 -5
- package/src/xai-chat-options.ts +0 -6
- package/src/xai-image-model.ts +29 -6
- package/src/xai-image-options.ts +2 -0
- package/src/xai-image-settings.ts +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.71
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 55ccbe2: chore(provider/xai): remove obsolete Grok 2 models now that they are shut down in their API
|
|
8
|
+
|
|
9
|
+
## 3.0.70
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 49ae502: feat(xai): add b64_json response format, usage cost tracking, and quality/user parameters for image models
|
|
14
|
+
|
|
3
15
|
## 3.0.69
|
|
4
16
|
|
|
5
17
|
### 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-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' |
|
|
6
|
+
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | '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<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -86,6 +86,12 @@ declare const xaiImageModelOptions: z.ZodObject<{
|
|
|
86
86
|
"1k": "1k";
|
|
87
87
|
"2k": "2k";
|
|
88
88
|
}>>;
|
|
89
|
+
quality: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
low: "low";
|
|
91
|
+
high: "high";
|
|
92
|
+
medium: "medium";
|
|
93
|
+
}>>;
|
|
94
|
+
user: z.ZodOptional<z.ZodString>;
|
|
89
95
|
}, z.core.$strip>;
|
|
90
96
|
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
91
97
|
|
|
@@ -99,7 +105,7 @@ type XaiVideoModelOptions = {
|
|
|
99
105
|
[key: string]: unknown;
|
|
100
106
|
};
|
|
101
107
|
|
|
102
|
-
type XaiImageModelId = 'grok-
|
|
108
|
+
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
103
109
|
|
|
104
110
|
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
105
111
|
output: string;
|
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-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | 'grok-code-fast-1' | 'grok-4' | 'grok-4-0709' | 'grok-4-latest' | 'grok-3' | 'grok-3-latest' | 'grok-3-mini' | 'grok-3-mini-latest' |
|
|
6
|
+
type XaiChatModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | '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<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -86,6 +86,12 @@ declare const xaiImageModelOptions: z.ZodObject<{
|
|
|
86
86
|
"1k": "1k";
|
|
87
87
|
"2k": "2k";
|
|
88
88
|
}>>;
|
|
89
|
+
quality: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
low: "low";
|
|
91
|
+
high: "high";
|
|
92
|
+
medium: "medium";
|
|
93
|
+
}>>;
|
|
94
|
+
user: z.ZodOptional<z.ZodString>;
|
|
89
95
|
}, z.core.$strip>;
|
|
90
96
|
type XaiImageModelOptions = z.infer<typeof xaiImageModelOptions>;
|
|
91
97
|
|
|
@@ -99,7 +105,7 @@ type XaiVideoModelOptions = {
|
|
|
99
105
|
[key: string]: unknown;
|
|
100
106
|
};
|
|
101
107
|
|
|
102
|
-
type XaiImageModelId = 'grok-
|
|
108
|
+
type XaiImageModelId = 'grok-imagine-image' | 'grok-imagine-image-pro' | (string & {});
|
|
103
109
|
|
|
104
110
|
declare const codeExecutionToolFactory: _ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<Record<string, never>, {
|
|
105
111
|
output: string;
|
package/dist/index.js
CHANGED
|
@@ -893,7 +893,9 @@ var xaiImageModelOptions = import_v44.z.object({
|
|
|
893
893
|
aspect_ratio: import_v44.z.string().optional(),
|
|
894
894
|
output_format: import_v44.z.string().optional(),
|
|
895
895
|
sync_mode: import_v44.z.boolean().optional(),
|
|
896
|
-
resolution: import_v44.z.enum(["1k", "2k"]).optional()
|
|
896
|
+
resolution: import_v44.z.enum(["1k", "2k"]).optional(),
|
|
897
|
+
quality: import_v44.z.enum(["low", "medium", "high"]).optional(),
|
|
898
|
+
user: import_v44.z.string().optional()
|
|
897
899
|
});
|
|
898
900
|
|
|
899
901
|
// src/xai-image-model.ts
|
|
@@ -919,7 +921,7 @@ var XaiImageModel = class {
|
|
|
919
921
|
files,
|
|
920
922
|
mask
|
|
921
923
|
}) {
|
|
922
|
-
var _a, _b, _c, _d;
|
|
924
|
+
var _a, _b, _c, _d, _e;
|
|
923
925
|
const warnings = [];
|
|
924
926
|
if (size != null) {
|
|
925
927
|
warnings.push({
|
|
@@ -952,7 +954,7 @@ var XaiImageModel = class {
|
|
|
952
954
|
model: this.modelId,
|
|
953
955
|
prompt,
|
|
954
956
|
n,
|
|
955
|
-
response_format: "
|
|
957
|
+
response_format: "b64_json"
|
|
956
958
|
};
|
|
957
959
|
if (aspectRatio != null) {
|
|
958
960
|
body.aspect_ratio = aspectRatio;
|
|
@@ -969,6 +971,12 @@ var XaiImageModel = class {
|
|
|
969
971
|
if ((xaiOptions == null ? void 0 : xaiOptions.resolution) != null) {
|
|
970
972
|
body.resolution = xaiOptions.resolution;
|
|
971
973
|
}
|
|
974
|
+
if ((xaiOptions == null ? void 0 : xaiOptions.quality) != null) {
|
|
975
|
+
body.quality = xaiOptions.quality;
|
|
976
|
+
}
|
|
977
|
+
if ((xaiOptions == null ? void 0 : xaiOptions.user) != null) {
|
|
978
|
+
body.user = xaiOptions.user;
|
|
979
|
+
}
|
|
972
980
|
if (imageUrls.length === 1) {
|
|
973
981
|
body.image = { url: imageUrls[0], type: "image_url" };
|
|
974
982
|
} else if (imageUrls.length > 1) {
|
|
@@ -987,11 +995,14 @@ var XaiImageModel = class {
|
|
|
987
995
|
abortSignal,
|
|
988
996
|
fetch: this.config.fetch
|
|
989
997
|
});
|
|
990
|
-
const
|
|
991
|
-
|
|
998
|
+
const hasAllBase64 = response.data.every((image) => image.b64_json != null);
|
|
999
|
+
const images = hasAllBase64 ? response.data.map((image) => image.b64_json) : await Promise.all(
|
|
1000
|
+
response.data.map(
|
|
1001
|
+
(image) => this.downloadImage(image.url, abortSignal)
|
|
1002
|
+
)
|
|
992
1003
|
);
|
|
993
1004
|
return {
|
|
994
|
-
images
|
|
1005
|
+
images,
|
|
995
1006
|
warnings,
|
|
996
1007
|
response: {
|
|
997
1008
|
timestamp: currentDate,
|
|
@@ -1002,7 +1013,8 @@ var XaiImageModel = class {
|
|
|
1002
1013
|
xai: {
|
|
1003
1014
|
images: response.data.map((item) => ({
|
|
1004
1015
|
...item.revised_prompt ? { revisedPrompt: item.revised_prompt } : {}
|
|
1005
|
-
}))
|
|
1016
|
+
})),
|
|
1017
|
+
...((_e = response.usage) == null ? void 0 : _e.cost_in_usd_ticks) != null ? { costInUsdTicks: response.usage.cost_in_usd_ticks } : {}
|
|
1006
1018
|
}
|
|
1007
1019
|
}
|
|
1008
1020
|
};
|
|
@@ -1021,10 +1033,14 @@ var XaiImageModel = class {
|
|
|
1021
1033
|
var xaiImageResponseSchema = import_v45.z.object({
|
|
1022
1034
|
data: import_v45.z.array(
|
|
1023
1035
|
import_v45.z.object({
|
|
1024
|
-
url: import_v45.z.string(),
|
|
1036
|
+
url: import_v45.z.string().nullish(),
|
|
1037
|
+
b64_json: import_v45.z.string().nullish(),
|
|
1025
1038
|
revised_prompt: import_v45.z.string().nullish()
|
|
1026
1039
|
})
|
|
1027
|
-
)
|
|
1040
|
+
),
|
|
1041
|
+
usage: import_v45.z.object({
|
|
1042
|
+
cost_in_usd_ticks: import_v45.z.number().nullish()
|
|
1043
|
+
}).nullish()
|
|
1028
1044
|
});
|
|
1029
1045
|
|
|
1030
1046
|
// src/responses/xai-responses-language-model.ts
|
|
@@ -2699,7 +2715,7 @@ var xaiTools = {
|
|
|
2699
2715
|
};
|
|
2700
2716
|
|
|
2701
2717
|
// src/version.ts
|
|
2702
|
-
var VERSION = true ? "3.0.
|
|
2718
|
+
var VERSION = true ? "3.0.71" : "0.0.0-test";
|
|
2703
2719
|
|
|
2704
2720
|
// src/xai-video-model.ts
|
|
2705
2721
|
var import_provider6 = require("@ai-sdk/provider");
|