@ai-sdk/openai 3.0.132 → 3.0.134

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.
@@ -46,7 +46,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
46
46
  const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a2 = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a2.startsWith("chat")) != null ? _b : false);
47
47
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
48
48
  const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
49
- const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
49
+ const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
50
50
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
51
51
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
52
52
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
@@ -57,7 +57,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
57
57
  supportsPriorityProcessing,
58
58
  supportsConfigurationUpdate: isGpt6OrLaterModel,
59
59
  supportsAsyncToolCalling: isGpt6OrLaterModel,
60
- supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
60
+ supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
61
61
  isReasoningModel,
62
62
  systemMessageMode,
63
63
  supportsNonReasoningParameters
@@ -2456,7 +2456,12 @@ var openaiTranscriptionResponseSchema = lazySchema10(
2456
2456
  compression_ratio: z10.number(),
2457
2457
  no_speech_prob: z10.number()
2458
2458
  })
2459
- ).nullish()
2459
+ ).nullish(),
2460
+ // Lenient: an unexpected usage shape must not fail the transcription.
2461
+ usage: z10.object({
2462
+ type: z10.string().nullish(),
2463
+ seconds: z10.number().nullish()
2464
+ }).nullish().catch(void 0)
2460
2465
  })
2461
2466
  )
2462
2467
  );
@@ -2592,10 +2597,10 @@ var OpenAITranscriptionModel = class {
2592
2597
  prompt: openAIOptions.prompt,
2593
2598
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
2594
2599
  // prefer verbose_json to get segments for models that support it
2595
- response_format: [
2596
- "gpt-4o-transcribe",
2597
- "gpt-4o-mini-transcribe"
2598
- ].includes(this.modelId) ? "json" : "verbose_json",
2600
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
2601
+ response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
2602
+ this.modelId
2603
+ ) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
2599
2604
  temperature: openAIOptions.temperature,
2600
2605
  timestamp_granularities: openAIOptions.timestampGranularities
2601
2606
  };
@@ -2617,7 +2622,7 @@ var OpenAITranscriptionModel = class {
2617
2622
  };
2618
2623
  }
2619
2624
  async doGenerate(options) {
2620
- var _a2, _b, _c, _d, _e, _f, _g, _h;
2625
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
2621
2626
  const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
2622
2627
  const { formData, warnings } = await this.getArgs(options);
2623
2628
  const {
@@ -2651,7 +2656,8 @@ var OpenAITranscriptionModel = class {
2651
2656
  endSecond: word.end
2652
2657
  }))) != null ? _g : [],
2653
2658
  language,
2654
- durationInSeconds: (_h = response.duration) != null ? _h : void 0,
2659
+ // Duration-billed json responses report the duration only in `usage`:
2660
+ 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,
2655
2661
  warnings,
2656
2662
  response: {
2657
2663
  timestamp: currentDate,
@@ -2910,6 +2916,7 @@ var openaiResponsesReasoningModelIds = [
2910
2916
  "gpt-5.6-terra",
2911
2917
  "gpt-6-astra",
2912
2918
  "gpt-6.1-sol",
2919
+ "gpt-6.1-terra",
2913
2920
  "gpt-6-luna",
2914
2921
  "gpt-6-sol"
2915
2922
  ];
@@ -7014,7 +7021,7 @@ var OpenAIResponsesLanguageModel = class {
7014
7021
  toolName: toolNameMapping.toCustomToolName(
7015
7022
  webSearchToolName != null ? webSearchToolName : "web_search"
7016
7023
  ),
7017
- result: mapWebSearchOutput(part.action)
7024
+ ...mapWebSearchResult(part)
7018
7025
  });
7019
7026
  break;
7020
7027
  }
@@ -7618,7 +7625,7 @@ var OpenAIResponsesLanguageModel = class {
7618
7625
  toolName: toolNameMapping.toCustomToolName(
7619
7626
  webSearchToolName != null ? webSearchToolName : "web_search"
7620
7627
  ),
7621
- result: mapWebSearchOutput(value.item.action)
7628
+ ...mapWebSearchResult(value.item)
7622
7629
  });
7623
7630
  } else if (value.item.type === "computer_call") {
7624
7631
  ongoingToolCalls[value.output_index] = void 0;
@@ -8300,6 +8307,12 @@ function isErrorChunk(chunk) {
8300
8307
  function isResponseOutputChunk(chunk) {
8301
8308
  return !(chunk.type === "response.created" || chunk.type === "response.failed" || chunk.type === "error" || chunk.type === "unknown_chunk");
8302
8309
  }
8310
+ function mapWebSearchResult({
8311
+ action,
8312
+ status
8313
+ }) {
8314
+ return status === "completed" ? { result: mapWebSearchOutput(action) } : { isError: true, result: { status } };
8315
+ }
8303
8316
  function mapWebSearchOutput(action) {
8304
8317
  var _a2;
8305
8318
  if (action == null) {
@@ -8357,6 +8370,7 @@ export {
8357
8370
  imageGeneration,
8358
8371
  imageGenerationArgsSchema,
8359
8372
  imageGenerationOutputSchema,
8373
+ mapWebSearchResult,
8360
8374
  modelMaxImagesPerCall,
8361
8375
  openAITranscriptionModelOptions,
8362
8376
  openaiEmbeddingModelOptions,