@ai-sdk/openai 2.0.19 → 2.0.21

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.
@@ -424,7 +424,7 @@ var webSearchPreview = createProviderDefinedToolFactory2({
424
424
  action: z4.discriminatedUnion("type", [
425
425
  z4.object({
426
426
  type: z4.literal("search"),
427
- query: z4.string()
427
+ query: z4.string().nullish()
428
428
  }),
429
429
  z4.object({
430
430
  type: z4.literal("open_page"),
@@ -1938,8 +1938,12 @@ var OpenAITranscriptionModel = class {
1938
1938
  include: openAIOptions.include,
1939
1939
  language: openAIOptions.language,
1940
1940
  prompt: openAIOptions.prompt,
1941
- response_format: "verbose_json",
1942
- // always use verbose_json to get segments
1941
+ // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
1942
+ // prefer verbose_json to get segments for models that support it
1943
+ response_format: [
1944
+ "gpt-4o-transcribe",
1945
+ "gpt-4o-mini-transcribe"
1946
+ ].includes(this.modelId) ? "json" : "verbose_json",
1943
1947
  temperature: openAIOptions.temperature,
1944
1948
  timestamp_granularities: openAIOptions.timestampGranularities
1945
1949
  };
@@ -2490,7 +2494,7 @@ var webSearchCallItem = z16.object({
2490
2494
  action: z16.discriminatedUnion("type", [
2491
2495
  z16.object({
2492
2496
  type: z16.literal("search"),
2493
- query: z16.string()
2497
+ query: z16.string().nullish()
2494
2498
  }),
2495
2499
  z16.object({
2496
2500
  type: z16.literal("open_page"),
@@ -3018,7 +3022,7 @@ var OpenAIResponsesLanguageModel = class {
3018
3022
  controller.enqueue({ type: "stream-start", warnings });
3019
3023
  },
3020
3024
  transform(chunk, controller) {
3021
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
3025
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
3022
3026
  if (options.includeRawChunks) {
3023
3027
  controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
3024
3028
  }
@@ -3229,12 +3233,12 @@ var OpenAIResponsesLanguageModel = class {
3229
3233
  id: value.item_id,
3230
3234
  delta: value.delta
3231
3235
  });
3232
- if (value.logprobs) {
3236
+ if (((_d = (_c = options.providerOptions) == null ? void 0 : _c.openai) == null ? void 0 : _d.logprobs) && value.logprobs) {
3233
3237
  logprobs.push(value.logprobs);
3234
3238
  }
3235
3239
  } else if (isResponseReasoningSummaryPartAddedChunk(value)) {
3236
3240
  if (value.summary_index > 0) {
3237
- (_c = activeReasoning[value.item_id]) == null ? void 0 : _c.summaryParts.push(
3241
+ (_e = activeReasoning[value.item_id]) == null ? void 0 : _e.summaryParts.push(
3238
3242
  value.summary_index
3239
3243
  );
3240
3244
  controller.enqueue({
@@ -3243,7 +3247,7 @@ var OpenAIResponsesLanguageModel = class {
3243
3247
  providerMetadata: {
3244
3248
  openai: {
3245
3249
  itemId: value.item_id,
3246
- reasoningEncryptedContent: (_e = (_d = activeReasoning[value.item_id]) == null ? void 0 : _d.encryptedContent) != null ? _e : null
3250
+ reasoningEncryptedContent: (_g = (_f = activeReasoning[value.item_id]) == null ? void 0 : _f.encryptedContent) != null ? _g : null
3247
3251
  }
3248
3252
  }
3249
3253
  });
@@ -3261,20 +3265,20 @@ var OpenAIResponsesLanguageModel = class {
3261
3265
  });
3262
3266
  } else if (isResponseFinishedChunk(value)) {
3263
3267
  finishReason = mapOpenAIResponseFinishReason({
3264
- finishReason: (_f = value.response.incomplete_details) == null ? void 0 : _f.reason,
3268
+ finishReason: (_h = value.response.incomplete_details) == null ? void 0 : _h.reason,
3265
3269
  hasToolCalls
3266
3270
  });
3267
3271
  usage.inputTokens = value.response.usage.input_tokens;
3268
3272
  usage.outputTokens = value.response.usage.output_tokens;
3269
3273
  usage.totalTokens = value.response.usage.input_tokens + value.response.usage.output_tokens;
3270
- usage.reasoningTokens = (_h = (_g = value.response.usage.output_tokens_details) == null ? void 0 : _g.reasoning_tokens) != null ? _h : void 0;
3271
- usage.cachedInputTokens = (_j = (_i = value.response.usage.input_tokens_details) == null ? void 0 : _i.cached_tokens) != null ? _j : void 0;
3274
+ usage.reasoningTokens = (_j = (_i = value.response.usage.output_tokens_details) == null ? void 0 : _i.reasoning_tokens) != null ? _j : void 0;
3275
+ usage.cachedInputTokens = (_l = (_k = value.response.usage.input_tokens_details) == null ? void 0 : _k.cached_tokens) != null ? _l : void 0;
3272
3276
  } else if (isResponseAnnotationAddedChunk(value)) {
3273
3277
  if (value.annotation.type === "url_citation") {
3274
3278
  controller.enqueue({
3275
3279
  type: "source",
3276
3280
  sourceType: "url",
3277
- id: (_m = (_l = (_k = self.config).generateId) == null ? void 0 : _l.call(_k)) != null ? _m : generateId2(),
3281
+ id: (_o = (_n = (_m = self.config).generateId) == null ? void 0 : _n.call(_m)) != null ? _o : generateId2(),
3278
3282
  url: value.annotation.url,
3279
3283
  title: value.annotation.title
3280
3284
  });
@@ -3282,7 +3286,7 @@ var OpenAIResponsesLanguageModel = class {
3282
3286
  controller.enqueue({
3283
3287
  type: "source",
3284
3288
  sourceType: "document",
3285
- id: (_p = (_o = (_n = self.config).generateId) == null ? void 0 : _o.call(_n)) != null ? _p : generateId2(),
3289
+ id: (_r = (_q = (_p = self.config).generateId) == null ? void 0 : _q.call(_p)) != null ? _r : generateId2(),
3286
3290
  mediaType: "text/plain",
3287
3291
  title: value.annotation.quote,
3288
3292
  filename: value.annotation.file_id