@ai-sdk/xai 3.0.124 → 3.0.126

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/docs/01-xai.mdx CHANGED
@@ -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.5'),
221
+ model: xai.responses('grok-4.6'),
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.5'),
242
+ model: xai('grok-4.6'),
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.20-non-reasoning'),
279
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
317
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
363
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
378
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
392
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
406
+ model: xai.responses('grok-4.6'),
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.20-reasoning'),
454
+ model: xai.responses('grok-4.6'),
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.20-non-reasoning'),
501
+ model: xai.responses('grok-4.6'),
502
502
  prompt: 'Research AI safety developments and calculate risk metrics',
503
503
  tools: {
504
504
  web_search: xai.tools.webSearch(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/xai",
3
- "version": "3.0.124",
3
+ "version": "3.0.126",
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.70",
32
+ "@ai-sdk/openai-compatible": "2.0.72",
33
33
  "@ai-sdk/provider": "3.0.15",
34
- "@ai-sdk/provider-utils": "4.0.46"
34
+ "@ai-sdk/provider-utils": "4.0.48"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/node": "20.17.24",
@@ -145,6 +145,12 @@ export class XaiImageModel implements ImageModelV3 {
145
145
  fetch: this.config.fetch,
146
146
  });
147
147
 
148
+ if (response.data.some(image => image.respect_moderation === false)) {
149
+ throw new Error(
150
+ 'Image generation was blocked due to a content policy violation.',
151
+ );
152
+ }
153
+
148
154
  const hasAllBase64 = response.data.every(image => image.b64_json != null);
149
155
 
150
156
  const images = hasAllBase64
@@ -199,6 +205,7 @@ const xaiImageResponseSchema = z.object({
199
205
  url: z.string().nullish(),
200
206
  b64_json: z.string().nullish(),
201
207
  revised_prompt: z.string().nullish(),
208
+ respect_moderation: z.boolean().nullish(),
202
209
  }),
203
210
  ),
204
211
  usage: z