@ai-sdk/xai 3.0.133 → 3.0.135
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 +18 -0
- package/README.md +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/docs/01-xai.mdx +17 -17
- package/package.json +6 -6
- package/src/responses/xai-responses-options.ts +1 -0
- package/src/xai-chat-options.ts +1 -0
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.7`.
|
|
77
77
|
|
|
78
78
|
```ts
|
|
79
|
-
const model = xai('grok-4.
|
|
79
|
+
const model = xai('grok-4.7');
|
|
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.7'),
|
|
94
94
|
prompt: 'Write a vegetarian lasagna recipe for 4 people.',
|
|
95
95
|
});
|
|
96
96
|
```
|
|
@@ -130,7 +130,7 @@ the [standard call settings](/docs/ai-sdk-core/settings). You can pass them in t
|
|
|
130
130
|
```ts
|
|
131
131
|
import { xai, type XaiLanguageModelChatOptions } from '@ai-sdk/xai';
|
|
132
132
|
|
|
133
|
-
const model = xai('grok-4.
|
|
133
|
+
const model = xai('grok-4.7');
|
|
134
134
|
|
|
135
135
|
await generateText({
|
|
136
136
|
model,
|
|
@@ -172,7 +172,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
172
172
|
import { generateText } from 'ai';
|
|
173
173
|
|
|
174
174
|
const { providerMetadata } = await generateText({
|
|
175
|
-
model: xai('grok-4.
|
|
175
|
+
model: xai('grok-4.7'),
|
|
176
176
|
prompt: 'Explain quantum entanglement.',
|
|
177
177
|
providerOptions: {
|
|
178
178
|
xai: { serviceTier: 'priority' },
|
|
@@ -196,7 +196,7 @@ docs](https://docs.x.ai/developers/advanced-api-usage/priority-processing).
|
|
|
196
196
|
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.
|
|
197
197
|
|
|
198
198
|
```ts
|
|
199
|
-
const model = xai.responses('grok-4.
|
|
199
|
+
const model = xai.responses('grok-4.7');
|
|
200
200
|
```
|
|
201
201
|
|
|
202
202
|
The Responses API provides server-side tools that the model can autonomously execute during its reasoning process:
|
|
@@ -218,7 +218,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
218
218
|
import { generateText } from 'ai';
|
|
219
219
|
|
|
220
220
|
const { text } = await generateText({
|
|
221
|
-
model: xai.responses('grok-4.
|
|
221
|
+
model: xai.responses('grok-4.7'),
|
|
222
222
|
messages: [
|
|
223
223
|
{
|
|
224
224
|
role: 'user',
|
|
@@ -239,7 +239,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
239
239
|
import { generateText } from 'ai';
|
|
240
240
|
|
|
241
241
|
const { text } = await generateText({
|
|
242
|
-
model: xai('grok-4.
|
|
242
|
+
model: xai('grok-4.7'),
|
|
243
243
|
messages: [
|
|
244
244
|
{
|
|
245
245
|
role: 'user',
|
|
@@ -276,7 +276,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
276
276
|
import { generateText } from 'ai';
|
|
277
277
|
|
|
278
278
|
const { text, sources } = await generateText({
|
|
279
|
-
model: xai.responses('grok-4.
|
|
279
|
+
model: xai.responses('grok-4.7'),
|
|
280
280
|
prompt: 'What are the latest developments in AI?',
|
|
281
281
|
tools: {
|
|
282
282
|
web_search: xai.tools.webSearch({
|
|
@@ -314,7 +314,7 @@ The X search tool enables searching X (Twitter) for posts, with filtering by han
|
|
|
314
314
|
|
|
315
315
|
```ts
|
|
316
316
|
const { text, sources } = await generateText({
|
|
317
|
-
model: xai.responses('grok-4.
|
|
317
|
+
model: xai.responses('grok-4.7'),
|
|
318
318
|
prompt: 'What are people saying about AI on X this week?',
|
|
319
319
|
tools: {
|
|
320
320
|
x_search: xai.tools.xSearch({
|
|
@@ -360,7 +360,7 @@ The code execution tool enables the model to write and execute Python code for c
|
|
|
360
360
|
|
|
361
361
|
```ts
|
|
362
362
|
const { text } = await generateText({
|
|
363
|
-
model: xai.responses('grok-4.
|
|
363
|
+
model: xai.responses('grok-4.7'),
|
|
364
364
|
prompt:
|
|
365
365
|
'Calculate the compound interest for $10,000 at 5% annually for 10 years',
|
|
366
366
|
tools: {
|
|
@@ -375,7 +375,7 @@ The view image tool enables the model to view and analyze images:
|
|
|
375
375
|
|
|
376
376
|
```ts
|
|
377
377
|
const { text } = await generateText({
|
|
378
|
-
model: xai.responses('grok-4.
|
|
378
|
+
model: xai.responses('grok-4.7'),
|
|
379
379
|
prompt: 'Describe what you see in the image',
|
|
380
380
|
tools: {
|
|
381
381
|
view_image: xai.tools.viewImage(),
|
|
@@ -389,7 +389,7 @@ The view X video tool enables the model to view and analyze videos from X (Twitt
|
|
|
389
389
|
|
|
390
390
|
```ts
|
|
391
391
|
const { text } = await generateText({
|
|
392
|
-
model: xai.responses('grok-4.
|
|
392
|
+
model: xai.responses('grok-4.7'),
|
|
393
393
|
prompt: 'Summarize the content of this X video',
|
|
394
394
|
tools: {
|
|
395
395
|
view_x_video: xai.tools.viewXVideo(),
|
|
@@ -403,7 +403,7 @@ The MCP server tool enables the model to connect to remote [Model Context Protoc
|
|
|
403
403
|
|
|
404
404
|
```ts
|
|
405
405
|
const { text } = await generateText({
|
|
406
|
-
model: xai.responses('grok-4.
|
|
406
|
+
model: xai.responses('grok-4.7'),
|
|
407
407
|
prompt: 'Use the weather tool to check conditions in San Francisco',
|
|
408
408
|
tools: {
|
|
409
409
|
weather_server: xai.tools.mcpServer({
|
|
@@ -451,7 +451,7 @@ import { xai, type XaiLanguageModelResponsesOptions } from '@ai-sdk/xai';
|
|
|
451
451
|
import { streamText } from 'ai';
|
|
452
452
|
|
|
453
453
|
const result = streamText({
|
|
454
|
-
model: xai.responses('grok-4.
|
|
454
|
+
model: xai.responses('grok-4.7'),
|
|
455
455
|
prompt: 'What documents do you have access to?',
|
|
456
456
|
tools: {
|
|
457
457
|
file_search: xai.tools.fileSearch({
|
|
@@ -498,7 +498,7 @@ import { xai } from '@ai-sdk/xai';
|
|
|
498
498
|
import { streamText } from 'ai';
|
|
499
499
|
|
|
500
500
|
const { fullStream } = streamText({
|
|
501
|
-
model: xai.responses('grok-4.
|
|
501
|
+
model: xai.responses('grok-4.7'),
|
|
502
502
|
prompt: 'Research AI safety developments and calculate risk metrics',
|
|
503
503
|
tools: {
|
|
504
504
|
web_search: xai.tools.webSearch(),
|
|
@@ -532,7 +532,7 @@ import { xai, type XaiLanguageModelResponsesOptions } from '@ai-sdk/xai';
|
|
|
532
532
|
import { generateText } from 'ai';
|
|
533
533
|
|
|
534
534
|
const result = await generateText({
|
|
535
|
-
model: xai.responses('grok-4.
|
|
535
|
+
model: xai.responses('grok-4.7'),
|
|
536
536
|
providerOptions: {
|
|
537
537
|
xai: {
|
|
538
538
|
reasoningEffort: 'high',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.135",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
}
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
33
|
-
"@ai-sdk/provider": "3.0.
|
|
34
|
-
"@ai-sdk/provider-utils": "4.0.
|
|
32
|
+
"@ai-sdk/openai-compatible": "2.0.77",
|
|
33
|
+
"@ai-sdk/provider": "3.0.17",
|
|
34
|
+
"@ai-sdk/provider-utils": "4.0.53"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/node": "20.17.24",
|
|
38
38
|
"tsup": "^8",
|
|
39
39
|
"typescript": "5.8.3",
|
|
40
40
|
"zod": "3.25.76",
|
|
41
|
-
"@
|
|
42
|
-
"@ai-
|
|
41
|
+
"@ai-sdk/test-server": "1.0.6",
|
|
42
|
+
"@vercel/ai-tsconfig": "0.0.0"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"zod": "^3.25.76 || ^4.1.8"
|