@ai-sdk/openai 2.0.21 → 2.0.23

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.
@@ -2703,7 +2703,7 @@ var OpenAIResponsesLanguageModel = class {
2703
2703
  };
2704
2704
  }
2705
2705
  async doGenerate(options) {
2706
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
2706
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
2707
2707
  const { args: body, warnings } = await this.getArgs(options);
2708
2708
  const url = this.config.url({
2709
2709
  path: "/responses",
@@ -2749,10 +2749,12 @@ var OpenAIResponsesLanguageModel = class {
2749
2749
  }),
2750
2750
  z16.object({
2751
2751
  type: z16.literal("file_citation"),
2752
- start_index: z16.number(),
2753
- end_index: z16.number(),
2754
2752
  file_id: z16.string(),
2755
- quote: z16.string()
2753
+ filename: z16.string().nullish(),
2754
+ index: z16.number().nullish(),
2755
+ start_index: z16.number().nullish(),
2756
+ end_index: z16.number().nullish(),
2757
+ quote: z16.string().nullish()
2756
2758
  })
2757
2759
  ])
2758
2760
  )
@@ -2801,6 +2803,7 @@ var OpenAIResponsesLanguageModel = class {
2801
2803
  })
2802
2804
  ])
2803
2805
  ),
2806
+ service_tier: z16.string().nullish(),
2804
2807
  incomplete_details: z16.object({ reason: z16.string() }).nullable(),
2805
2808
  usage: usageSchema2
2806
2809
  })
@@ -2870,8 +2873,8 @@ var OpenAIResponsesLanguageModel = class {
2870
2873
  sourceType: "document",
2871
2874
  id: (_i = (_h = (_g = this.config).generateId) == null ? void 0 : _h.call(_g)) != null ? _i : generateId2(),
2872
2875
  mediaType: "text/plain",
2873
- title: annotation.quote,
2874
- filename: annotation.file_id
2876
+ title: (_k = (_j = annotation.quote) != null ? _j : annotation.filename) != null ? _k : "Document",
2877
+ filename: (_l = annotation.filename) != null ? _l : annotation.file_id
2875
2878
  });
2876
2879
  }
2877
2880
  }
