@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.
package/dist/index.mjs CHANGED
@@ -2837,8 +2837,10 @@ async function convertToOpenAIResponsesInput({
2837
2837
  systemMessageMode,
2838
2838
  providerOptionsName,
2839
2839
  fileIdPrefixes,
2840
+ passThroughUnsupportedFiles = false,
2840
2841
  store,
2841
2842
  hasConversation = false,
2843
+ hasPreviousResponseId = false,
2842
2844
  hasLocalShellTool = false,
2843
2845
  hasShellTool = false,
2844
2846
  hasApplyPatchTool = false,
@@ -2886,8 +2888,8 @@ async function convertToOpenAIResponsesInput({
2886
2888
  return { type: "input_text", text: part.text };
2887
2889
  }
2888
2890
  case "file": {
2889
- if (part.mediaType.startsWith("image/")) {
2890
- const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2891
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2892
+ if (mediaType.startsWith("image/")) {
2891
2893
  return {
2892
2894
  type: "input_image",
2893
2895
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
@@ -2895,25 +2897,25 @@ async function convertToOpenAIResponsesInput({
2895
2897
  },
2896
2898
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2897
2899
  };
2898
- } else if (part.mediaType === "application/pdf") {
2899
- if (part.data instanceof URL) {
2900
- return {
2901
- type: "input_file",
2902
- file_url: part.data.toString()
2903
- };
2904
- }
2900
+ }
2901
+ if (part.data instanceof URL) {
2905
2902
  return {
2906
2903
  type: "input_file",
2907
- ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2908
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2909
- file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2910
- }
2904
+ file_url: part.data.toString()
2911
2905
  };
2912
- } else {
2906
+ }
2907
+ if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
2913
2908
  throw new UnsupportedFunctionalityError4({
2914
- functionality: `file part media type ${part.mediaType}`
2909
+ functionality: `file part media type ${mediaType}`
2915
2910
  });
2916
2911
  }
2912
+ return {
2913
+ type: "input_file",
2914
+ ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2915
+ filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
2916
+ file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
2917
+ }
2918
+ };
2917
2919
  }
2918
2920
  }
2919
2921
  })
@@ -2981,6 +2983,9 @@ async function convertToOpenAIResponsesInput({
2981
2983
  break;
2982
2984
  }
2983
2985
  if (store && id != null) {
2986
+ if (hasPreviousResponseId) {
2987
+ break;
2988
+ }
2984
2989
  input.push({ type: "item_reference", id });
2985
2990
  break;
2986
2991
  }
@@ -3125,7 +3130,7 @@ async function convertToOpenAIResponsesInput({
3125
3130
  schema: openaiResponsesReasoningProviderOptionsSchema
3126
3131
  });
3127
3132
  const reasoningId = providerOptions == null ? void 0 : providerOptions.itemId;
3128
- if (hasConversation && reasoningId != null) {
3133
+ if ((hasConversation || hasPreviousResponseId) && reasoningId != null) {
3129
3134
  break;
3130
3135
  }
3131
3136
  if (reasoningId != null) {
@@ -4486,6 +4491,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema21(
4486
4491
  * Whether to store the generation. Defaults to `true`.
4487
4492
  */
4488
4493
  store: z23.boolean().nullish(),
4494
+ /**
4495
+ * Whether to pass through non-image file types as generic input files.
4496
+ *
4497
+ * By default, inline file inputs are restricted to images and PDFs.
4498
+ * Enable this when the target OpenAI Responses model supports additional
4499
+ * file media types, such as text/csv.
4500
+ */
4501
+ passThroughUnsupportedFiles: z23.boolean().optional(),
4489
4502
  /**
4490
4503
  * Whether to use strict JSON schema validation.
4491
4504
  * Defaults to `true`.
@@ -4882,7 +4895,7 @@ var OpenAIResponsesLanguageModel = class {
4882
4895
  toolChoice,
4883
4896
  responseFormat
4884
4897
  }) {
4885
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
4898
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
4886
4899
  const warnings = [];
4887
4900
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
4888
4901
  if (topK != null) {
@@ -4955,15 +4968,17 @@ var OpenAIResponsesLanguageModel = class {
4955
4968
  systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
4956
4969
  providerOptionsName,
4957
4970
  fileIdPrefixes: this.config.fileIdPrefixes,
4958
- store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
4971
+ passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
4972
+ store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
4959
4973
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
4974
+ hasPreviousResponseId: (openaiOptions == null ? void 0 : openaiOptions.previousResponseId) != null,
4960
4975
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
4961
4976
  hasShellTool: hasOpenAITool("openai.shell"),
4962
4977
  hasApplyPatchTool: hasOpenAITool("openai.apply_patch"),
4963
4978
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
4964
4979
  });
4965
4980
  warnings.push(...inputWarnings);
4966
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
4981
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
4967
4982
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
4968
4983
  function addInclude(key) {
4969
4984
  if (include == null) {
@@ -4979,9 +4994,9 @@ var OpenAIResponsesLanguageModel = class {
4979
4994
  if (topLogprobs) {
4980
4995
  addInclude("message.output_text.logprobs");
4981
4996
  }
4982
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
4997
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
4983
4998
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
4984
- )) == null ? void 0 : _f.name;
4999
+ )) == null ? void 0 : _g.name;
4985
5000
  if (webSearchToolName) {
4986
5001
  addInclude("web_search_call.action.sources");
4987
5002
  }
@@ -5004,7 +5019,7 @@ var OpenAIResponsesLanguageModel = class {
5004
5019
  format: responseFormat.schema != null ? {
5005
5020
  type: "json_schema",
5006
5021
  strict: strictJsonSchema,
5007
- name: (_g = responseFormat.name) != null ? _g : "response",
5022
+ name: (_h = responseFormat.name) != null ? _h : "response",
5008
5023
  description: responseFormat.description,
5009
5024
  schema: responseFormat.schema
5010
5025
  } : { type: "json_object" }
@@ -5093,9 +5108,9 @@ var OpenAIResponsesLanguageModel = class {
5093
5108
  });
5094
5109
  delete baseArgs.service_tier;
5095
5110
  }
5096
- const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
5111
+ const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
5097
5112
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
5098
- )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
5113
+ )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
5099
5114
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
5100
5115
  return {
5101
5116
  webSearchToolName,
@@ -6912,7 +6927,7 @@ var OpenAITranscriptionModel = class {
6912
6927
  };
6913
6928
 
6914
6929
  // src/version.ts
6915
- var VERSION = true ? "3.0.63" : "0.0.0-test";
6930
+ var VERSION = true ? "3.0.65" : "0.0.0-test";
6916
6931
 
6917
6932
  // src/openai-provider.ts
6918
6933
  function createOpenAI(options = {}) {