@ai-sdk/openai 4.0.61 → 4.0.63

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,20 @@
1
1
  # @ai-sdk/openai
2
2
 
3
+ ## 4.0.63
4
+
5
+ ### Patch Changes
6
+
7
+ - 85db433: Include explicit message item types in Azure AI Foundry Responses requests.
8
+ - 5fb2a64: feat(openai): add GPT Image 2.5 Flare and Sunburst model IDs
9
+ - e105b2b: fix(openai): reject denied programmatic tool calls
10
+ - 45f2b6a: fix(openai): report apply patch responses with a tool-calls finish reason
11
+
12
+ ## 4.0.62
13
+
14
+ ### Patch Changes
15
+
16
+ - 8487955: Add `xhigh` and `max` quality support for GPT Image 2.5 Flare and Sunburst in image generation, image editing, and the Responses API image generation tool.
17
+
3
18
  ## 4.0.61
4
19
 
5
20
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -47,9 +47,9 @@ declare const openaiEmbeddingModelOptions: _ai_sdk_provider_utils.LazySchema<{
47
47
  }>;
48
48
  type OpenAIEmbeddingModelOptions = InferSchema<typeof openaiEmbeddingModelOptions>;
49
49
 
50
- type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'chatgpt-image-latest' | (string & {});
50
+ type OpenAIImageModelId = 'dall-e-3' | 'dall-e-2' | 'gpt-image-1' | 'gpt-image-1-mini' | 'gpt-image-1.5' | 'gpt-image-2' | 'gpt-image-2.5-flare' | 'gpt-image-2.5-flare-2026-09-08' | 'gpt-image-2.5-sunburst' | 'gpt-image-2.5-sunburst-2026-09-08' | 'chatgpt-image-latest' | (string & {});
51
51
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
52
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
52
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
53
53
  background?: "auto" | "transparent" | "opaque" | undefined;
54
54
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
55
55
  outputCompression?: number | undefined;
@@ -57,7 +57,7 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
57
57
  }>;
58
58
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
59
59
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
60
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
60
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
61
61
  background?: "auto" | "transparent" | "opaque" | undefined;
62
62
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
63
63
  outputCompression?: number | undefined;
@@ -67,7 +67,7 @@ declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySche
67
67
  }>;
68
68
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
69
69
  declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
70
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
70
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
71
71
  background?: "auto" | "transparent" | "opaque" | undefined;
72
72
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
73
73
  outputCompression?: number | undefined;
