@ai-sdk/openai 2.0.11 → 2.0.12

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.
@@ -1143,13 +1143,13 @@ var openaiChatChunkSchema = import_v45.z.union([
1143
1143
  openaiErrorDataSchema
1144
1144
  ]);
1145
1145
  function isReasoningModel(modelId) {
1146
- return modelId.startsWith("o") || modelId.startsWith("gpt-5");
1146
+ return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
1147
1147
  }
1148
1148
  function supportsFlexProcessing(modelId) {
1149
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5");
1149
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
1150
1150
  }
1151
1151
  function supportsPriorityProcessing(modelId) {
1152
- return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
1152
+ return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
1153
1153
  }
1154
1154
  function getSystemMessageMode(modelId) {
1155
1155
  var _a, _b;
@@ -1920,6 +1920,8 @@ var OpenAITranscriptionModel = class {
1920
1920
  include: openAIOptions.include,
1921
1921
  language: openAIOptions.language,
1922
1922
  prompt: openAIOptions.prompt,
1923
+ response_format: "verbose_json",
1924
+ // always use verbose_json to get segments
1923
1925
  temperature: openAIOptions.temperature,
1924
1926
  timestamp_granularities: openAIOptions.timestampGranularities
1925
1927
  };
@@ -1935,7 +1937,7 @@ var OpenAITranscriptionModel = class {
1935
1937
  };
1936
1938
  }
1937
1939
  async doGenerate(options) {
1938
- var _a, _b, _c, _d, _e, _f;
1940
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1939
1941
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
1940
1942
  const { formData, warnings } = await this.getArgs(options);
1941
1943
  const {
@@ -1959,13 +1961,17 @@ var OpenAITranscriptionModel = class {
1959
1961
  const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
1960
1962
  return {
1961
1963
  text: response.text,
1962
- segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
1964
+ segments: (_g = (_f = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
1965
+ text: segment.text,
1966
+ startSecond: segment.start,
1967
+ endSecond: segment.end
1968
+ }))) != null ? _f : (_e = response.words) == null ? void 0 : _e.map((word) => ({
1963
1969
  text: word.word,
1964
1970
  startSecond: word.start,
1965
1971
  endSecond: word.end
1966
- }))) != null ? _e : [],
1972
+ }))) != null ? _g : [],
1967
1973
  language,
1968
- durationInSeconds: (_f = response.duration) != null ? _f : void 0,
1974
+ durationInSeconds: (_h = response.duration) != null ? _h : void 0,
1969
1975
  warnings,
1970
1976
  response: {
1971
1977
  timestamp: currentDate,
@@ -1986,6 +1992,20 @@ var openaiTranscriptionResponseSchema = import_v412.z.object({
1986
1992
  start: import_v412.z.number(),
1987
1993
  end: import_v412.z.number()
1988
1994
  })
1995
+ ).nullish(),
1996
+ segments: import_v412.z.array(
1997
+ import_v412.z.object({
1998
+ id: import_v412.z.number(),
1999
+ seek: import_v412.z.number(),
2000
+ start: import_v412.z.number(),
2001
+ end: import_v412.z.number(),
2002
+ text: import_v412.z.string(),
2003
+ tokens: import_v412.z.array(import_v412.z.number()),
2004
+ temperature: import_v412.z.number(),
2005
+ avg_logprob: import_v412.z.number(),
2006
+ compression_ratio: import_v412.z.number(),
2007
+ no_speech_prob: import_v412.z.number()
2008
+ })
1989
2009
  ).nullish()
1990
2010
  });
1991
2011
 
@@ -3388,6 +3408,13 @@ function isErrorChunk(chunk) {
3388
3408
  return chunk.type === "error";
3389
3409
  }
3390
3410
  function getResponsesModelConfig(modelId) {
3411
+ if (modelId.startsWith("gpt-5-chat")) {
3412
+ return {
3413
+ isReasoningModel: false,
3414
+ systemMessageMode: "system",
3415
+ requiredAutoTruncation: false
3416
+ };
3417
+ }
3391
3418
  if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
3392
3419
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
3393
3420
  return {
@@ -3409,10 +3436,10 @@ function getResponsesModelConfig(modelId) {
3409
3436
  };
3410
3437
  }
3411
3438
  function supportsFlexProcessing2(modelId) {
3412
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5");
3439
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
3413
3440
  }
3414
3441
  function supportsPriorityProcessing2(modelId) {
3415
- return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
3442
+ return modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
3416
3443
  }
3417
3444
  var openaiResponsesProviderOptionsSchema = import_v416.z.object({
3418
3445
  metadata: import_v416.z.any().nullish(),