@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.
@@ -32,10 +32,15 @@ var openaiFailedResponseHandler = createJsonErrorResponseHandler({
32
32
 
33
33
  // src/openai-language-model-capabilities.ts
34
34
  function getOpenAILanguageModelCapabilities(modelId) {
35
- const supportsFlexProcessing = modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
36
- 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");
37
- const isReasoningModel = modelId.startsWith("o1") || modelId.startsWith("o3") || modelId.startsWith("o4-mini") || modelId.startsWith("gpt-5") && !modelId.startsWith("gpt-5-chat");
38
- 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");
35
+ var _a, _b, _c, _d, _e;
36
+ const oSeriesVersion = getOSeriesVersion(modelId);
37
+ const gptVersion = getGptVersion(modelId);
38
+ 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);
39
+ const isGptNanoModel = (_d = (_c = gptVersion == null ? void 0 : gptVersion.variant) == null ? void 0 : _c.startsWith("nano")) != null ? _d : false;
40
+ const supportsFlexProcessing = oSeriesVersion != null && oSeriesVersion >= 3 || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
41
+ const supportsPriorityProcessing = modelId.startsWith("gpt-4") || gptVersion != null && gptVersion.major >= 5 && !isGptNanoModel && !isGptChatModel || oSeriesVersion != null && oSeriesVersion >= 3;
42
+ const isReasoningModel = oSeriesVersion != null || gptVersion != null && gptVersion.major >= 5 && !isGptChatModel;
43
+ const supportsNonReasoningParameters = gptVersion != null && (gptVersion.major > 5 || gptVersion.major === 5 && ((_e = gptVersion.minor) != null ? _e : 0) >= 1);
39
44
  const systemMessageMode = isReasoningModel ? "developer" : "system";
40
45
  return {
41
46
  supportsFlexProcessing,
@@ -45,6 +50,21 @@ function getOpenAILanguageModelCapabilities(modelId) {
45
50
  supportsNonReasoningParameters
46
51
  };
47
52
  }
53
+ function getOSeriesVersion(modelId) {
54
+ const match = /^o(\d+)(?:-|$)/.exec(modelId);
55
+ return match == null ? void 0 : Number(match[1]);
56
+ }
57
+ function getGptVersion(modelId) {
58
+ const match = /^gpt-(\d+)(?:\.(\d+))?(?:-(.+))?$/.exec(modelId);
59
+ if (match == null) {
60
+ return void 0;
61
+ }
62
+ return {
63
+ major: Number(match[1]),
64
+ minor: match[2] == null ? void 0 : Number(match[2]),
65
+ variant: match[3]
66
+ };
67
+ }
48
68
 
49
69
  // src/openai-stream-error.ts
50
70
  import { APICallError } from "@ai-sdk/provider";
@@ -2011,18 +2031,16 @@ var modelMaxImagesPerCall = {
2011
2031
  "gpt-image-2": 10,
2012
2032
  "chatgpt-image-latest": 10
2013
2033
  };
2014
- var defaultResponseFormatPrefixes = [
2015
- "chatgpt-image-",
2016
- "gpt-image-1-mini",
2017
- "gpt-image-1.5",
2018
- "gpt-image-1",
2019
- "gpt-image-2"
2020
- ];
2034
+ var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
2021
2035
  function hasDefaultResponseFormat(modelId) {
2022
2036
  return defaultResponseFormatPrefixes.some(
2023
2037
  (prefix) => modelId.startsWith(prefix)
2024
2038
  );
2025
2039
  }
2040
+ function getMaxImagesPerCall(modelId) {
2041
+ var _a;
2042
+ return (_a = modelMaxImagesPerCall[modelId]) != null ? _a : modelId.startsWith("gpt-image-") ? 10 : 1;
2043
+ }
2026
2044
  var baseImageModelOptionsObject = z9.object({
2027
2045
  /**
2028
2046
  * Quality of the generated image(s).
@@ -2091,8 +2109,7 @@ var OpenAIImageModel = class {
2091
2109
  this.specificationVersion = "v3";
2092
2110
  }
2093
2111
  get maxImagesPerCall() {
2094
- var _a;
2095
- return (_a = modelMaxImagesPerCall[this.modelId]) != null ? _a : 1;
2112
+ return getMaxImagesPerCall(this.modelId);
2096
2113
  }
2097
2114
  get provider() {
2098
2115
  return this.config.provider;
@@ -2975,7 +2992,7 @@ async function convertToOpenAIResponsesInput({
2975
2992
  hasApplyPatchTool = false,
2976
2993
  customProviderToolNames
2977
2994
  }) {
2978
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w;
2995
+ 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;
2979
2996
  let input = [];
2980
2997
  const warnings = [];
2981
2998
  const processedApprovalIds = /* @__PURE__ */ new Set();
@@ -3252,7 +3269,7 @@ async function convertToOpenAIResponsesInput({
3252
3269
  part.toolName
3253
3270
  );
3254
3271
  if (resolvedResultToolName === "tool_search") {
3255
- const itemId = (_p = (_o = (_n = part.providerOptions) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.itemId) != null ? _p : part.toolCallId;
3272
+ 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;
3256
3273
  if (store) {
3257
3274
  input.push({ type: "item_reference", id: itemId });
3258
3275
  } else if (part.output.type === "json") {
@@ -3293,7 +3310,7 @@ async function convertToOpenAIResponsesInput({
3293
3310
  break;
3294
3311
  }
3295
3312
  if (store) {
3296
- const itemId = (_s = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.itemId) != null ? _s : part.toolCallId;
3313
+ const itemId = (_v = (_u = (_t = part.providerOptions) == null ? void 0 : _t[providerOptionsName]) == null ? void 0 : _u.itemId) != null ? _v : part.toolCallId;
3297
3314
  input.push({ type: "item_reference", id: itemId });
3298
3315
  } else {
3299
3316
  warnings.push({
@@ -3403,7 +3420,7 @@ async function convertToOpenAIResponsesInput({
3403
3420
  }
3404
3421
  const output = part.output;
3405
3422
  if (output.type === "execution-denied") {
3406
- const approvalId = (_u = (_t = output.providerOptions) == null ? void 0 : _t.openai) == null ? void 0 : _u.approvalId;
3423
+ const approvalId = (_x = (_w = output.providerOptions) == null ? void 0 : _w.openai) == null ? void 0 : _x.approvalId;
3407
3424
  if (approvalId) {
3408
3425
  continue;
3409
3426
  }
@@ -3477,7 +3494,7 @@ async function convertToOpenAIResponsesInput({
3477
3494
  outputValue = output.value;
3478
3495
  break;
3479
3496
  case "execution-denied":
3480
- outputValue = (_v = output.reason) != null ? _v : "Tool call execution denied.";
3497
+ outputValue = (_y = output.reason) != null ? _y : "Tool call execution denied.";
3481
3498
  break;
3482
3499
  case "json":
3483
3500
  case "error-json":
@@ -3560,7 +3577,7 @@ async function convertToOpenAIResponsesInput({
3560
3577
  contentValue = output.value;
3561
3578
  break;
3562
3579
  case "execution-denied":
3563
- contentValue = (_w = output.reason) != null ? _w : "Tool call execution denied.";
3580
+ contentValue = (_z = output.reason) != null ? _z : "Tool call execution denied.";
3564
3581
  break;
3565
3582
  case "json":
3566
3583
  case "error-json":
@@ -7345,6 +7362,7 @@ export {
7345
7362
  fileSearch,
7346
7363
  fileSearchArgsSchema,
7347
7364
  fileSearchOutputSchema,
7365
+ getMaxImagesPerCall,
7348
7366
  hasDefaultResponseFormat,
7349
7367
  imageGeneration,
7350
7368
  imageGenerationArgsSchema,