@ai-sdk/openai 3.0.63 → 3.0.65

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.
@@ -2686,8 +2686,10 @@ async function convertToOpenAIResponsesInput({
2686
2686
  systemMessageMode,
2687
2687
  providerOptionsName,
2688
2688
  fileIdPrefixes,
2689
+ passThroughUnsupportedFiles = false,
2689
2690
  store,
2690
2691
  hasConversation = false,
2692
+ hasPreviousResponseId = false,
2691
2693
  hasLocalShellTool = false,
2692
2694
  hasShellTool = false,
2693
2695
  hasApplyPatchTool = false,
@@ -2735,8 +2737,8 @@ async function convertToOpenAIResponsesInput({
2735
2737
  return { type: "input_text", text: part.text };
2736
2738
  }
2737
2739
  case "file": {
2738
- if (part.mediaType.startsWith("image/")) {
2739
- const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2740
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2741
+ if (mediaType.startsWith("image/")) {
2740
2742
  return {
2741
2743
  type: "input_image",
2742
2744
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
@@ -2744,25 +2746,25 @@ async function convertToOpenAIResponsesInput({
2744
2746
  },
2745
2747
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2746
2748
  };
2747
- } else if (part.mediaType === "application/pdf") {
2748
- if (part.data instanceof URL) {
2749
- return {
2750
- type: "input_file",
2751
- file_url: part.data.toString()
2752
- };
2753
- }
2749
+ }
2750
+ if (part.data instanceof URL) {
2754
2751
  return {
2755
2752
  type: "input_file",
2756
- ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2757
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2758
- file_data: `data:application/pdf;base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
2759
- }
2753
+ file_url: part.data.toString()
2760
2754
  };
2761
- } else {
2755
+ }
2756
+ if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
2762
2757
  throw new import_provider6.UnsupportedFunctionalityError({
2763
- functionality: `file part media type ${part.mediaType}`
2758
+ functionality: `file part media type ${mediaType}`
2764
2759
  });
2765
2760
  }
2761
+ return {
2762
+ type: "input_file",
2763
+ ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2764
+ filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
2765
+ file_data: `data:${mediaType};base64,${(0, import_provider_utils24.convertToBase64)(part.data)}`
2766
+ }
2767
+ };
2766
2768
  }
2767
2769
  }
2768
2770
  })
@@ -2830,6 +2832,9 @@ async function convertToOpenAIResponsesInput({
2830
2832
  break;
2831
2833
  }
2832
2834
  if (store && id != null) {
2835
+ if (hasPreviousResponseId) {
2836
+ break;
2837
+ }
2833
2838
  input.push({ type: "item_reference", id });
2834
2839
  break;
2835
2840
  }
@@ -2974,7 +2979,7 @@ async function convertToOpenAIResponsesInput({
2974
2979
  schema: openaiResponsesReasoningProviderOptionsSchema
2975
2980
  });
2976
2981
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
2977
- if (hasConversation && reasoningId != null) {
2982
+ if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
2978
2983
  break;
2979
2984
  }
2980
2985
  if (reasoningId != null) {
@@ -4329,6 +4334,14 @@ var openaiLanguageModelResponsesOptionsSchema = (0, import_provider_utils26.lazy
4329
4334
  * Whether to store the generation. Defaults to `true`.
4330
4335
  */
4331
4336
  store: import_v419.z.boolean().nullish(),
4337
+ /**
4338
+ * Whether to pass through non-image file types as generic input files.
4339
+ *
4340
+ * By default, inline file inputs are restricted to images and PDFs.
4341
+ * Enable this when the target OpenAI Responses model supports additional
4342
+ * file media types, such as text/csv.
4343
+ */
4344
+ passThroughUnsupportedFiles: import_v419.z.boolean().optional(),
4332
4345
  /**
4333
4346
  * Whether to use strict JSON schema validation.
4334
4347
  * Defaults to `true`.
@@ -5042,7 +5055,7 @@ var OpenAIResponsesLanguageModel = class {
5042
5055
  toolChoice,
5043
5056
  responseFormat
5044
5057
  }) {
5045
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5058
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5046
5059
  const warnings = [];
5047
5060
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
5048
5061
  if (topK != null) {
@@ -5115,15 +5128,17 @@ var OpenAIResponsesLanguageModel = class {
5115
5128
  systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5116
5129
  providerOptionsName,
5117
5130
  fileIdPrefixes: this.config.fileIdPrefixes,
5118
- store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
5131
+ passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
5132
+ store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
5119
5133
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
5134
+ hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
5120
5135
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
5121
5136
  hasShellTool: hasOpenAITool("openai.shell"),
5122
5137
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
5123
5138
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5124
5139
  });
5125
5140
  warnings.push(...inputWarnings);
5126
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
5141
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
5127
5142
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
5128
5143
  function addInclude(key) {
5129
5144
  if (include == null) {
@@ -5139,9 +5154,9 @@ var OpenAIResponsesLanguageModel = class {
5139
5154
  if (topLogprobs) {
5140
5155
  addInclude("message.output_text.logprobs");
5141
5156
  }
5142
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
5157
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
5143
5158
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
5144
- )) == null ? void 0 : _f.name;
5159
+ )) == null ? void 0 : _g.name;
5145
5160
  if (webSearchToolName) {
5146
5161
  addInclude("web_search_call.action.sources");
5147
5162
  }
@@ -5164,7 +5179,7 @@ var OpenAIResponsesLanguageModel = class {
5164
5179
  format: responseFormat.schema != null ? {
5165
5180
  type: "json_schema",
5166
5181
  strict: strictJsonSchema,
5167
- name: (_g = responseFormat.name) != null ? _g : "response",
5182
+ name: (_h = responseFormat.name) != null ? _h : "response",
5168
5183
  description: responseFormat.description,
5169
5184
  schema: responseFormat.schema
5170
5185
  } : { type: "json_object" }
@@ -5253,9 +5268,9 @@ var OpenAIResponsesLanguageModel = class {
5253
5268
  });
5254
5269
  delete baseArgs.service_tier;
5255
5270
  }
5256
- const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
5271
+ const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
5257
5272
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
5258
- )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
5273
+ )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
5259
5274
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
5260
5275
  return {
5261
5276
  webSearchToolName,