@ai-sdk/xai 3.0.117 → 3.0.119
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 +4 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +6 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -5
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +19 -15
- package/package.json +3 -3
- package/src/responses/xai-responses-options.ts +7 -3
- package/src/xai-chat-options.ts +4 -1
package/docs/01-xai.mdx
CHANGED
|
@@ -73,10 +73,10 @@ You can use the following optional settings to customize the xAI provider instan
|
|
|
73
73
|
## Language Models
|
|
74
74
|
|
|
75
75
|
You can create [xAI models](https://console.x.ai) using a provider instance. The
|
|
76
|
-
first argument is the model id, e.g. `grok-4.
|
|
76
|
+
first argument is the model id, e.g. `grok-4.6`.
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
const model = xai('grok-4.
|
|
79
|
+
const model = xai('grok-4.6');
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
By default, `xai(modelId)` uses the Chat API. To use the Responses API with server-side agentic tools, explicitly use `xai.responses(modelId)`.
|
|
@@ -90,7 +90,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
90
90
|
import { generateText } from 'ai';
|
|
91
91
|
|
|
92
92
|
const { text } = await generateText({
|
|
93
|
-
model: xai('grok-4.
|
|
93
|
+
model: xai('grok-4.6'),
|
|
94
94
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
95
95
|
});
|
|
96
96
|
```
|
|
@@ -104,16 +104,19 @@ and support structured data generation with [`Output`](/docs/reference/ai-sdk-co
|
|
|
104
104
|
For models with configurable reasoning, you can control how much effort the
|
|
105
105
|
model spends thinking before responding with
|
|
106
106
|
`providerOptions.xai.reasoningEffort`. The AI SDK option accepts `'none'`,
|
|
107
|
-
`'low'`, `'medium'`, and `'
|
|
107
|
+
`'low'`, `'medium'`, `'high'`, and `'xhigh'`, but each xAI model supports a
|
|
108
|
+
subset.
|
|
108
109
|
|
|
109
110
|
<Note>
|
|
110
|
-
Support and defaults are model-specific. `grok-4.
|
|
111
|
-
`'
|
|
112
|
-
|
|
113
|
-
`grok-4.
|
|
114
|
-
|
|
115
|
-
`grok-4.20-
|
|
116
|
-
|
|
111
|
+
Support and defaults are model-specific. `grok-4.6` supports `'low'`,
|
|
112
|
+
`'medium'`, `'high'`, and `'xhigh'`, defaults to `'high'`, and cannot disable
|
|
113
|
+
reasoning. `grok-4.3` supports `'none'`, `'low'`, `'medium'`, and `'high'`.
|
|
114
|
+
`grok-4.5` supports `'low'`, `'medium'`, and `'high'`, defaults to `'high'`,
|
|
115
|
+
and cannot disable reasoning. The `grok-4.20-reasoning` and
|
|
116
|
+
`grok-4.20-non-reasoning` variants do not accept this option, and neither does
|
|
117
|
+
`grok-build-0.1`. For `grok-4.20-multi-agent`, `'low'`, `'medium'`, and
|
|
118
|
+
`'high'` control the number of agents instead of reasoning depth. See xAI's
|
|
119
|
+
[reasoning
|
|
117
120
|
docs](https://docs.x.ai/developers/model-capabilities/text/reasoning) and
|
|
118
121
|
[Grok 4.3 model page](https://docs.x.ai/developers/models/grok-4.3) for
|
|
119
122
|
current details.
|
|
@@ -127,7 +130,7 @@ the [standard call settings](/docs/ai-sdk-core/settings). You can pass them in t
|
|
|
127
130
|
```ts
|
|
128
131
|
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
129
132
|
|
|
130
|
-
const model = xai('grok-4.
|
|
133
|
+
const model = xai('grok-4.6');
|
|
131
134
|
|
|
132
135
|
await generateText({
|
|
133
136
|
model,
|
|
@@ -162,7 +165,7 @@ The following optional provider options are available for xAI chat models:
|
|
|
162
165
|
You can use the xAI Responses API with the `xai.responses(modelId)` factory method for server-side agentic tool calling. This enables the model to autonomously orchestrate tool calls and research on xAI's servers.
|
|
163
166
|
|
|
164
167
|
```ts
|
|
165
|
-
const model = xai.responses('grok-4.
|
|
168
|
+
const model = xai.responses('grok-4.6');
|
|
166
169
|
```
|
|
167
170
|
|
|
168
171
|
The Responses API provides server-side tools that the model can autonomously execute during its reasoning process:
|
|
@@ -498,7 +501,7 @@ import { xai, type XaiLanguageModelResponsesOptions } from '@ai-sdk/xai';
|
|
|
498
501
|
import { generateText } from 'ai';
|
|
499
502
|
|
|
500
503
|
const result = await generateText({
|
|
501
|
-
model: xai.responses('grok-4.
|
|
504
|
+
model: xai.responses('grok-4.6'),
|
|
502
505
|
providerOptions: {
|
|
503
506
|
xai: {
|
|
504
507
|
reasoningEffort: 'high',
|
|
@@ -510,7 +513,7 @@ const result = await generateText({
|
|
|
510
513
|
|
|
511
514
|
The following provider options are available:
|
|
512
515
|
|
|
513
|
-
- **reasoningEffort** _'none' | 'low' | 'medium' | 'high'_
|
|
516
|
+
- **reasoningEffort** _'none' | 'low' | 'medium' | 'high' | 'xhigh'_
|
|
514
517
|
|
|
515
518
|
Control the reasoning effort for supported models. See [Reasoning Effort](#reasoning-effort) for model-specific values and defaults.
|
|
516
519
|
|
|
@@ -828,6 +831,7 @@ console.log('Sources:', await result.sources);
|
|
|
828
831
|
|
|
829
832
|
| Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Reasoning |
|
|
830
833
|
| ----------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
|
|
834
|
+
| `grok-4.6` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
831
835
|
| `grok-4.5` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
832
836
|
| `grok-4.20-reasoning` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
|
|
833
837
|
| `grok-4.20-non-reasoning` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Cross size={18} /> |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.119",
|
|
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": "2.0.
|
|
32
|
+
"@ai-sdk/openai-compatible": "2.0.67",
|
|
33
33
|
"@ai-sdk/provider": "3.0.15",
|
|
34
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
34
|
+
"@ai-sdk/provider-utils": "4.0.45"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod/v4';
|
|
2
2
|
|
|
3
3
|
export type XaiResponsesModelId =
|
|
4
|
+
| 'grok-4.6'
|
|
4
5
|
| 'grok-4.5'
|
|
5
6
|
| 'grok-4.3'
|
|
6
7
|
| 'grok-4.20-0309-reasoning'
|
|
@@ -16,10 +17,13 @@ export const xaiLanguageModelResponsesOptions = z.object({
|
|
|
16
17
|
/**
|
|
17
18
|
* Constrains how hard a reasoning model thinks before responding.
|
|
18
19
|
* Possible values are `none` (disables reasoning), `low` (uses fewer reasoning
|
|
19
|
-
* tokens), `medium` and `
|
|
20
|
-
* support reasoning effort; see xAI's docs for the values each model
|
|
20
|
+
* tokens), `medium`, `high`, and `xhigh` (uses more reasoning tokens). Not all
|
|
21
|
+
* models support reasoning effort; see xAI's docs for the values each model
|
|
22
|
+
* accepts. `xhigh` is currently only supported by `grok-4.6`.
|
|
21
23
|
*/
|
|
22
|
-
reasoningEffort: z
|
|
24
|
+
reasoningEffort: z
|
|
25
|
+
.enum(['none', 'low', 'medium', 'high', 'xhigh'])
|
|
26
|
+
.optional(),
|
|
23
27
|
logprobs: z.boolean().optional(),
|
|
24
28
|
topLogprobs: z.number().int().min(0).max(8).optional(),
|
|
25
29
|
/**
|
package/src/xai-chat-options.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { z } from 'zod/v4';
|
|
|
2
2
|
|
|
3
3
|
// https://docs.x.ai/docs/models
|
|
4
4
|
export type XaiChatModelId =
|
|
5
|
+
| 'grok-4.6'
|
|
5
6
|
| 'grok-4.5'
|
|
6
7
|
| 'grok-4.3'
|
|
7
8
|
| 'grok-4.20-0309-reasoning'
|
|
@@ -52,7 +53,9 @@ const searchSourceSchema = z.discriminatedUnion('type', [
|
|
|
52
53
|
|
|
53
54
|
// xai-specific provider options
|
|
54
55
|
export const xaiLanguageModelChatOptions = z.object({
|
|
55
|
-
reasoningEffort: z
|
|
56
|
+
reasoningEffort: z
|
|
57
|
+
.enum(['none', 'low', 'medium', 'high', 'xhigh'])
|
|
58
|
+
.optional(),
|
|
56
59
|
logprobs: z.boolean().optional(),
|
|
57
60
|
topLogprobs: z.number().int().min(0).max(8).optional(),
|
|
58
61
|
|