@ai-sdk/xai 4.0.0-beta.14 → 4.0.0-beta.16
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 +14 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +34 -11
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +38 -11
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/responses/xai-responses-language-model.ts +24 -3
- package/src/responses/xai-responses-options.ts +3 -0
- package/src/xai-chat-language-model.ts +20 -1
- package/src/xai-chat-options.ts +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @ai-sdk/xai
|
|
2
2
|
|
|
3
|
+
## 4.0.0-beta.16
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4f91b5d: chore(provider/xai): update Grok 4.20 model IDs to their non-beta versions
|
|
8
|
+
|
|
9
|
+
## 4.0.0-beta.15
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 74d520f: feat: migrate providers to support new top-level `reasoning` parameter
|
|
14
|
+
- Updated dependencies [74d520f]
|
|
15
|
+
- @ai-sdk/openai-compatible@3.0.0-beta.9
|
|
16
|
+
|
|
3
17
|
## 4.0.0-beta.14
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ import { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 }
|
|
|
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 { ProviderV4, LanguageModelV4, ImageModelV4, Experimental_VideoModelV4 }
|
|
|
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
|
@@ -390,12 +390,13 @@ var XaiChatLanguageModel = class {
|
|
|
390
390
|
presencePenalty,
|
|
391
391
|
stopSequences,
|
|
392
392
|
seed,
|
|
393
|
+
reasoning,
|
|
393
394
|
responseFormat,
|
|
394
395
|
providerOptions,
|
|
395
396
|
tools,
|
|
396
397
|
toolChoice
|
|
397
398
|
}) {
|
|
398
|
-
var _a, _b, _c;
|
|
399
|
+
var _a, _b, _c, _d;
|
|
399
400
|
const warnings = [];
|
|
400
401
|
const options = (_a = await (0, import_provider_utils3.parseProviderOptions)({
|
|
401
402
|
provider: "xai",
|
|
@@ -435,14 +436,24 @@ var XaiChatLanguageModel = class {
|
|
|
435
436
|
temperature,
|
|
436
437
|
top_p: topP,
|
|
437
438
|
seed,
|
|
438
|
-
reasoning_effort: options.reasoningEffort,
|
|
439
|
+
reasoning_effort: (_b = options.reasoningEffort) != null ? _b : (0, import_provider_utils3.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils3.mapReasoningToProviderEffort)({
|
|
440
|
+
reasoning,
|
|
441
|
+
effortMap: {
|
|
442
|
+
minimal: "low",
|
|
443
|
+
low: "low",
|
|
444
|
+
medium: "low",
|
|
445
|
+
high: "high",
|
|
446
|
+
xhigh: "high"
|
|
447
|
+
},
|
|
448
|
+
warnings
|
|
449
|
+
}) : void 0,
|
|
439
450
|
// parallel function calling
|
|
440
451
|
parallel_function_calling: options.parallel_function_calling,
|
|
441
452
|
// response format
|
|
442
453
|
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
443
454
|
type: "json_schema",
|
|
444
455
|
json_schema: {
|
|
445
|
-
name: (
|
|
456
|
+
name: (_c = responseFormat.name) != null ? _c : "response",
|
|
446
457
|
schema: responseFormat.schema,
|
|
447
458
|
strict: true
|
|
448
459
|
}
|
|
@@ -454,7 +465,7 @@ var XaiChatLanguageModel = class {
|
|
|
454
465
|
from_date: options.searchParameters.fromDate,
|
|
455
466
|
to_date: options.searchParameters.toDate,
|
|
456
467
|
max_search_results: options.searchParameters.maxSearchResults,
|
|
457
|
-
sources: (
|
|
468
|
+
sources: (_d = options.searchParameters.sources) == null ? void 0 : _d.map((source) => {
|
|
458
469
|
var _a2;
|
|
459
470
|
return {
|
|
460
471
|
type: source.type,
|
|
@@ -1984,9 +1995,10 @@ var XaiResponsesLanguageModel = class {
|
|
|
1984
1995
|
responseFormat,
|
|
1985
1996
|
providerOptions,
|
|
1986
1997
|
tools,
|
|
1987
|
-
toolChoice
|
|
1998
|
+
toolChoice,
|
|
1999
|
+
reasoning
|
|
1988
2000
|
}) {
|
|
1989
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
2001
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1990
2002
|
const warnings = [];
|
|
1991
2003
|
const options = (_a = await (0, import_provider_utils11.parseProviderOptions)({
|
|
1992
2004
|
provider: "xai",
|
|
@@ -2033,6 +2045,17 @@ var XaiResponsesLanguageModel = class {
|
|
|
2033
2045
|
include = [...include, "reasoning.encrypted_content"];
|
|
2034
2046
|
}
|
|
2035
2047
|
}
|
|
2048
|
+
const resolvedReasoningEffort = (_g = options.reasoningEffort) != null ? _g : (0, import_provider_utils11.isCustomReasoning)(reasoning) ? reasoning === "none" ? void 0 : (0, import_provider_utils11.mapReasoningToProviderEffort)({
|
|
2049
|
+
reasoning,
|
|
2050
|
+
effortMap: {
|
|
2051
|
+
minimal: "low",
|
|
2052
|
+
low: "low",
|
|
2053
|
+
medium: "medium",
|
|
2054
|
+
high: "high",
|
|
2055
|
+
xhigh: "high"
|
|
2056
|
+
},
|
|
2057
|
+
warnings
|
|
2058
|
+
}) : void 0;
|
|
2036
2059
|
const baseArgs = {
|
|
2037
2060
|
model: this.modelId,
|
|
2038
2061
|
input,
|
|
@@ -2047,16 +2070,16 @@ var XaiResponsesLanguageModel = class {
|
|
|
2047
2070
|
format: responseFormat.schema != null ? {
|
|
2048
2071
|
type: "json_schema",
|
|
2049
2072
|
strict: true,
|
|
2050
|
-
name: (
|
|
2073
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
2051
2074
|
description: responseFormat.description,
|
|
2052
2075
|
schema: responseFormat.schema
|
|
2053
2076
|
} : { type: "json_object" }
|
|
2054
2077
|
}
|
|
2055
2078
|
},
|
|
2056
|
-
...(
|
|
2079
|
+
...(resolvedReasoningEffort != null || options.reasoningSummary != null) && {
|
|
2057
2080
|
reasoning: {
|
|
2058
|
-
...
|
|
2059
|
-
effort:
|
|
2081
|
+
...resolvedReasoningEffort != null && {
|
|
2082
|
+
effort: resolvedReasoningEffort
|
|
2060
2083
|
},
|
|
2061
2084
|
...options.reasoningSummary != null && {
|
|
2062
2085
|
summary: options.reasoningSummary
|
|
@@ -2726,7 +2749,7 @@ var xaiTools = {
|
|
|
2726
2749
|
};
|
|
2727
2750
|
|
|
2728
2751
|
// src/version.ts
|
|
2729
|
-
var VERSION = true ? "4.0.0-beta.
|
|
2752
|
+
var VERSION = true ? "4.0.0-beta.16" : "0.0.0-test";
|
|
2730
2753
|
|
|
2731
2754
|
// src/xai-video-model.ts
|
|
2732
2755
|
var import_provider6 = require("@ai-sdk/provider");
|