@ai-sdk/xai 4.0.0-beta.13 → 4.0.0-beta.15

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "4.0.0-beta.13",
3
+ "version": "4.0.0-beta.15",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -29,9 +29,9 @@
29
29
  }
30
30
  },
31
31
  "dependencies": {
32
- "@ai-sdk/openai-compatible": "3.0.0-beta.7",
33
- "@ai-sdk/provider": "4.0.0-beta.3",
34
- "@ai-sdk/provider-utils": "5.0.0-beta.5"
32
+ "@ai-sdk/openai-compatible": "3.0.0-beta.9",
33
+ "@ai-sdk/provider": "4.0.0-beta.4",
34
+ "@ai-sdk/provider-utils": "5.0.0-beta.6"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -65,9 +65,7 @@
65
65
  "build": "pnpm clean && tsup --tsconfig tsconfig.build.json",
66
66
  "build:watch": "pnpm clean && tsup --watch",
67
67
  "clean": "del-cli dist docs *.tsbuildinfo",
68
- "lint": "eslint \"./**/*.ts*\"",
69
68
  "type-check": "tsc --build",
70
- "prettier-check": "prettier --check \"./**/*.ts*\"",
71
69
  "test": "pnpm test:node && pnpm test:edge",
72
70
  "test:update": "pnpm test:node -u",
73
71
  "test:watch": "vitest --config vitest.node.config.js",
@@ -14,6 +14,8 @@ import {
14
14
  createEventSourceResponseHandler,
15
15
  createJsonResponseHandler,
16
16
  FetchFunction,
17
+ isCustomReasoning,
18
+ mapReasoningToProviderEffort,
17
19
  parseProviderOptions,
18
20
  ParseResult,
19
21
  postJsonToApi,
@@ -74,6 +76,7 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
74
76
  providerOptions,
75
77
  tools,
76
78
  toolChoice,
79
+ reasoning,
77
80
  }: LanguageModelV4CallOptions) {
78
81
  const warnings: SharedV4Warning[] = [];
79
82
 
@@ -139,6 +142,24 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
139
142
  }
140
143
  }
141
144
 
145
+ const resolvedReasoningEffort =
146
+ options.reasoningEffort ??
147
+ (isCustomReasoning(reasoning)
148
+ ? reasoning === 'none'
149
+ ? undefined
150
+ : mapReasoningToProviderEffort({
151
+ reasoning,
152
+ effortMap: {
153
+ minimal: 'low',
154
+ low: 'low',
155
+ medium: 'medium',
156
+ high: 'high',
157
+ xhigh: 'high',
158
+ },
159
+ warnings,
160
+ })
161
+ : undefined);
162
+
142
163
  const baseArgs: Record<string, unknown> = {
143
164
  model: this.modelId,
144
165
  input,
@@ -165,11 +186,11 @@ export class XaiResponsesLanguageModel implements LanguageModelV4 {
165
186
  : { type: 'json_object' },
166
187
  },
167
188
  }),
168
- ...((options.reasoningEffort != null ||
189
+ ...((resolvedReasoningEffort != null ||
169
190
  options.reasoningSummary != null) && {
170
191
  reasoning: {
171
- ...(options.reasoningEffort != null && {
172
- effort: options.reasoningEffort,
192
+ ...(resolvedReasoningEffort != null && {
193
+ effort: resolvedReasoningEffort,
173
194
  }),
174
195
  ...(options.reasoningSummary != null && {
175
196
  summary: options.reasoningSummary,
@@ -16,6 +16,8 @@ import {
16
16
  createJsonResponseHandler,
17
17
  extractResponseHeaders,
18
18
  FetchFunction,
19
+ isCustomReasoning,
20
+ mapReasoningToProviderEffort,
19
21
  parseProviderOptions,
20
22
  ParseResult,
21
23
  postJsonToApi,
@@ -71,6 +73,7 @@ export class XaiChatLanguageModel implements LanguageModelV4 {
71
73
  presencePenalty,
72
74
  stopSequences,
73
75
  seed,
76
+ reasoning,
74
77
  responseFormat,
75
78
  providerOptions,
76
79
  tools,
@@ -133,7 +136,23 @@ export class XaiChatLanguageModel implements LanguageModelV4 {
133
136
  temperature,
134
137
  top_p: topP,
135
138
  seed,
136
- reasoning_effort: options.reasoningEffort,
139
+ reasoning_effort:
140
+ options.reasoningEffort ??
141
+ (isCustomReasoning(reasoning)
142
+ ? reasoning === 'none'
143
+ ? undefined
144
+ : mapReasoningToProviderEffort({
145
+ reasoning,
146
+ effortMap: {
147
+ minimal: 'low',
148
+ low: 'low',
149
+ medium: 'low',
150
+ high: 'high',
151
+ xhigh: 'high',
152
+ },
153
+ warnings,
154
+ })
155
+ : undefined),
137
156
 
138
157
  // parallel function calling
139
158
  parallel_function_calling: options.parallel_function_calling,