@ai-sdk/xai 3.0.72 → 3.0.74
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 +20 -8
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +15 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +15 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -3
- package/src/responses/xai-responses-options.ts +3 -0
- package/src/xai-chat-options.ts +3 -0
- package/src/xai-video-model.ts +16 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 3.0.74
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3caa544: chore(provider/xai): update Grok 4.20 model IDs to their non-beta versions
|
|
8
|
+
|
|
9
|
+
## 3.0.73
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 12e972c: feat(provider/xai): add moderation error, and costInUsdTicks to video model
|
|
14
|
+
|
|
3
15
|
## 3.0.72
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -530,13 +542,13 @@
|
|
|
530
542
|
Before
|
|
531
543
|
|
|
532
544
|
```ts
|
|
533
|
-
model.textEmbeddingModel(
|
|
545
|
+
model.textEmbeddingModel("my-model-id");
|
|
534
546
|
```
|
|
535
547
|
|
|
536
548
|
After
|
|
537
549
|
|
|
538
550
|
```ts
|
|
539
|
-
model.embeddingModel(
|
|
551
|
+
model.embeddingModel("my-model-id");
|
|
540
552
|
```
|
|
541
553
|
|
|
542
554
|
- 2625a04: feat(openai); update spec for mcp approval
|
|
@@ -794,13 +806,13 @@
|
|
|
794
806
|
Before
|
|
795
807
|
|
|
796
808
|
```ts
|
|
797
|
-
model.textEmbeddingModel(
|
|
809
|
+
model.textEmbeddingModel("my-model-id");
|
|
798
810
|
```
|
|
799
811
|
|
|
800
812
|
After
|
|
801
813
|
|
|
802
814
|
```ts
|
|
803
|
-
model.embeddingModel(
|
|
815
|
+
model.embeddingModel("my-model-id");
|
|
804
816
|
```
|
|
805
817
|
|
|
806
818
|
- 8514146: add grok-4-1 model IDs
|
|
@@ -1343,7 +1355,7 @@
|
|
|
1343
1355
|
|
|
1344
1356
|
```js
|
|
1345
1357
|
await generateImage({
|
|
1346
|
-
model: luma.image(
|
|
1358
|
+
model: luma.image("photon-flash-1", {
|
|
1347
1359
|
maxImagesPerCall: 5,
|
|
1348
1360
|
pollIntervalMillis: 500,
|
|
1349
1361
|
}),
|
|
@@ -1356,7 +1368,7 @@
|
|
|
1356
1368
|
|
|
1357
1369
|
```js
|
|
1358
1370
|
await generateImage({
|
|
1359
|
-
model: luma.image(
|
|
1371
|
+
model: luma.image("photon-flash-1"),
|
|
1360
1372
|
prompt,
|
|
1361
1373
|
n: 10,
|
|
1362
1374
|
maxImagesPerCall: 5,
|
|
@@ -1672,7 +1684,7 @@
|
|
|
1672
1684
|
|
|
1673
1685
|
```js
|
|
1674
1686
|
await generateImage({
|
|
1675
|
-
model: luma.image(
|
|
1687
|
+
model: luma.image("photon-flash-1", {
|
|
1676
1688
|
maxImagesPerCall: 5,
|
|
1677
1689
|
pollIntervalMillis: 500,
|
|
1678
1690
|
}),
|
|
@@ -1685,7 +1697,7 @@
|
|
|
1685
1697
|
|
|
1686
1698
|
```js
|
|
1687
1699
|
await generateImage({
|
|
1688
|
-
model: luma.image(
|
|
1700
|
+
model: luma.image("photon-flash-1"),
|
|
1689
1701
|
prompt,
|
|
1690
1702
|
n: 10,
|
|
1691
1703
|
maxImagesPerCall: 5,
|
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' | (string & {});
|
|
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<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -58,7 +58,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
58
58
|
}, z.core.$strip>;
|
|
59
59
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
60
|
|
|
61
|
-
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | (string & {});
|
|
61
|
+
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | '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' | (string & {});
|
|
62
62
|
/**
|
|
63
63
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
64
64
|
*/
|
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' | (string & {});
|
|
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<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -58,7 +58,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
58
58
|
}, z.core.$strip>;
|
|
59
59
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
60
60
|
|
|
61
|
-
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast-non-reasoning' | 'grok-4-fast-reasoning' | (string & {});
|
|
61
|
+
type XaiResponsesModelId = 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | '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' | (string & {});
|
|
62
62
|
/**
|
|
63
63
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
64
64
|
*/
|
package/dist/index.js
CHANGED
|
@@ -2715,7 +2715,7 @@ var xaiTools = {
|
|
|
2715
2715
|
};
|
|
2716
2716
|
|
|
2717
2717
|
// src/version.ts
|
|
2718
|
-
var VERSION = true ? "3.0.
|
|
2718
|
+
var VERSION = true ? "3.0.74" : "0.0.0-test";
|
|
2719
2719
|
|
|
2720
2720
|
// src/xai-video-model.ts
|
|
2721
2721
|
var import_provider6 = require("@ai-sdk/provider");
|
|
@@ -2753,7 +2753,7 @@ var XaiVideoModel = class {
|
|
|
2753
2753
|
return this.config.provider;
|
|
2754
2754
|
}
|
|
2755
2755
|
async doGenerate(options) {
|
|
2756
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
2756
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
2757
2757
|
const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
|
|
2758
2758
|
const warnings = [];
|
|
2759
2759
|
const xaiOptions = await (0, import_provider_utils16.parseProviderOptions)({
|
|
@@ -2896,7 +2896,13 @@ var XaiVideoModel = class {
|
|
|
2896
2896
|
});
|
|
2897
2897
|
responseHeaders = pollHeaders;
|
|
2898
2898
|
if (statusResponse.status === "done" || statusResponse.status == null && ((_g = statusResponse.video) == null ? void 0 : _g.url)) {
|
|
2899
|
-
if (
|
|
2899
|
+
if (((_h = statusResponse.video) == null ? void 0 : _h.respect_moderation) === false) {
|
|
2900
|
+
throw new import_provider6.AISDKError({
|
|
2901
|
+
name: "XAI_VIDEO_MODERATION_ERROR",
|
|
2902
|
+
message: "Video generation was blocked due to a content policy violation."
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
if (!((_i = statusResponse.video) == null ? void 0 : _i.url)) {
|
|
2900
2906
|
throw new import_provider6.AISDKError({
|
|
2901
2907
|
name: "XAI_VIDEO_GENERATION_ERROR",
|
|
2902
2908
|
message: "Video generation completed but no video URL was returned."
|
|
@@ -2920,7 +2926,8 @@ var XaiVideoModel = class {
|
|
|
2920
2926
|
xai: {
|
|
2921
2927
|
requestId,
|
|
2922
2928
|
videoUrl: statusResponse.video.url,
|
|
2923
|
-
...statusResponse.video.duration != null ? { duration: statusResponse.video.duration } : {}
|
|
2929
|
+
...statusResponse.video.duration != null ? { duration: statusResponse.video.duration } : {},
|
|
2930
|
+
...((_j = statusResponse.usage) == null ? void 0 : _j.cost_in_usd_ticks) != null ? { costInUsdTicks: statusResponse.usage.cost_in_usd_ticks } : {}
|
|
2924
2931
|
}
|
|
2925
2932
|
}
|
|
2926
2933
|
};
|
|
@@ -2944,7 +2951,10 @@ var xaiVideoStatusResponseSchema = import_v416.z.object({
|
|
|
2944
2951
|
duration: import_v416.z.number().nullish(),
|
|
2945
2952
|
respect_moderation: import_v416.z.boolean().nullish()
|
|
2946
2953
|
}).nullish(),
|
|
2947
|
-
model: import_v416.z.string().nullish()
|
|
2954
|
+
model: import_v416.z.string().nullish(),
|
|
2955
|
+
usage: import_v416.z.object({
|
|
2956
|
+
cost_in_usd_ticks: import_v416.z.number().nullish()
|
|
2957
|
+
}).nullish()
|
|
2948
2958
|
});
|
|
2949
2959
|
|
|
2950
2960
|
// src/xai-provider.ts
|