@ai-sdk/openai 4.0.62 → 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,7 +162,7 @@ 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;
@@ -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';
@@ -2377,8 +2387,9 @@ type ImageGenerationArgs = {
2377
2387
  quality?: 'auto' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
2378
2388
  /**
2379
2389
  * The size of the generated image.
2380
- * One of 1024x1024, 1024x1536, 1536x1024, or auto. gpt-image-2 also accepts
2381
- * 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.
2382
2393
  * Default: auto.
2383
2394
  */
2384
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-"];
@@ -3862,6 +3866,7 @@ async function convertToOpenAIResponsesInput({
3862
3866
  toolNameMapping,
3863
3867
  systemMessageMode,
3864
3868
  providerOptionsName,
3869
+ explicitMessageItemType = false,
3865
3870
  fileIdPrefixes,
3866
3871
  passThroughUnsupportedFiles = false,
3867
3872
  store,
@@ -3879,6 +3884,7 @@ async function convertToOpenAIResponsesInput({
3879
3884
  let input = [];
3880
3885
  const warnings = [];
3881
3886
  const processedApprovalIds = /* @__PURE__ */ new Set();
3887
+ const programmaticToolCallIds = /* @__PURE__ */ new Set();
3882
3888
  const parallelToolResultGroups = hasConversation || hasPreviousResponseId ? collectCompleteParallelToolResultGroups({
3883
3889
  prompt,
3884
3890
  providerOptionsName
@@ -3895,6 +3901,7 @@ async function convertToOpenAIResponsesInput({
3895
3901
  providerOptionsName
3896
3902
  );
3897
3903
  input.push({
3904
+ ...explicitMessageItemType && { type: "message" },
3898
3905
  role: "system",
3899
3906
  content: promptCacheBreakpoint == null ? content : [
3900
3907
  {
@@ -3912,6 +3919,7 @@ async function convertToOpenAIResponsesInput({
3912
3919
  providerOptionsName
3913
3920
  );
3914
3921
  input.push({
3922
+ ...explicitMessageItemType && { type: "message" },
3915
3923
  role: "developer",
3916
3924
  content: promptCacheBreakpoint == null ? content : [
3917
3925
  {
@@ -3941,6 +3949,7 @@ async function convertToOpenAIResponsesInput({
3941
3949
  }
3942
3950
  case "user": {
3943
3951
  input.push({
3952
+ ...explicitMessageItemType && { type: "message" },
3944
3953
  role: "user",
3945
3954
  content: content.map((part, index) => {
3946
3955
  var _a3, _b2, _c2, _d2, _e2;
@@ -4057,6 +4066,7 @@ async function convertToOpenAIResponsesInput({
4057
4066
  break;
4058
4067
  }
4059
4068
  input.push({
4069
+ ...explicitMessageItemType && { type: "message" },
4060
4070
  role: "assistant",
4061
4071
  content: [{ type: "output_text", text: part.text }],
4062
4072
  id,
@@ -4097,6 +4107,9 @@ async function convertToOpenAIResponsesInput({
4097
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;
4098
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;
4099
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
+ }
4100
4113
  if (hasConversation && id != null) {
4101
4114
  break;
4102
4115
  }
@@ -4748,6 +4761,12 @@ ${text}`,
4748
4761
  });
4749
4762
  continue;
4750
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
+ }
4751
4770
  const contentValue = await convertFunctionToolResultOutput({
4752
4771
  output,
4753
4772
  toolName: part.toolName,
@@ -4760,9 +4779,7 @@ ${text}`,
4760
4779
  providerOptionsName,
4761
4780
  warnings
4762
4781
  });
4763
- const caller = mapToolCaller(
4764
- (_P = (_O = part.providerOptions) == null ? void 0 : _O[providerOptionsName]) == null ? void 0 : _P.caller
4765
- );
4782
+ const caller = mapToolCaller(resultCaller);
4766
4783
  input.push({
4767
4784
  type: "function_call_output",
4768
4785
  call_id: part.toolCallId,
@@ -7255,6 +7272,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
7255
7272
  toolNameMapping,
7256
7273
  systemMessageMode: (_d = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _d : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
7257
7274
  providerOptionsName,
7275
+ explicitMessageItemType: config.explicitMessageItemType,
7258
7276
  fileIdPrefixes: config.fileIdPrefixes,
7259
7277
  passThroughUnsupportedFiles: (_e = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _e : false,
7260
7278
  store: (_f = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _f : true,
@@ -8013,6 +8031,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8013
8031
  break;
8014
8032
  }
8015
8033
  case "apply_patch_call": {
8034
+ hasFunctionCall = true;
8016
8035
  content.push({
8017
8036
  type: "tool-call",
8018
8037
  toolCallId: part.call_id,
@@ -8756,6 +8775,7 @@ var OpenAIResponsesLanguageModel = class _OpenAIResponsesLanguageModel {
8756
8775
  toolCall.applyPatch.endEmitted = true;
8757
8776
  }
8758
8777
  if (toolCall && value.item.status === "completed") {
8778
+ hasFunctionCall = true;
8759
8779
  controller.enqueue({
8760
8780
  type: "tool-call",
8761
8781
  toolCallId: toolCall.toolCallId,