@ai-sdk/openai 2.0.3 → 2.0.4

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
@@ -122,7 +122,7 @@ function convertToOpenAIChatMessages({
122
122
  }
123
123
  return {
124
124
  type: "file",
125
- file: {
125
+ file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
126
126
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
127
127
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
128
128
  }
@@ -1972,6 +1972,7 @@ import {
1972
1972
  } from "@ai-sdk/provider";
1973
1973
  import { parseProviderOptions as parseProviderOptions5 } from "@ai-sdk/provider-utils";
1974
1974
  import { z as z13 } from "zod/v4";
1975
+ import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
1975
1976
  async function convertToOpenAIResponsesMessages({
1976
1977
  prompt,
1977
1978
  systemMessageMode
@@ -2021,8 +2022,9 @@ async function convertToOpenAIResponsesMessages({
2021
2022
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2022
2023
  return {
2023
2024
  type: "input_image",
2024
- image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
2025
- // OpenAI specific extension: image detail
2025
+ ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
2026
+ image_url: `data:${mediaType};base64,${part.data}`
2027
+ },
2026
2028
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2027
2029
  };
2028
2030
  } else if (part.mediaType === "application/pdf") {
@@ -2033,8 +2035,10 @@ async function convertToOpenAIResponsesMessages({
2033
2035
  }
2034
2036
  return {
2035
2037
  type: "input_file",
2036
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2037
- file_data: `data:application/pdf;base64,${part.data}`
2038
+ ...typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
2039
+ filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2040
+ file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2041
+ }
2038
2042
  };
2039
2043
  } else {
2040
2044
  throw new UnsupportedFunctionalityError4({