@ai-sdk/openai 2.0.136 → 2.0.137

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.
@@ -2000,7 +2000,12 @@ var openaiTranscriptionResponseSchema = (0, import_provider_utils15.lazyValidato
2000
2000
  compression_ratio: import_v410.z.number(),
2001
2001
  no_speech_prob: import_v410.z.number()
2002
2002
  })
2003
- ).nullish()
2003
+ ).nullish(),
2004
+ // Lenient: an unexpected usage shape must not fail the transcription.
2005
+ usage: import_v410.z.object({
2006
+ type: import_v410.z.string().nullish(),
2007
+ seconds: import_v410.z.number().nullish()
2008
+ }).nullish().catch(void 0)
2004
2009
  })
2005
2010
  )
2006
2011
  );
@@ -2133,10 +2138,10 @@ var OpenAITranscriptionModel = class {
2133
2138
  prompt: openAIOptions.prompt,
2134
2139
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
2135
2140
  // prefer verbose_json to get segments for models that support it
2136
- response_format: [
2137
- "gpt-4o-transcribe",
2138
- "gpt-4o-mini-transcribe"
2139
- ].includes(this.modelId) ? "json" : "verbose_json",
2141
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
2142
+ response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
2143
+ this.modelId
2144
+ ) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
2140
2145
  temperature: openAIOptions.temperature,
2141
2146
  timestamp_granularities: openAIOptions.timestampGranularities
2142
2147
  };
@@ -2158,7 +2163,7 @@ var OpenAITranscriptionModel = class {
2158
2163
  };
2159
2164
  }
2160
2165
  async doGenerate(options) {
2161
- var _a2, _b, _c, _d, _e, _f, _g, _h;
2166
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2162
2167
  const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
2163
2168
  const { formData, warnings } = await this.getArgs(options);
2164
2169
  const {
@@ -2192,7 +2197,8 @@ var OpenAITranscriptionModel = class {
2192
2197
  endSecond: word.end
2193
2198
  }))) != null ? _g : [],
2194
2199
  language,
2195
- durationInSeconds: (_h = response.duration) != null ? _h : void 0,
2200
+ // Duration-billed json responses report the duration only in `usage`:
2201
+ 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,
2196
2202
  warnings,
2197
2203
  response: {
2198
2204
  timestamp: currentDate,