@@ -2959,18 +2962,21 @@ var OpenAIResponsesLanguageModel = class {
2959
2962
  if (logprobs.length > 0) {
2960
2963
  providerMetadata.openai.logprobs = logprobs;
2961
2964
  }
2965
+ if (typeof response.service_tier === "string") {
2966
+ providerMetadata.openai.serviceTier = response.service_tier;
2967
+ }
2962
2968
  return {
2963
2969
  content,
2964
2970
  finishReason: mapOpenAIResponseFinishReason({
2965
- finishReason: (_j = response.incomplete_details) == null ? void 0 : _j.reason,
2971
+ finishReason: (_m = response.incomplete_details) == null ? void 0 : _m.reason,
2966
2972
  hasToolCalls: content.some((part) => part.type === "tool-call")
2967
2973
  }),
2968
2974
  usage: {
2969
2975
  inputTokens: response.usage.input_tokens,
2970
2976
  outputTokens: response.usage.output_tokens,
2971
2977
  totalTokens: response.usage.input_tokens + response.usage.output_tokens,
2972
- reasoningTokens: (_l = (_k = response.usage.output_tokens_details) == null ? void 0 : _k.reasoning_tokens) != null ? _l : void 0,
2973
- cachedInputTokens: (_n = (_m = response.usage.input_tokens_details) == null ? void 0 : _m.cached_tokens) != null ? _n : void 0
2978
+ reasoningTokens: (_o = (_n = response.usage.output_tokens_details) == null ? void 0 : _n.reasoning_tokens) != null ? _o : void 0,
2979
+ cachedInputTokens: (_q = (_p = response.usage.input_tokens_details) == null ? void 0 : _p.cached_tokens) != null ? _q : void 0
2974
2980
  },
2975
2981
  request: { body },
2976
2982
  response: {
@@ -3015,6 +3021,7 @@ var OpenAIResponsesLanguageModel = class {
3015
3021
  const ongoingToolCalls = {};
3016
3022
  let hasToolCalls = false;
3017
3023
  const activeReasoning = {};
3024
+ let serviceTier;
3018
3025
  return {
3019
3026
  stream: response.pipeThrough(
3020
3027
  new TransformStream({
@@ -3022,7 +3029,7 @@ var OpenAIResponsesLanguageModel = class {
3022
3029
  controller.enqueue({ type: "stream-start", warnings });
3023
3030
  },
3024
3031
  transform(chunk, controller) {
3025
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3032
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u;
3026
3033
  if (options.includeRawChunks) {
3027
3034
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3028
3035
  }
@@ -3273,6 +3280,9 @@ var OpenAIResponsesLanguageModel = class {
3273
3280
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
3274
3281
  usage.reasoningTokens = (_j = (_i = value.response.usage.output_tokens_details) == null ? void 0 : _i.reasoning_tokens) != null ? _j : void 0;
3275
3282
  usage.cachedInputTokens = (_l = (_k = value.response.usage.input_tokens_details) == null ? void 0 : _k.cached_tokens) != null ? _l : void 0;
3283
+ if (typeof value.response.service_tier === "string") {
3284
+ serviceTier = value.response.service_tier;
3285
+ }
3276
3286
  } else if (isResponseAnnotationAddedChunk(value)) {
3277
3287
  if (value.annotation.type === "url_citation") {
3278
3288
  controller.enqueue({
@@ -3288,8 +3298,8 @@ var OpenAIResponsesLanguageModel = class {
3288
3298
  sourceType: "document",
3289
3299
  id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
3290
3300
  mediaType: "text/plain",
3291
- title: value.annotation.quote,
3292
- filename: value.annotation.file_id
3301
+ title: (_t = (_s = value.annotation.quote) != null ? _s : value.annotation.filename) != null ? _t : "Document",
3302
+ filename: (_u = value.annotation.filename) != null ? _u : value.annotation.file_id
3293
3303
  });
3294
3304
  }
3295
3305
  } else if (isErrorChunk(value)) {
@@ -3305,6 +3315,9 @@ var OpenAIResponsesLanguageModel = class {
3305
3315
  if (logprobs.length > 0) {
3306
3316
  providerMetadata.openai.logprobs = logprobs;
3307
3317
  }
3318
+ if (serviceTier !== void 0) {
3319
+ providerMetadata.openai.serviceTier = serviceTier;
3320
+ }
3308
3321
  controller.enqueue({
3309
3322
  type: "finish",
3310
3323
  finishReason,
@@ -3342,7 +3355,8 @@ var responseFinishedChunkSchema = z16.object({
3342
3355
  type: z16.enum(["response.completed", "response.incomplete"]),
3343
3356
  response: z16.object({
3344
3357
  incomplete_details: z16.object({ reason: z16.string() }).nullish(),
3345
- usage: usageSchema2
3358
+ usage: usageSchema2,
3359
+ service_tier: z16.string().nullish()
3346
3360
  })
3347
3361
  });
3348
3362
  var responseCreatedChunkSchema = z16.object({
@@ -3350,7 +3364,8 @@ var responseCreatedChunkSchema = z16.object({
3350
3364
  response: z16.object({
3351
3365
  id: z16.string(),
3352
3366
  created_at: z16.number(),
3353
- model: z16.string()
3367
+ model: z16.string(),
3368
+ service_tier: z16.string().nullish()
3354
3369
  })
3355
3370
  });
3356
3371
  var responseOutputItemAddedSchema = z16.object({
@@ -3467,7 +3482,11 @@ var responseAnnotationAddedSchema = z16.object({
3467
3482
  z16.object({
3468
3483
  type: z16.literal("file_citation"),
3469
3484
  file_id: z16.string(),
3470
- quote: z16.string()
3485
+ filename: z16.string().nullish(),
3486
+ index: z16.number().nullish(),
3487
+ start_index: z16.number().nullish(),
3488
+ end_index: z16.number().nullish(),
3489
+ quote: z16.string().nullish()
3471
3490
  })
3472
3491
  ])
3473
3492
  });