@ai-sdk/openai 3.0.62 → 3.0.64

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.
@@ -2734,6 +2734,7 @@ async function convertToOpenAIResponsesInput({
2734
2734
  systemMessageMode,
2735
2735
  providerOptionsName,
2736
2736
  fileIdPrefixes,
2737
+ passThroughUnsupportedFiles = false,
2737
2738
  store,
2738
2739
  hasConversation = false,
2739
2740
  hasLocalShellTool = false,
@@ -2783,8 +2784,8 @@ async function convertToOpenAIResponsesInput({
2783
2784
  return { type: "input_text", text: part.text };
2784
2785
  }
2785
2786
  case "file": {
2786
- if (part.mediaType.startsWith("image/")) {
2787
- const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2787
+ const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2788
+ if (mediaType.startsWith("image/")) {
2788
2789
  return {
2789
2790
  type: "input_image",
2790
2791
  ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
@@ -2792,25 +2793,25 @@ async function convertToOpenAIResponsesInput({
2792
2793
  },
2793
2794
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2[providerOptionsName]) == null ? void 0 : _b2.imageDetail
2794
2795
  };
2795
- } else if (part.mediaType === "application/pdf") {
2796
- if (part.data instanceof URL) {
2797
- return {
2798
- type: "input_file",
2799
- file_url: part.data.toString()
2800
- };
2801
- }
2796
+ }
2797
+ if (part.data instanceof URL) {
2802
2798
  return {
2803
2799
  type: "input_file",
2804
- ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2805
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2806
- file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2807
- }
2800
+ file_url: part.data.toString()
2808
2801
  };
2809
- } else {
2802
+ }
2803
+ if (mediaType !== "application/pdf" && !passThroughUnsupportedFiles) {
2810
2804
  throw new UnsupportedFunctionalityError4({
2811
- functionality: `file part media type ${part.mediaType}`
2805
+ functionality: `file part media type ${mediaType}`
2812
2806
  });
2813
2807
  }
2808
+ return {
2809
+ type: "input_file",
2810
+ ...typeof part.data === "string" && isFileId(part.data, fileIdPrefixes) ? { file_id: part.data } : {
2811
+ filename: (_c2 = part.filename) != null ? _c2 : mediaType === "application/pdf" ? `part-${index}.pdf` : `part-${index}`,
2812
+ file_data: `data:${mediaType};base64,${convertToBase642(part.data)}`
2813
+ }
2814
+ };
2814
2815
  }
2815
2816
  }
2816
2817
  })
@@ -4383,6 +4384,14 @@ var openaiLanguageModelResponsesOptionsSchema = lazySchema17(
4383
4384
  * Whether to store the generation. Defaults to `true`.
4384
4385
  */
4385
4386
  store: z19.boolean().nullish(),
4387
+ /**
4388
+ * Whether to pass through non-image file types as generic input files.
4389
+ *
4390
+ * By default, inline file inputs are restricted to images and PDFs.
4391
+ * Enable this when the target OpenAI Responses model supports additional
4392
+ * file media types, such as text/csv.
4393
+ */
4394
+ passThroughUnsupportedFiles: z19.boolean().optional(),
4386
4395
  /**
4387
4396
  * Whether to use strict JSON schema validation.
4388
4397
  * Defaults to `true`.
@@ -5126,7 +5135,7 @@ var OpenAIResponsesLanguageModel = class {
5126
5135
  toolChoice,
5127
5136
  responseFormat
5128
5137
  }) {
5129
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
5138
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
5130
5139
  const warnings = [];
5131
5140
  const modelCapabilities = getOpenAILanguageModelCapabilities(this.modelId);
5132
5141
  if (topK != null) {
@@ -5199,7 +5208,8 @@ var OpenAIResponsesLanguageModel = class {
5199
5208
  systemMessageMode: (_c = openaiOptions == null ? void 0 : openaiOptions.systemMessageMode) != null ? _c : isReasoningModel ? "developer" : modelCapabilities.systemMessageMode,
5200
5209
  providerOptionsName,
5201
5210
  fileIdPrefixes: this.config.fileIdPrefixes,
5202
- store: (_d = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _d : true,
5211
+ passThroughUnsupportedFiles: (_d = openaiOptions == null ? void 0 : openaiOptions.passThroughUnsupportedFiles) != null ? _d : false,
5212
+ store: (_e = openaiOptions == null ? void 0 : openaiOptions.store) != null ? _e : true,
5203
5213
  hasConversation: (openaiOptions == null ? void 0 : openaiOptions.conversation) != null,
5204
5214
  hasLocalShellTool: hasOpenAITool("openai.local_shell"),
5205
5215
  hasShellTool: hasOpenAITool("openai.shell"),
@@ -5207,7 +5217,7 @@ var OpenAIResponsesLanguageModel = class {
5207
5217
  customProviderToolNames: customProviderToolNames.size > 0 ? customProviderToolNames : void 0
5208
5218
  });
5209
5219
  warnings.push(...inputWarnings);
5210
- const strictJsonSchema = (_e = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _e : true;
5220
+ const strictJsonSchema = (_f = openaiOptions == null ? void 0 : openaiOptions.strictJsonSchema) != null ? _f : true;
5211
5221
  let include = openaiOptions == null ? void 0 : openaiOptions.include;
5212
5222
  function addInclude(key) {
5213
5223
  if (include == null) {
@@ -5223,9 +5233,9 @@ var OpenAIResponsesLanguageModel = class {
5223
5233
  if (topLogprobs) {
5224
5234
  addInclude("message.output_text.logprobs");
5225
5235
  }
5226
- const webSearchToolName = (_f = tools == null ? void 0 : tools.find(
5236
+ const webSearchToolName = (_g = tools == null ? void 0 : tools.find(
5227
5237
  (tool) => tool.type === "provider" && (tool.id === "openai.web_search" || tool.id === "openai.web_search_preview")
5228
- )) == null ? void 0 : _f.name;
5238
+ )) == null ? void 0 : _g.name;
5229
5239
  if (webSearchToolName) {
5230
5240
  addInclude("web_search_call.action.sources");
5231
5241
  }
@@ -5248,7 +5258,7 @@ var OpenAIResponsesLanguageModel = class {
5248
5258
  format: responseFormat.schema != null ? {
5249
5259
  type: "json_schema",
5250
5260
  strict: strictJsonSchema,
5251
- name: (_g = responseFormat.name) != null ? _g : "response",
5261
+ name: (_h = responseFormat.name) != null ? _h : "response",
5252
5262
  description: responseFormat.description,
5253
5263
  schema: responseFormat.schema
5254
5264
  } : { type: "json_object" }
@@ -5337,9 +5347,9 @@ var OpenAIResponsesLanguageModel = class {
5337
5347
  });
5338
5348
  delete baseArgs.service_tier;
5339
5349
  }
5340
- const shellToolEnvType = (_j = (_i = (_h = tools == null ? void 0 : tools.find(
5350
+ const shellToolEnvType = (_k = (_j = (_i = tools == null ? void 0 : tools.find(
5341
5351
  (tool) => tool.type === "provider" && tool.id === "openai.shell"
5342
- )) == null ? void 0 : _h.args) == null ? void 0 : _i.environment) == null ? void 0 : _j.type;
5352
+ )) == null ? void 0 : _i.args) == null ? void 0 : _j.environment) == null ? void 0 : _k.type;
5343
5353
  const isShellProviderExecuted = shellToolEnvType === "containerAuto" || shellToolEnvType === "containerReference";
5344
5354
  return {
5345
5355
  webSearchToolName,