@ai-sdk/xai 2.0.62 → 2.0.64
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 +16 -4
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +10 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 2.0.64
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 2418bd8: fix(provider/xai): correct finish reason for tool calls
|
|
8
|
+
|
|
9
|
+
## 2.0.63
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 5e55f43: chore(provider/xai): update Grok 4.20 model IDs to their non-beta versions
|
|
14
|
+
|
|
3
15
|
## 2.0.62
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
|
@@ -458,7 +470,7 @@
|
|
|
458
470
|
|
|
459
471
|
```js
|
|
460
472
|
await generateImage({
|
|
461
|
-
model: luma.image(
|
|
473
|
+
model: luma.image("photon-flash-1", {
|
|
462
474
|
maxImagesPerCall: 5,
|
|
463
475
|
pollIntervalMillis: 500,
|
|
464
476
|
}),
|
|
@@ -471,7 +483,7 @@
|
|
|
471
483
|
|
|
472
484
|
```js
|
|
473
485
|
await generateImage({
|
|
474
|
-
model: luma.image(
|
|
486
|
+
model: luma.image("photon-flash-1"),
|
|
475
487
|
prompt,
|
|
476
488
|
n: 10,
|
|
477
489
|
maxImagesPerCall: 5,
|
|
@@ -924,7 +936,7 @@
|
|
|
924
936
|
|
|
925
937
|
```js
|
|
926
938
|
await generateImage({
|
|
927
|
-
model: luma.image(
|
|
939
|
+
model: luma.image("photon-flash-1", {
|
|
928
940
|
maxImagesPerCall: 5,
|
|
929
941
|
pollIntervalMillis: 500,
|
|
930
942
|
}),
|
|
@@ -937,7 +949,7 @@
|
|
|
937
949
|
|
|
938
950
|
```js
|
|
939
951
|
await generateImage({
|
|
940
|
-
model: luma.image(
|
|
952
|
+
model: luma.image("photon-flash-1"),
|
|
941
953
|
prompt,
|
|
942
954
|
n: 10,
|
|
943
955
|
maxImagesPerCall: 5,
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { ProviderV2, LanguageModelV2, ImageModelV2 } from '@ai-sdk/provider';
|
|
|
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' | '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-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
6
|
+
type XaiChatModelId = 'grok-4-1' | '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-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
7
|
declare const xaiProviderOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -56,7 +56,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | '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 & {});
|
|
60
60
|
/**
|
|
61
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
62
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { ProviderV2, LanguageModelV2, ImageModelV2 } from '@ai-sdk/provider';
|
|
|
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' | '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-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
6
|
+
type XaiChatModelId = 'grok-4-1' | '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-fast' | 'grok-3-fast-latest' | 'grok-3-mini' | 'grok-3-mini-latest' | 'grok-3-mini-fast' | 'grok-3-mini-fast-latest' | 'grok-2-vision-1212' | 'grok-2-vision' | 'grok-2-vision-latest' | 'grok-2-image-1212' | 'grok-2-image' | 'grok-2-image-latest' | 'grok-2-1212' | 'grok-2' | 'grok-2-latest' | 'grok-vision-beta' | 'grok-beta' | (string & {});
|
|
7
7
|
declare const xaiProviderOptions: z.ZodObject<{
|
|
8
8
|
reasoningEffort: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
low: "low";
|
|
@@ -56,7 +56,7 @@ declare const xaiErrorDataSchema: z.ZodObject<{
|
|
|
56
56
|
}, z.core.$strip>;
|
|
57
57
|
type XaiErrorData = z.infer<typeof xaiErrorDataSchema>;
|
|
58
58
|
|
|
59
|
-
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | 'grok-4-fast-non-reasoning' | (string & {});
|
|
59
|
+
type XaiResponsesModelId = 'grok-4-1' | 'grok-4-1-fast-reasoning' | 'grok-4-1-fast-non-reasoning' | 'grok-4' | 'grok-4-fast' | '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 & {});
|
|
60
60
|
/**
|
|
61
61
|
* @see https://docs.x.ai/docs/api-reference#create-new-response
|
|
62
62
|
*/
|
package/dist/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
VERSION: () => VERSION,
|
|
24
24
|
codeExecution: () => codeExecution,
|
|
25
25
|
createXai: () => createXai,
|
|
@@ -30,7 +30,7 @@ __export(src_exports, {
|
|
|
30
30
|
xai: () => xai,
|
|
31
31
|
xaiTools: () => xaiTools
|
|
32
32
|
});
|
|
33
|
-
module.exports = __toCommonJS(
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
34
|
|
|
35
35
|
// src/xai-provider.ts
|
|
36
36
|
var import_openai_compatible = require("@ai-sdk/openai-compatible");
|
|
@@ -1781,6 +1781,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1781
1781
|
fetch: this.config.fetch
|
|
1782
1782
|
});
|
|
1783
1783
|
const content = [];
|
|
1784
|
+
let hasFunctionCall = false;
|
|
1784
1785
|
const webSearchSubTools = [
|
|
1785
1786
|
"web_search",
|
|
1786
1787
|
"web_search_with_snippets",
|
|
@@ -1838,6 +1839,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1838
1839
|
break;
|
|
1839
1840
|
}
|
|
1840
1841
|
case "function_call": {
|
|
1842
|
+
hasFunctionCall = true;
|
|
1841
1843
|
content.push({
|
|
1842
1844
|
type: "tool-call",
|
|
1843
1845
|
toolCallId: part.call_id,
|
|
@@ -1879,7 +1881,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1879
1881
|
}
|
|
1880
1882
|
return {
|
|
1881
1883
|
content,
|
|
1882
|
-
finishReason: mapXaiResponsesFinishReason(response.status),
|
|
1884
|
+
finishReason: hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response.status),
|
|
1883
1885
|
usage: convertXaiResponsesUsage(response.usage),
|
|
1884
1886
|
request: { body },
|
|
1885
1887
|
response: {
|
|
@@ -1920,6 +1922,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
1920
1922
|
outputTokens: void 0,
|
|
1921
1923
|
totalTokens: void 0
|
|
1922
1924
|
};
|
|
1925
|
+
let hasFunctionCall = false;
|
|
1923
1926
|
let isFirstChunk = true;
|
|
1924
1927
|
const contentBlocks = {};
|
|
1925
1928
|
const seenToolCalls = /* @__PURE__ */ new Set();
|
|
@@ -2066,7 +2069,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2066
2069
|
usage.cachedInputTokens = converted.cachedInputTokens;
|
|
2067
2070
|
}
|
|
2068
2071
|
if (response2.status) {
|
|
2069
|
-
finishReason = mapXaiResponsesFinishReason(response2.status);
|
|
2072
|
+
finishReason = hasFunctionCall ? "tool-calls" : mapXaiResponsesFinishReason(response2.status);
|
|
2070
2073
|
}
|
|
2071
2074
|
return;
|
|
2072
2075
|
}
|
|
@@ -2206,6 +2209,7 @@ var XaiResponsesLanguageModel = class {
|
|
|
2206
2209
|
toolName: part.name
|
|
2207
2210
|
});
|
|
2208
2211
|
} else if (event.type === "response.output_item.done") {
|
|
2212
|
+
hasFunctionCall = true;
|
|
2209
2213
|
ongoingToolCalls[event.output_index] = void 0;
|
|
2210
2214
|
controller.enqueue({
|
|
2211
2215
|
type: "tool-input-end",
|
|
@@ -2296,7 +2300,7 @@ var xaiTools = {
|
|
|
2296
2300
|
};
|
|
2297
2301
|
|
|
2298
2302
|
// src/version.ts
|
|
2299
|
-
var VERSION = true ? "2.0.
|
|
2303
|
+
var VERSION = true ? "2.0.64" : "0.0.0-test";
|
|
2300
2304
|
|
|
2301
2305
|
// src/xai-provider.ts
|
|
2302
2306
|
var xaiErrorStructure = {
|