@ai-sdk/openai 3.0.86 → 3.0.88

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/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 3.0.88
4
+
5
+ ### Patch Changes
6
+
7
+ - 8100830: Apply reasoning, service tier, and image defaults to recognizable future OpenAI model family versions.
8
+
9
+ ## 3.0.87
10
+
11
+ ### Patch Changes
12
+
13
+ - 2f11af1: Preserve stored tool search output item IDs from provider metadata.
14
+
3
15
  ## 3.0.86
4
16
 
5
17
  ### Patch Changes
package/dist/index.js CHANGED
@@ -54,10 +54,15 @@ var openaiFailedResponseHandler = (0, import_provider_utils.createJsonErrorRespo
54
54
 
55
55
  // src/openai-language-model-capabilities.ts
56
56
  function getOpenAILanguageModelCapabilities(modelId) {
57
- const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
58
- const supportsPriorityProcessing = modelId.startsWith("gpt-4") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-nano") && !modelId.startsWith("gpt-5-chat") && !modelId.startsWith("gpt-5.4-nano") || modelId.startsWith("o3") || modelId.startsWith("o4-mini");
59
- const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
60
- const supportsNonReasoningParameters = modelId.startsWith("gpt-5.1") || modelId.startsWith("gpt-5.2") || modelId.startsWith("gpt-5.3") || modelId.startsWith("gpt-5.4") || modelId.startsWith("gpt-5.5") || modelId.startsWith("gpt-5.6");
57
+ var _a, _b, _c, _d, _e;
58
+ const oSeriesVersion = getOSeriesVersion(modelId);
59
+ const gptVersion = getGptVersion(modelId);
60
+ const isGptChatModel = (gptVersion == null ? void 0 : gptVersion.minor) == null && ((_b = (_a = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _a.startsWith("chat")) != null ? _b : false);
61
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
62
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
63
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
64
+ const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
65
+ const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
61
66
  const systemMessageMode = isReasoningModel ? "developer" : "system";
62
67
  return {
63
68
  supportsFlexProcessing,
@@ -67,6 +72,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
67
72
  supportsNonReasoningParameters
68
73
  };
69
74
  }
75
+ function getOSeriesVersion(modelId) {
76
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
77
+ return match == null ? void 0 : Number(match[1]);
78
+ }
79
+ function getGptVersion(modelId) {
80
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
81
+ if (match == null) {
82
+ return void 0;
83
+ }
84
+ return {
85
+ major: Number(match[1]),
86
+ minor: match[2] == null ? void 0 : Number(match[2]),
87
+ variant: match[3]
88
+ };
89
+ }
70
90
 
71
91
  // src/openai-stream-error.ts
72
92
  var import_provider = require("@ai-sdk/provider");
@@ -1986,18 +2006,16 @@ var modelMaxImagesPerCall = {
1986
2006
  "gpt-image-2": 10,
1987
2007
  "chatgpt-image-latest": 10
1988
2008
  };
1989
- var defaultResponseFormatPrefixes = [
1990
- "chatgpt-image-",
1991
- "gpt-image-1-mini",
1992
- "gpt-image-1.5",
1993
- "gpt-image-1",
1994
- "gpt-image-2"
1995
- ];
2009
+ var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
1996
2010
  function hasDefaultResponseFormat(modelId) {
1997
2011
  return defaultResponseFormatPrefixes.some(
1998
2012
  (prefix) => modelId.startsWith(prefix)
1999
2013
  );
2000
2014
  }
2015
+ function getMaxImagesPerCall(modelId) {
2016
+ var _a;
2017
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
2018
+ }
2001
2019
  var baseImageModelOptionsObject = import_v49.z.object({
2002
2020
  /**
2003
2021
  * Quality of the generated image(s).
@@ -2066,8 +2084,7 @@ var OpenAIImageModel = class {
2066
2084
  this.specificationVersion = "v3";
2067
2085
  }
2068
2086
  get maxImagesPerCall() {
2069
- var _a;
2070
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
2087
+ return getMaxImagesPerCall(this.modelId);
2071
2088
  }
2072
2089
  get provider() {
2073
2090
  return this.config.provider;
@@ -2984,7 +3001,7 @@ async function convertToOpenAIResponsesInput({
2984
3001
  hasApplyPatchTool = false,
2985
3002
  customProviderToolNames
2986
3003
  }) {
2987
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
3004
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
2988
3005
  let input = [];
2989
3006
  const warnings = [];
2990
3007
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3261,7 +3278,7 @@ async function convertToOpenAIResponsesInput({
3261
3278
  part.toolName
3262
3279
  );
3263
3280
  if (resolvedResultToolName === "tool_search") {
3264
- const itemId = (_p = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _p : part.toolCallId;
3281
+ const itemId = (_s = (_r = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _r : (_q = (_p = part.providerMetadata) == null ? void 0 : _p[providerOptionsName]) == null ? void 0 : _q.itemId) != null ? _s : part.toolCallId;
3265
3282
  if (store) {
3266
3283
  input.push({ type: "item_reference", id: itemId });
3267
3284
  } else if (part.output.type === "json") {
@@ -3302,7 +3319,7 @@ async function convertToOpenAIResponsesInput({
3302
3319
  break;
3303
3320
  }
3304
3321
  if (store) {
3305
- const itemId = (_s = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.itemId) != null ? _s : part.toolCallId;
3322
+ const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
3306
3323
  input.push({ type: "item_reference", id: itemId });
3307
3324
  } else {
3308
3325
  warnings.push({
@@ -3412,7 +3429,7 @@ async function convertToOpenAIResponsesInput({
3412
3429
  }
3413
3430
  const output = part.output;
3414
3431
  if (output.type === "execution-denied") {
3415
- const approvalId = (_u = (_t = output.providerOptions) == null ? void 0 : _t.openai) == null ? void 0 : _u.approvalId;
3432
+ const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
3416
3433
  if (approvalId) {
3417
3434
  continue;
3418
3435
  }
@@ -3486,7 +3503,7 @@ async function convertToOpenAIResponsesInput({
3486
3503
  outputValue = output.value;
3487
3504
  break;
3488
3505
  case "execution-denied":
3489
- outputValue = (_v = output.reason) != null ? _v : "Tool call execution denied.";
3506
+ outputValue = (_y = output.reason) != null ? _y : "Tool call execution denied.";
3490
3507
  break;
3491
3508
  case "json":
3492
3509
  case "error-json":
@@ -3569,7 +3586,7 @@ async function convertToOpenAIResponsesInput({
3569
3586
  contentValue = output.value;
3570
3587
  break;
3571
3588
  case "execution-denied":
3572
- contentValue = (_w = output.reason) != null ? _w : "Tool call execution denied.";
3589
+ contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
3573
3590
  break;
3574
3591
  case "json":
3575
3592
  case "error-json":
@@ -7330,7 +7347,7 @@ var OpenAITranscriptionModel = class {
7330
7347
  };
7331
7348
 
7332
7349
  // src/version.ts
7333
- var VERSION = true ? "3.0.86" : "0.0.0-test";
7350
+ var VERSION = true ? "3.0.88" : "0.0.0-test";
7334
7351
 
7335
7352
  // src/openai-provider.ts
7336
7353
  function createOpenAI(options = {}) {