@ai-sdk/xai 4.0.40 → 4.0.42
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 +13 -0
- package/dist/index.js +8 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/xai-image-model.ts +7 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-sdk/xai",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.42",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@ai-sdk/provider": "4.0.7",
|
|
33
|
-
"@ai-sdk/provider-utils": "5.0.
|
|
33
|
+
"@ai-sdk/provider-utils": "5.0.28"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/node": "22.19.19",
|
package/src/xai-image-model.ts
CHANGED
|
@@ -162,6 +162,12 @@ export class XaiImageModel implements ImageModelV4 {
|
|
|
162
162
|
fetch: this.config.fetch,
|
|
163
163
|
});
|
|
164
164
|
|
|
165
|
+
if (response.data.some(image => image.respect_moderation === false)) {
|
|
166
|
+
throw new Error(
|
|
167
|
+
'Image generation was blocked due to a content policy violation.',
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
165
171
|
const hasAllBase64 = response.data.every(image => image.b64_json != null);
|
|
166
172
|
|
|
167
173
|
const images = hasAllBase64
|
|
@@ -219,6 +225,7 @@ const xaiImageResponseSchema = z.object({
|
|
|
219
225
|
url: z.string().nullish(),
|
|
220
226
|
b64_json: z.string().nullish(),
|
|
221
227
|
revised_prompt: z.string().nullish(),
|
|
228
|
+
respect_moderation: z.boolean().nullish(),
|
|
222
229
|
}),
|
|
223
230
|
),
|
|
224
231
|
usage: z
|