@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.
@@ -116,6 +116,13 @@ type OpenAIConfig = {
116
116
  fetch?: FetchFunction;
117
117
  webSocket?: WebSocketConstructor;
118
118
  generateId?: () => string;
119
+ /**
120
+ * Whether Responses API message input items must include an explicit
121
+ * `type: 'message'` discriminator.
122
+ *
123
+ * @see https://github.com/vercel/ai/issues/20180
124
+ */
125
+ explicitMessageItemType?: boolean;
119
126
  /**
120
127
  * This is soft-deprecated. Use provider references (e.g. `{ openai: 'file-abc123' }`)
121
128
  * in file part data instead. File ID prefixes used to identify file IDs
@@ -155,12 +162,12 @@ declare class OpenAIEmbeddingModel implements EmbeddingModelV4 {
155
162
  doEmbed({ values, headers, abortSignal, providerOptions, }: Parameters<EmbeddingModelV4['doEmbed']>[0]): Promise<Awaited<ReturnType<EmbeddingModelV4['doEmbed']>>>;
156
163
  }
157
164
 
158
- 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 & {});
165
+ 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 & {});
159
166
  declare const modelMaxImagesPerCall: Record<OpenAIImageModelId, number>;
160
167
  declare function hasDefaultResponseFormat(modelId: string): boolean;
161
168
  declare function getMaxImagesPerCall(modelId: OpenAIImageModelId): number;
162
169
  declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
163
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
170
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
164
171
  background?: "auto" | "transparent" | "opaque" | undefined;
165
172
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
166
173
  outputCompression?: number | undefined;
@@ -168,7 +175,7 @@ declare const openaiImageModelOptions: _ai_sdk_provider_utils.LazySchema<{
168
175
  }>;
169
176
  type OpenAIImageModelOptions = InferSchema<typeof openaiImageModelOptions>;
170
177
  declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySchema<{
171
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
178
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
172
179
  background?: "auto" | "transparent" | "opaque" | undefined;
173
180
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
174
181
  outputCompression?: number | undefined;
@@ -178,7 +185,7 @@ declare const openaiImageModelGenerationOptions: _ai_sdk_provider_utils.LazySche
178
185
  }>;
179
186
  type OpenAIImageModelGenerationOptions = InferSchema<typeof openaiImageModelGenerationOptions>;
180
187
  declare const openaiImageModelEditOptions: _ai_sdk_provider_utils.LazySchema<{
181
- quality?: "low" | "medium" | "high" | "auto" | "standard" | "hd" | undefined;
188
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | "standard" | "hd" | undefined;
182
189
  background?: "auto" | "transparent" | "opaque" | undefined;
183
190
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
184
191
  outputCompression?: number | undefined;
@@ -422,6 +429,7 @@ type OpenAIResponsesInputItem = OpenAIResponsesSystemMessage | OpenAIResponsesUs
422
429
  type OpenAIResponsesIncludeValue = 'web_search_call.action.sources' | 'web_search_call.results' | 'code_interpreter_call.outputs' | 'computer_call_output.output.image_url' | 'file_search_call.results' | 'message.input_image.image_url' | 'message.output_text.logprobs' | 'reasoning.encrypted_content';
423
430
  type OpenAIResponsesIncludeOptions = Array<OpenAIResponsesIncludeValue> | undefined | null;
424
431
  type OpenAIResponsesSystemMessage = {
432
+ type?: 'message';
425
433
  role: 'system' | 'developer';
426
434
  content: string | Array<{
427
435
  type: 'input_text';
@@ -432,6 +440,7 @@ type OpenAIResponsesSystemMessage = {
432
440
  }>;
433
441
  };
434
442
  type OpenAIResponsesUserMessage = {
443
+ type?: 'message';
435
444
  role: 'user';
436
445
  content: Array<{
437
446
  type: 'input_text';
@@ -473,6 +482,7 @@ type OpenAIResponsesUserMessage = {
473
482
  }>;
474
483
  };
475
484
  type OpenAIResponsesAssistantMessage = {
485
+ type?: 'message';
476
486
  role: 'assistant';
477
487
  content: Array<{
478
488
  type: 'output_text';
@@ -791,7 +801,7 @@ type OpenAIResponsesTool = OpenAIResponsesFunctionTool | {
791
801
  output_compression: number | undefined;
792
802
  output_format: 'png' | 'jpeg' | 'webp' | undefined;
793
803
  partial_images: number | undefined;
794
- quality: 'auto' | 'low' | 'medium' | 'high' | undefined;
804
+ quality: 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max' | undefined;
795
805
  size: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {}) | undefined;
796
806
  }
797
807
  /**
@@ -2315,7 +2325,7 @@ declare const imageGenerationArgsSchema: _ai_sdk_provider_utils.LazySchema<{
2315
2325
  outputCompression?: number | undefined;
2316
2326
  outputFormat?: "png" | "jpeg" | "webp" | undefined;
2317
2327
  partialImages?: number | undefined;
2318
- quality?: "low" | "medium" | "high" | "auto" | undefined;
2328
+ quality?: "low" | "medium" | "high" | "xhigh" | "max" | "auto" | undefined;
2319
2329
  size?: string | undefined;
2320
2330
  }>;
2321
2331
  declare const imageGenerationOutputSchema: _ai_sdk_provider_utils.LazySchema<{
@@ -2371,13 +2381,15 @@ type ImageGenerationArgs = {
2371
2381
  partialImages?: number;
2372
2382
  /**
2373
2383
  * The quality of the generated image.
2374
- * One of low, medium, high, or auto. Default: auto.
2384
+ * One of low, medium, high, xhigh, max, or auto. Default: auto.
2385
+ * xhigh and max are supported by GPT Image 2.5 models.
2375
2386
  */
2376
- quality?: 'auto' | 'low' | 'medium' | 'high';
2387
+ quality?: 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
2377
2388
  /**
2378
2389
  * The size of the generated image.
2379
- * One of 1024x1024, 1024x1536, 1536x1024, or auto. gpt-image-2 also accepts
2380
- * arbitrary WIDTHxHEIGHT sizes where both are divisible by 16, e.g. 1536x864.
2390
+ * One of 1024x1024, 1024x1536, 1536x1024, or auto. GPT Image 2 and 2.5
2391
+ * models also accept arbitrary WIDTHxHEIGHT sizes where both are divisible
2392
+ * by 16, e.g. 1536x864.
2381
2393
  * Default: auto.
2382
2394
  */
2383
2395
  size?: 'auto' | '1024x1024' | '1024x1536' | '1536x1024' | (string & {});
@@ -2114,6 +2114,10 @@ var modelMaxImagesPerCall = {
2114
2114
  "gpt-image-1-mini": 10,
2115
2115
  "gpt-image-1.5": 10,
2116
2116
  "gpt-image-2": 10,
2117
+ "gpt-image-2.5-flare": 10,
2118
+ "gpt-image-2.5-flare-2026-09-08": 10,
2119
+ "gpt-image-2.5-sunburst": 10,
2120
+ "gpt-image-2.5-sunburst-2026-09-08": 10,
2117
2121
  "chatgpt-image-latest": 10
2118
2122
  };
2119
2123
  var defaultResponseFormatPrefixes = ["chatgpt-image-", "gpt-image-"];
@@ -2130,9 +2134,10 @@ var baseImageModelOptionsObject = z9.object({
2130
2134
  /**
2131
2135
  * Quality of the generated image(s).
2132
2136
  *
2133
- * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `auto`.
2137
+ * Valid values: `standard`, `hd`, `low`, `medium`, `high`, `xhigh`, `max`, `auto`.
2138
+ * `xhigh` and `max` are supported by GPT Image 2.5 models.
2134
2139
  */
2135
- quality: z9.enum(["standard", "hd", "low", "medium", "high", "auto"]).optional(),
2140
+ quality: z9.enum(["standard", "hd", "low", "medium", "high", "xhigh", "max", "auto"]).optional(),
2136
2141
  /**
2137
2142
  * Background behavior for the generated image(s).
2138
2143
  *
@@ -3861,6 +3866,7 @@ async function convertToOpenAIResponsesInput({
3861
3866
  toolNameMapping,
3862
3867
  systemMessageMode,
3863
3868
  providerOptionsName,
3869
+ explicitMessageItemType = false,
3864
3870
  fileIdPrefixes,
3865
3871
  passThroughUnsupportedFiles = false,
3866
3872
  store,
@@ -3878,6 +3884,7 @@ async function convertToOpenAIResponsesInput({
3878
3884
  let input = [];
3879
3885
  const warnings = [];
3880
3886
  const processedApprovalIds = /* @__PURE__ */ new Set();
3887
+ const programmaticToolCallIds = /* @__PURE__ */ new Set();
3881
3888
  const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
3882
3889
  prompt,
3883
3890
  providerOptionsName
@@ -3894,6 +3901,7 @@ async function convertToOpenAIResponsesInput({
3894
3901
  providerOptionsName
3895
3902
  );
3896
3903
  input.push({
3904
+ ...explicitMessageItemType && { type: "message" },
3897
3905
  role: "system",
3898
3906
  content: promptCacheBreakpoint == null ? content : [
3899
3907
  {
@@ -3911,6 +3919,7 @@ async function convertToOpenAIResponsesInput({
3911
3919
  providerOptionsName
3912
3920
  );
3913
3921
  input.push({
3922
+ ...explicitMessageItemType && { type: "message" },
3914
3923
  role: "developer",
3915
3924
  content: promptCacheBreakpoint == null ? content : [
3916
3925
  {
@@ -3940,6 +3949,7 @@ async function convertToOpenAIResponsesInput({
3940
3949
  }
3941
3950
  case "user": {
3942
3951
  input.push({
3952
+ ...explicitMessageItemType && { type: "message" },
3943
3953
  role: "user",
3944
3954
  content: content.map((part, index) => {
3945
3955
  var _a3, _b2, _c2, _d2, _e2;
@@ -4056,6 +4066,7 @@ async function convertToOpenAIResponsesInput({
4056
4066
  break;
4057
4067
  }
4058
4068
  input.push({
4069
+ ...explicitMessageItemType && { type: "message" },
4059
4070
  role: "assistant",
4060
4071
  content: [{ type: "output_text", text: part.text }],
4061
4072
  id,
@@ -4096,6 +4107,9 @@ async function convertToOpenAIResponsesInput({
4096
4107
  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;
4097
4108
  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;
4098
4109
  const caller = (_r = (_q = part.providerOptions) == null ? void 0 : _q[providerOptionsName]) == null ? void 0 : _r.caller;
4110
+ if ((caller == null ? void 0 : caller.type) === "program") {
4111
+ programmaticToolCallIds.add(part.toolCallId);
4112
+ }
4099
4113
  if (hasConversation && id != null) {
4100
4114
  break;
4101
4115
  }
@@ -4747,6 +4761,12 @@ ${text}`,
4747
4761
  });
4748
4762
  continue;
4749
4763
  }
4764
+ const resultCaller = (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller;
4765
+ if (output.type === "execution-denied" && ((resultCaller == null ? void 0 : resultCaller.type) === "program" || programmaticToolCallIds.has(part.toolCallId))) {
4766
+ throw new UnsupportedFunctionalityError5({
4767
+ functionality: "execution-denied results for programmatic tool calls"
4768
+ });
4769
+ }
4750
4770
  const contentValue = await convertFunctionToolResultOutput({
4751
4771
  output,
4752
4772
  toolName: part.toolName,
@@ -4759,9 +4779,7 @@ ${text}`,
4759
4779
  providerOptionsName,
4760
4780
  warnings
4761
4781
  });
4762
- const caller = mapToolCaller(
4763
- (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
4764
- );
4782
+ const caller = mapToolCaller(resultCaller);
4765
4783
  input.push({
4766
4784
  type: "function_call_output",
4767
4785
  call_id: part.toolCallId,
@@ -6298,7 +6316,7 @@ var imageGenerationArgsSchema = lazySchema22(
6298
6316
  outputCompression: z24.number().int().min(0).max(100).optional(),
6299
6317
  outputFormat: z24.enum(["png", "jpeg", "webp"]).optional(),
6300
6318
  partialImages: z24.number().int().min(0).max(3).optional(),
6301
- quality: z24.enum(["auto", "low", "medium", "high"]).optional(),
6319
+ quality: z24.enum(["auto", "low", "medium", "high", "xhigh", "max"]).optional(),
6302
6320
  size: z24.union([
6303
6321
  z24.enum(["1024x1024", "1024x1536", "1536x1024", "auto"]),
6304
6322
  z24.string().regex(/^\d+x\d+$/)
@@ -7254,6 +7272,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7254
7272
  toolNameMapping,
7255
7273
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
7256
7274
  providerOptionsName,
7275
+ explicitMessageItemType: config.explicitMessageItemType,
7257
7276
  fileIdPrefixes: config.fileIdPrefixes,
7258
7277
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
7259
7278
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
@@ -8012,6 +8031,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8012
8031
  break;
8013
8032
  }
8014
8033
  case "apply_patch_call": {
8034
+ hasFunctionCall = true;
8015
8035
  content.push({
8016
8036
  type: "tool-call",
8017
8037
  toolCallId: part.call_id,
@@ -8755,6 +8775,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8755
8775
  toolCall.applyPatch.endEmitted = true;
8756
8776
  }
8757
8777
  if (toolCall && value.item.status === "completed") {
8778
+ hasFunctionCall = true;
8758
8779
  controller.enqueue({
8759
8780
  type: "tool-call",
8760
8781
  toolCallId: toolCall.toolCallId,