@ai-sdk/xai 3.0.32 → 3.0.34

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 CHANGED
@@ -1,5 +1,23 @@
1
1
  # @ai-sdk/xai
2
2
 
3
+ ## 3.0.34
4
+
5
+ ### Patch Changes
6
+
7
+ - 648c8f3: fix(xai): make usage nullable in responses schema for streaming compatibility
8
+
9
+ xAI sends `usage: null` in early streaming events (`response.created`, `response.in_progress`) because token counts aren't available until the stream completes. This change makes the `usage` field nullish in `xaiResponsesResponseSchema` to accept these values without validation errors.
10
+
11
+ ## 3.0.33
12
+
13
+ ### Patch Changes
14
+
15
+ - 4de5a1d: chore: excluded tests from src folder in npm package
16
+ - Updated dependencies [4de5a1d]
17
+ - @ai-sdk/openai-compatible@2.0.18
18
+ - @ai-sdk/provider@3.0.5
19
+ - @ai-sdk/provider-utils@4.0.9
20
+
3
21
  ## 3.0.32
4
22
 
5
23
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1174,7 +1174,7 @@ var xaiResponsesResponseSchema = import_v44.z.object({
1174
1174
  model: import_v44.z.string().nullish(),
1175
1175
  object: import_v44.z.literal("response"),
1176
1176
  output: import_v44.z.array(outputItemSchema),
1177
- usage: xaiResponsesUsageSchema,
1177
+ usage: xaiResponsesUsageSchema.nullish(),
1178
1178
  status: import_v44.z.string()
1179
1179
  });
1180
1180
  var xaiResponsesChunkSchema = import_v44.z.union([
@@ -1964,7 +1964,10 @@ var XaiResponsesLanguageModel = class {
1964
1964
  unified: mapXaiResponsesFinishReason(response.status),
1965
1965
  raw: (_j = response.status) != null ? _j : void 0
1966
1966
  },
1967
- usage: convertXaiResponsesUsage(response.usage),
1967
+ usage: response.usage ? convertXaiResponsesUsage(response.usage) : {
1968
+ inputTokens: { total: 0, noCache: 0, cacheRead: 0, cacheWrite: 0 },
1969
+ outputTokens: { total: 0, text: 0, reasoning: 0 }
1970
+ },
1968
1971
  request: { body },
1969
1972
  response: {
1970
1973
  ...getResponseMetadata(response),
@@ -2326,7 +2329,7 @@ var xaiTools = {
2326
2329
  };
2327
2330
 
2328
2331
  // src/version.ts
2329
- var VERSION = true ? "3.0.32" : "0.0.0-test";
2332
+ var VERSION = true ? "3.0.34" : "0.0.0-test";
2330
2333
 
2331
2334
  // src/xai-provider.ts
2332
2335
  var xaiErrorStructure = {