@ai-sdk/openai 3.0.131 → 3.0.133

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
  ];
@@ -3376,6 +3383,7 @@ var toolSearchToolFactory = createProviderToolFactoryWithOutputSchema4({
3376
3383
  inputSchema: toolSearchInputSchema,
3377
3384
  outputSchema: toolSearchOutputSchema
3378
3385
  });
3386
+ var toolSearch = (args = {}) => toolSearchToolFactory(args);
3379
3387
 
3380
3388
  // src/tool/web-search.ts
3381
3389
  import {
@@ -5839,9 +5847,10 @@ async function prepareResponsesTools({
5839
5847
  allowedTools,
5840
5848
  toolNameMapping,
5841
5849
  customProviderToolNames,
5842
- supportsAsyncToolCalling = true
5850
+ supportsAsyncToolCalling = true,
5851
+ providerOptionsName = "openai"
5843
5852
  }) {
5844
- var _a2, _b, _c, _d;
5853
+ var _a2, _b, _c, _d, _e, _f;
5845
5854
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
5846
5855
  const toolWarnings = [];
5847
5856
  if (tools == null) {
@@ -5867,7 +5876,7 @@ async function prepareResponsesTools({
5867
5876
  for (const tool of tools) {
5868
5877
  switch (tool.type) {
5869
5878
  case "function": {
5870
- const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5879
+ const openaiOptions = (_c = (_a2 = tool.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _c : (_b = tool.providerOptions) == null ? void 0 : _b.openai;
5871
5880
  const openaiFunctionTool = prepareFunctionTool({
5872
5881
  tool,
5873
5882
  options: openaiOptions,
@@ -6131,7 +6140,7 @@ async function prepareResponsesTools({
6131
6140
  });
6132
6141
  allowedToolEntries.push({
6133
6142
  type: "function",
6134
- name: (_b = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _b : name
6143
+ name: (_d = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _d : name
6135
6144
  });
6136
6145
  continue;
6137
6146
  }
@@ -6157,7 +6166,7 @@ async function prepareResponsesTools({
6157
6166
  tools: openaiTools,
6158
6167
  toolChoice: {
6159
6168
  type: "allowed_tools",
6160
- mode: (_c = allowedTools.mode) != null ? _c : "auto",
6169
+ mode: (_e = allowedTools.mode) != null ? _e : "auto",
6161
6170
  tools: allowedToolEntries
6162
6171
  },
6163
6172
  toolWarnings
@@ -6173,7 +6182,7 @@ async function prepareResponsesTools({
6173
6182
  case "required":
6174
6183
  return { tools: openaiTools, toolChoice: type, toolWarnings };
6175
6184
  case "tool": {
6176
- const resolvedToolName = (_d = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _d : toolChoice.toolName;
6185
+ const resolvedToolName = (_f = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _f : toolChoice.toolName;
6177
6186
  return {
6178
6187
  tools: openaiTools,
6179
6188
  toolChoice: resolvedToolName === "code_interpreter" || resolvedToolName === "file_search" || resolvedToolName === "image_generation" || resolvedToolName === "web_search_preview" || resolvedToolName === "web_search" || resolvedToolName === "mcp" || resolvedToolName === "apply_patch" ? { type: resolvedToolName } : resolvedCustomProviderToolNames.has(resolvedToolName) ? { type: "custom", name: resolvedToolName } : { type: "function", name: resolvedToolName },
@@ -6445,7 +6454,8 @@ var OpenAIResponsesLanguageModel = class {
6445
6454
  allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
6446
6455
  toolNameMapping,
6447
6456
  customProviderToolNames,
6448
- supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
6457
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
6458
+ providerOptionsName
6449
6459
  });
6450
6460
  const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
6451
6461
  modelCapabilities,
@@ -8363,6 +8373,10 @@ export {
8363
8373
  openaiLanguageModelChatOptions,
8364
8374
  openaiLanguageModelCompletionOptions,
8365
8375
  openaiSpeechModelOptionsSchema,
8376
+ toolSearch,
8377
+ toolSearchArgsSchema,
8378
+ toolSearchInputSchema,
8379
+ toolSearchOutputSchema,
8366
8380
  webSearch,
8367
8381
  webSearchArgsSchema,
8368
8382
  webSearchOutputSchema,