@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.
package/dist/index.mjs CHANGED
@@ -1125,13 +1125,13 @@ var openaiChatChunkSchema = z5.union([
1125
1125
  openaiErrorDataSchema
1126
1126
  ]);
1127
1127
  function isReasoningModel(modelId) {
1128
- return modelId.startsWith("o") || modelId.startsWith("gpt-5");
1128
+ return (modelId.startsWith("o") || modelId.startsWith("gpt-5")) && !modelId.startsWith("gpt-5-chat");
1129
1129
  }
1130
1130
  function supportsFlexProcessing(modelId) {
1131
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5");
1131
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
1132
1132
  }
1133
1133
  function supportsPriorityProcessing(modelId) {
1134
- 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");
1134
+ 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");
1135
1135
  }
1136
1136
  function getSystemMessageMode(modelId) {
1137
1137
  var _a, _b;
@@ -3112,6 +3112,13 @@ function isErrorChunk(chunk) {
3112
3112
  return chunk.type === "error";
3113
3113
  }
3114
3114
  function getResponsesModelConfig(modelId) {
3115
+ if (modelId.startsWith("gpt-5-chat")) {
3116
+ return {
3117
+ isReasoningModel: false,
3118
+ systemMessageMode: "system",
3119
+ requiredAutoTruncation: false
3120
+ };
3121
+ }
3115
3122
  if (modelId.startsWith("o") || modelId.startsWith("gpt-5") || modelId.startsWith("codex-") || modelId.startsWith("computer-use")) {
3116
3123
  if (modelId.startsWith("o1-mini") || modelId.startsWith("o1-preview")) {
3117
3124
  return {
@@ -3133,10 +3140,10 @@ function getResponsesModelConfig(modelId) {
3133
3140
  };
3134
3141
  }
3135
3142
  function supportsFlexProcessing2(modelId) {
3136
- return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5");
3143
+ return modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
3137
3144
  }
3138
3145
  function supportsPriorityProcessing2(modelId) {
3139
- 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");
3146
+ 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");
3140
3147
  }
3141
3148
  var openaiResponsesProviderOptionsSchema = z13.object({
3142
3149
  metadata: z13.any().nullish(),
@@ -3393,6 +3400,8 @@ var OpenAITranscriptionModel = class {
3393
3400
  include: openAIOptions.include,
3394
3401
  language: openAIOptions.language,
3395
3402
  prompt: openAIOptions.prompt,
3403
+ response_format: "verbose_json",
3404
+ // always use verbose_json to get segments
3396
3405
  temperature: openAIOptions.temperature,
3397
3406
  timestamp_granularities: openAIOptions.timestampGranularities
3398
3407
  };
@@ -3408,7 +3417,7 @@ var OpenAITranscriptionModel = class {
3408
3417
  };
3409
3418
  }
3410
3419
  async doGenerate(options) {
3411
- var _a, _b, _c, _d, _e, _f;
3420
+ var _a, _b, _c, _d, _e, _f, _g, _h;
3412
3421
  const currentDate = (_c = (_b = (_a = this.config._internal) == null ? void 0 : _a.currentDate) == null ? void 0 : _b.call(_a)) != null ? _c : /* @__PURE__ */ new Date();
3413
3422
  const { formData, warnings } = await this.getArgs(options);
3414
3423
  const {
@@ -3432,13 +3441,17 @@ var OpenAITranscriptionModel = class {
3432
3441
  const language = response.language != null && response.language in languageMap ? languageMap[response.language] : void 0;
3433
3442
  return {
3434
3443
  text: response.text,
3435
- segments: (_e = (_d = response.words) == null ? void 0 : _d.map((word) => ({
3444
+ segments: (_g = (_f = (_d = response.segments) == null ? void 0 : _d.map((segment) => ({
3445
+ text: segment.text,
3446
+ startSecond: segment.start,
3447
+ endSecond: segment.end
3448
+ }))) != null ? _f : (_e = response.words) == null ? void 0 : _e.map((word) => ({
3436
3449
  text: word.word,
3437
3450
  startSecond: word.start,
3438
3451
  endSecond: word.end
3439
- }))) != null ? _e : [],
3452
+ }))) != null ? _g : [],
3440
3453
  language,
3441
- durationInSeconds: (_f = response.duration) != null ? _f : void 0,
3454
+ durationInSeconds: (_h = response.duration) != null ? _h : void 0,
3442
3455
  warnings,
3443
3456
  response: {
3444
3457
  timestamp: currentDate,
@@ -3459,6 +3472,20 @@ var openaiTranscriptionResponseSchema = z16.object({
3459
3472
  start: z16.number(),
3460
3473
  end: z16.number()
3461
3474
  })
3475
+ ).nullish(),
3476
+ segments: z16.array(
3477
+ z16.object({
3478
+ id: z16.number(),
3479
+ seek: z16.number(),
3480
+ start: z16.number(),
3481
+ end: z16.number(),
3482
+ text: z16.string(),
3483
+ tokens: z16.array(z16.number()),
3484
+ temperature: z16.number(),
3485
+ avg_logprob: z16.number(),
3486
+ compression_ratio: z16.number(),
3487
+ no_speech_prob: z16.number()
3488
+ })
3462
3489
  ).nullish()
3463
3490
  });
3464
3491