@@ -1134,7 +1134,7 @@ declare const openaiTools: {
1134
1134
  * @param outputCompression - Compression level for the output image (0-100).
1135
1135
  * @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
1136
1136
  * @param partialImages - Number of partial images to generate in streaming mode (0-3).
1137
- * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
1137
+ * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', 'high', 'xhigh', or 'max'. 'xhigh' and 'max' require a GPT Image 2.5 model.
1138
1138
  * @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
1139
1139
  */
1140
1140
  imageGeneration: (args?: {
@@ -1150,7 +1150,7 @@ declare const openaiTools: {
1150
1150
  outputCompression?: number;
1151
1151
  outputFormat?: "png" | "jpeg" | "webp";
1152
1152
  partialImages?: number;
1153
- quality?: "auto" | "low" | "medium" | "high";
1153
+ quality?: "auto" | "low" | "medium" | "high" | "xhigh" | "max";
1154
1154
  size?: "auto" | "1024x1024" | "1024x1536" | "1536x1024" | (string & {});
1155
1155
  }) => _ai_sdk_provider_utils.ProviderExecutedTool<{}, {
1156
1156
  result: string;
@@ -1629,6 +1629,13 @@ type OpenAIConfig = {
1629
1629
  fetch?: FetchFunction;
1630
1630
  webSocket?: WebSocketConstructor;
1631
1631
  generateId?: () => string;
1632
+ /**
1633
+ * Whether Responses API message input items must include an explicit
1634
+ * `type: 'message'` discriminator.
1635
+ *
1636
+ * @see https://github.com/vercel/ai/issues/20180
1637
+ */
1638
+ explicitMessageItemType?: boolean;
1632
1639
  /**
1633
1640
  * This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
1634
1641
  * in file part data instead. File ID prefixes used to identify file IDs
package/dist/index.js CHANGED
@@ -2401,6 +2401,10 @@ var modelMaxImagesPerCall = {
2401
2401
  "gpt-image-1-mini": 10,
2402
2402
  "gpt-image-1.5": 10,
2403
2403
  "gpt-image-2": 10,
2404
+ "gpt-image-2.5-flare": 10,
2405
+ "gpt-image-2.5-flare-2026-09-08": 10,
2406
+ "gpt-image-2.5-sunburst": 10,
2407
+ "gpt-image-2.5-sunburst-2026-09-08": 10,
2404
2408
  "chatgpt-image-latest": 10
2405
2409
  };
2406
2410
  var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
@@ -2417,9 +2421,10 @@ var baseImageModelOptionsObject = z11.object({
2417
2421
  /**
2418
2422
  * Quality of the generated image(s).
2419
2423
  *
2420
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2424
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2425
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2421
2426
  */
2422
- quality: z11.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2427
+ quality: z11.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2423
2428
  /**
2424
2429
  * Background behavior for the generated image(s).
2425
2430
  *
@@ -2993,7 +2998,7 @@ var imageGenerationArgsSchema = lazySchema16(
2993
2998
  outputCompression: z17.number().int().min(0).max(100).optional(),
2994
2999
  outputFormat: z17.enum(["png", "jpeg", "webp"]).optional(),
2995
3000
  partialImages: z17.number().int().min(0).max(3).optional(),
2996
- quality: z17.enum(["auto", "low", "medium", "high"]).optional(),
3001
+ quality: z17.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
2997
3002
  size: z17.union([
2998
3003
  z17.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
2999
3004
  z17.string().regex(/^\d+x\d+$/)
@@ -3474,7 +3479,7 @@ var openaiTools = {
3474
3479
  * @param outputCompression - Compression level for the output image (0-100).
3475
3480
  * @param outputFormat - The output format of the generated image. One of 'png', 'jpeg', or 'webp'.
3476
3481
  * @param partialImages - Number of partial images to generate in streaming mode (0-3).
3477
- * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', or 'high'.
3482
+ * @param quality - The quality of the generated image. One of 'auto', 'low', 'medium', 'high', 'xhigh', or 'max'. 'xhigh' and 'max' require a GPT Image 2.5 model.
3478
3483
  * @param size - The size of the generated image. One of 'auto', '1024x1024', '1024x1536', or '1536x1024'.
3479
3484
  */
3480
3485
  imageGeneration,
@@ -4998,6 +5003,7 @@ async function convertToOpenAIResponsesInput({
4998
5003
  toolNameMapping,
4999
5004
  systemMessageMode,
5000
5005
  providerOptionsName,
5006
+ explicitMessageItemType = false,
5001
5007
  fileIdPrefixes,
5002
5008
  passThroughUnsupportedFiles = false,
5003
5009
  store,
@@ -5015,6 +5021,7 @@ async function convertToOpenAIResponsesInput({
5015
5021
  let input = [];
5016
5022
  const warnings = [];
5017
5023
  const processedApprovalIds = /* @__PURE__ */ new Set();
5024
+ const programmaticToolCallIds = /* @__PURE__ */ new Set();
5018
5025
  const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
5019
5026
  prompt,
5020
5027
  providerOptionsName
@@ -5031,6 +5038,7 @@ async function convertToOpenAIResponsesInput({
5031
5038
  providerOptionsName
5032
5039
  );
5033
5040
  input.push({
5041
+ ...explicitMessageItemType && { type: "message" },
5034
5042
  role: "system",
5035
5043
  content: promptCacheBreakpoint == null ? content : [
5036
5044
  {
@@ -5048,6 +5056,7 @@ async function convertToOpenAIResponsesInput({
5048
5056
  providerOptionsName
5049
5057
  );
5050
5058
  input.push({
5059
+ ...explicitMessageItemType && { type: "message" },
5051
5060
  role: "developer",
5052
5061
  content: promptCacheBreakpoint == null ? content : [
5053
5062
  {
@@ -5077,6 +5086,7 @@ async function convertToOpenAIResponsesInput({
5077
5086
  }
5078
5087
  case "user": {
5079
5088
  input.push({
5089
+ ...explicitMessageItemType && { type: "message" },
5080
5090
  role: "user",
5081
5091
  content: content.map((part, index) => {
5082
5092
  var _a3, _b2, _c2, _d2, _e2;
@@ -5193,6 +5203,7 @@ async function convertToOpenAIResponsesInput({
5193
5203
  break;
5194
5204
  }
5195
5205
  input.push({
5206
+ ...explicitMessageItemType && { type: "message" },
5196
5207
  role: "assistant",
5197
5208
  content: [{ type: "output_text", text: part.text }],
5198
5209
  id,
@@ -5233,6 +5244,9 @@ async function convertToOpenAIResponsesInput({
5233
5244
  const namespace = (_k = (_h = (_g = part.providerOptions) == null ? void 0 : _g[providerOptionsName]) == null ? void 0 : _h.namespace) != null ? _k : (_j = (_i = part.providerMetadata) == null ? void 0 : _i[providerOptionsName]) == null ? void 0 : _j.namespace;
5234
5245
  const isAsync = (_p = (_m = (_l = part.providerOptions) == null ? void 0 : _l[providerOptionsName]) == null ? void 0 : _m.async) != null ? _p : (_o = (_n = part.providerMetadata) == null ? void 0 : _n[providerOptionsName]) == null ? void 0 : _o.async;
5235
5246
  const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
5247
+ if ((caller == null ? void 0 : caller.type) === "program") {
5248
+ programmaticToolCallIds.add(part.toolCallId);
5249
+ }
5236
5250
  if (hasConversation && id != null) {
5237
5251
  break;
5238
5252
  }
@@ -5884,6 +5898,12 @@ ${text}`,
5884
5898
  });
5885
5899
  continue;
5886
5900
  }
5901
+ const resultCaller = (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller;
5902
+ if (output.type === "execution-denied" && ((resultCaller == null ? void 0 : resultCaller.type) === "program" || programmaticToolCallIds.has(part.toolCallId))) {
5903
+ throw new UnsupportedFunctionalityError4({
5904
+ functionality: "execution-denied results for programmatic tool calls"
5905
+ });
5906
+ }
5887
5907
  const contentValue = await convertFunctionToolResultOutput({
5888
5908
  output,
5889
5909
  toolName: part.toolName,
@@ -5896,9 +5916,7 @@ ${text}`,
5896
5916
  providerOptionsName,
5897
5917
  warnings
5898
5918
  });
5899
- const caller = mapToolCaller(
5900
- (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
5901
- );
5919
+ const caller = mapToolCaller(resultCaller);
5902
5920
  input.push({
5903
5921
  type: "function_call_output",
5904
5922
  call_id: part.toolCallId,
@@ -6962,6 +6980,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
6962
6980
  toolNameMapping,
6963
6981
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
6964
6982
  providerOptionsName,
6983
+ explicitMessageItemType: config.explicitMessageItemType,
6965
6984
  fileIdPrefixes: config.fileIdPrefixes,
6966
6985
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
6967
6986
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
@@ -7720,6 +7739,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7720
7739
  break;
7721
7740
  }
7722
7741
  case "apply_patch_call": {
7742
+ hasFunctionCall = true;
7723
7743
  content.push({
7724
7744
  type: "tool-call",
7725
7745
  toolCallId: part.call_id,
@@ -8463,6 +8483,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8463
8483
  toolCall.applyPatch.endEmitted = true;
8464
8484
  }
8465
8485
  if (toolCall && value.item.status === "completed") {
8486
+ hasFunctionCall = true;
8466
8487
  controller.enqueue({
8467
8488
  type: "tool-call",
8468
8489
  toolCallId: toolCall.toolCallId,
@@ -11187,7 +11208,7 @@ var OpenAISkills = class {
11187
11208
  };
11188
11209
 
11189
11210
  // src/version.ts
11190
- var VERSION = true ? "4.0.61" : "0.0.0-test";
11211
+ var VERSION = true ? "4.0.63" : "0.0.0-test";
11191
11212
 
11192
11213
  // src/openai-provider.ts
11193
11214
  function createOpenAI(options = {}) {