@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.
package/dist/index.mjs CHANGED
@@ -54,7 +54,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
54
54
  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);
55
55
  const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
56
56
  const isGpt6OrLaterModel = gptVersion != null && gptVersion.major >= 6;
57
- const isGpt6SolOrLuna = modelId === "gpt-6-sol" || modelId === "gpt-6-luna";
57
+ const isGpt6OrLaterModelWithNoneEffort = modelId === "gpt-6-sol" || modelId === "gpt-6-luna" || modelId === "gpt-6.1-terra";
58
58
  const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
59
59
  const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
60
60
  const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
@@ -65,7 +65,7 @@ function getOpenAILanguageModelCapabilities(modelId) {
65
65
  supportsPriorityProcessing,
66
66
  supportsConfigurationUpdate: isGpt6OrLaterModel,
67
67
  supportsAsyncToolCalling: isGpt6OrLaterModel,
68
- supportedReasoningEfforts: isGpt6SolOrLuna ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
68
+ supportedReasoningEfforts: isGpt6OrLaterModelWithNoneEffort ? ["none", "low", "medium", "high", "xhigh", "max"] : isGpt6OrLaterModel ? ["low", "medium", "high", "xhigh", "max"] : void 0,
69
69
  isReasoningModel,
70
70
  systemMessageMode,
71
71
  supportsNonReasoningParameters
@@ -3237,6 +3237,7 @@ var openaiResponsesReasoningModelIds = [
3237
3237
  "gpt-5.6-terra",
3238
3238
  "gpt-6-astra",
3239
3239
  "gpt-6.1-sol",
3240
+ "gpt-6.1-terra",
3240
3241
  "gpt-6-luna",
3241
3242
  "gpt-6-sol"
3242
3243
  ];
@@ -5597,9 +5598,10 @@ async function prepareResponsesTools({
5597
5598
  allowedTools,
5598
5599
  toolNameMapping,
5599
5600
  customProviderToolNames,
5600
- supportsAsyncToolCalling = true
5601
+ supportsAsyncToolCalling = true,
5602
+ providerOptionsName = "openai"
5601
5603
  }) {
5602
- var _a2, _b, _c, _d;
5604
+ var _a2, _b, _c, _d, _e, _f;
5603
5605
  tools = (tools == null ? void 0 : tools.length) ? tools : void 0;
5604
5606
  const toolWarnings = [];
5605
5607
  if (tools == null) {
@@ -5625,7 +5627,7 @@ async function prepareResponsesTools({
5625
5627
  for (const tool of tools) {
5626
5628
  switch (tool.type) {
5627
5629
  case "function": {
5628
- const openaiOptions = (_a2 = tool.providerOptions) == null ? void 0 : _a2.openai;
5630
+ const openaiOptions = (_c = (_a2 = tool.providerOptions) == null ? void 0 : _a2[providerOptionsName]) != null ? _c : (_b = tool.providerOptions) == null ? void 0 : _b.openai;
5629
5631
  const openaiFunctionTool = prepareFunctionTool({
5630
5632
  tool,
5631
5633
  options: openaiOptions,
@@ -5889,7 +5891,7 @@ async function prepareResponsesTools({
5889
5891
  });
5890
5892
  allowedToolEntries.push({
5891
5893
  type: "function",
5892
- name: (_b = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _b : name
5894
+ name: (_d = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(name)) != null ? _d : name
5893
5895
  });
5894
5896
  continue;
5895
5897
  }
@@ -5915,7 +5917,7 @@ async function prepareResponsesTools({
5915
5917
  tools: openaiTools2,
5916
5918
  toolChoice: {
5917
5919
  type: "allowed_tools",
5918
- mode: (_c = allowedTools.mode) != null ? _c : "auto",
5920
+ mode: (_e = allowedTools.mode) != null ? _e : "auto",
5919
5921
  tools: allowedToolEntries
5920
5922
  },
5921
5923
  toolWarnings
@@ -5931,7 +5933,7 @@ async function prepareResponsesTools({
5931
5933
  case "required":
5932
5934
  return { tools: openaiTools2, toolChoice: type, toolWarnings };
5933
5935
  case "tool": {
5934
- const resolvedToolName = (_d = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _d : toolChoice.toolName;
5936
+ const resolvedToolName = (_f = toolNameMapping == null ? void 0 : toolNameMapping.toProviderToolName(toolChoice.toolName)) != null ? _f : toolChoice.toolName;
5935
5937
  return {
5936
5938
  tools: openaiTools2,
5937
5939
  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 },
@@ -6203,7 +6205,8 @@ var OpenAIResponsesLanguageModel = class {
6203
6205
  allowedTools: (_b = openaiOptions == null ? void 0 : openaiOptions.allowedTools) != null ? _b : void 0,
6204
6206
  toolNameMapping,
6205
6207
  customProviderToolNames,
6206
- supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling
6208
+ supportsAsyncToolCalling: modelCapabilities.supportsAsyncToolCalling,
6209
+ providerOptionsName
6207
6210
  });
6208
6211
  const configurationUpdateUnsupportedReason = getConfigurationUpdateUnsupportedReason({
6209
6212
  modelCapabilities,
@@ -8250,7 +8253,12 @@ var openaiTranscriptionResponseSchema = lazySchema25(
8250
8253
  compression_ratio: z25.number(),
8251
8254
  no_speech_prob: z25.number()
8252
8255
  })
8253
- ).nullish()
8256
+ ).nullish(),
8257
+ // Lenient: an unexpected usage shape must not fail the transcription.
8258
+ usage: z25.object({
8259
+ type: z25.string().nullish(),
8260
+ seconds: z25.number().nullish()
8261
+ }).nullish().catch(void 0)
8254
8262
  })
8255
8263
  )
8256
8264
  );
@@ -8386,10 +8394,10 @@ var OpenAITranscriptionModel = class {
8386
8394
  prompt: openAIOptions.prompt,
8387
8395
  // https://platform.openai.com/docs/api-reference/audio/createTranscription#audio_createtranscription-response_format
8388
8396
  // prefer verbose_json to get segments for models that support it
8389
- response_format: [
8390
- "gpt-4o-transcribe",
8391
- "gpt-4o-mini-transcribe"
8392
- ].includes(this.modelId) ? "json" : "verbose_json",
8397
+ // gpt-4o(-mini)-transcribe (incl. snapshots) and gpt-transcribe reject verbose_json:
8398
+ response_format: ["gpt-4o-transcribe", "gpt-4o-mini-transcribe"].includes(
8399
+ this.modelId
8400
+ ) || this.modelId.startsWith("gpt-4o-mini-transcribe-") || this.modelId === "gpt-transcribe" || this.modelId.startsWith("gpt-transcribe-") ? "json" : "verbose_json",
8393
8401
  temperature: openAIOptions.temperature,
8394
8402
  timestamp_granularities: openAIOptions.timestampGranularities
8395
8403
  };
@@ -8411,7 +8419,7 @@ var OpenAITranscriptionModel = class {
8411
8419
  };
8412
8420
  }
8413
8421
  async doGenerate(options) {
8414
- var _a2, _b, _c, _d, _e, _f, _g, _h;
8422
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
8415
8423
  const currentDate = (_c = (_b = (_a2 = this.config._internal) == null ? void 0 : _a2.currentDate) == null ? void 0 : _b.call(_a2)) != null ? _c : /* @__PURE__ */ new Date();
8416
8424
  const { formData, warnings } = await this.getArgs(options);
8417
8425
  const {
@@ -8445,7 +8453,8 @@ var OpenAITranscriptionModel = class {
8445
8453
  endSecond: word.end
8446
8454
  }))) != null ? _g : [],
8447
8455
  language,
8448
- durationInSeconds: (_h = response.duration) != null ? _h : void 0,
8456
+ // Duration-billed json responses report the duration only in `usage`:
8457
+ 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,
8449
8458
  warnings,
8450
8459
  response: {
8451
8460
  timestamp: currentDate,
@@ -8458,7 +8467,7 @@ var OpenAITranscriptionModel = class {
8458
8467
  };
8459
8468
 
8460
8469
  // src/version.ts
8461
- var VERSION = true ? "3.0.131" : "0.0.0-test";
8470
+ var VERSION = true ? "3.0.133" : "0.0.0-test";
8462
8471
 
8463
8472
  // src/openai-provider.ts
8464
8473
  function createOpenAI(options = {}) {