@ai-sdk/openai 2.0.136 → 2.0.138

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/dist/index.mjs CHANGED
@@ -4249,7 +4249,7 @@ var OpenAIResponsesLanguageModel = class {
4249
4249
  type: "tool-result",
4250
4250
  toolCallId: part.id,
4251
4251
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4252
- result: mapWebSearchOutput(part.action),
4252
+ ...mapWebSearchResult(part),
4253
4253
  providerExecuted: true
4254
4254
  });
4255
4255
  break;
@@ -4581,7 +4581,7 @@ var OpenAIResponsesLanguageModel = class {
4581
4581
  type: "tool-result",
4582
4582
  toolCallId: value.item.id,
4583
4583
  toolName: webSearchToolName != null ? webSearchToolName : "web_search",
4584
- result: mapWebSearchOutput(value.item.action),
4584
+ ...mapWebSearchResult(value.item),
4585
4585
  providerExecuted: true
4586
4586
  });
4587
4587
  } else if (value.item.type === "computer_call") {
@@ -4910,6 +4910,12 @@ function isResponseAnnotationAddedChunk(chunk) {
4910
4910
  function isErrorChunk(chunk) {
4911
4911
  return chunk.type === "error";
4912
4912
  }
4913
+ function mapWebSearchResult({
4914
+ action,
4915
+ status
4916
+ }) {
4917
+ return status === "completed" ? { result: mapWebSearchOutput(action) } : { isError: true, result: { status } };
4918
+ }
4913
4919
  function mapWebSearchOutput(action) {
4914
4920
  var _a2;
4915
4921
  if (action == null) {
@@ -5116,7 +5122,12 @@ var openaiTranscriptionResponseSchema = lazyValidator12(
5116
5122
  compression_ratio: z20.number(),
5117
5123
  no_speech_prob: z20.number()
5118
5124
  })
5119
- ).nullish()
5125
+ ).nullish(),
5126
+ // Lenient: an unexpected usage shape must not fail the transcription.
5127
+ usage: z20.object({
5128
+ type: z20.string().nullish(),
5129
+ seconds: z20.number().nullish()
5130
+ }).nullish().catch(void 0)
5120
5131
  })
5121
5132
  )
5122
5133
  );
@@ -5252,10 +5263,10 @@ var OpenAITranscriptionModel = class {
5252
5263
  prompt: openAIOptions.prompt,
5253
5264
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
5254
5265
  // prefer verbose_json to get segments for models that support it
5255
- response_format: [
5256
- "gpt-4o-transcribe",
5257
- "gpt-4o-mini-transcribe"
5258
- ].includes(this.modelId) ? "json" : "verbose_json",
5266
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
5267
+ response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
5268
+ this.modelId
5269
+ ) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
5259
5270
  temperature: openAIOptions.temperature,
5260
5271
  timestamp_granularities: openAIOptions.timestampGranularities
5261
5272
  };
@@ -5277,7 +5288,7 @@ var OpenAITranscriptionModel = class {
5277
5288
  };
5278
5289
  }
5279
5290
  async doGenerate(options) {
5280
- var _a2, _b, _c, _d, _e, _f, _g, _h;
5291
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5281
5292
  const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
5282
5293
  const { formData, warnings } = await this.getArgs(options);
5283
5294
  const {
@@ -5311,7 +5322,8 @@ var OpenAITranscriptionModel = class {
5311
5322
  endSecond: word.end
5312
5323
  }))) != null ? _g : [],
5313
5324
  language,
5314
- durationInSeconds: (_h = response.duration) != null ? _h : void 0,
5325
+ // Duration-billed json responses report the duration only in `usage`:
5326
+ durationInSeconds: (_j = response.duration) != null ? _j : ((_h = response.usage) == null ? void 0 : _h.type) === "duration" ? (_i = response.usage.seconds) != null ? _i : void 0 : void 0,
5315
5327
  warnings,
5316
5328
  response: {
5317
5329
  timestamp: currentDate,
@@ -5324,7 +5336,7 @@ var OpenAITranscriptionModel = class {
5324
5336
  };
5325
5337
 
5326
5338
  // src/version.ts
5327
- var VERSION = true ? "2.0.136" : "0.0.0-test";
5339
+ var VERSION = true ? "2.0.138" : "0.0.0-test";
5328
5340
 
5329
5341
  // src/openai-provider.ts
5330
5342
  function createOpenAI(options = {}) {