@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.
@@ -116,7 +116,7 @@ function convertToOpenAIChatMessages({
116
116
  }
117
117
  return {
118
118
  type: "file",
119
- file: {
119
+ file: typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
120
120
  filename: (_c = part.filename) != null ? _c : `part-${index}.pdf`,
121
121
  file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
122
122
  }
@@ -2072,6 +2072,7 @@ import {
2072
2072
  } from "@ai-sdk/provider";
2073
2073
  import { parseProviderOptions as parseProviderOptions6 } from "@ai-sdk/provider-utils";
2074
2074
  import { z as z14 } from "zod/v4";
2075
+ import { convertToBase64 as convertToBase642 } from "@ai-sdk/provider-utils";
2075
2076
  async function convertToOpenAIResponsesMessages({
2076
2077
  prompt,
2077
2078
  systemMessageMode
@@ -2121,8 +2122,9 @@ async function convertToOpenAIResponsesMessages({
2121
2122
  const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
2122
2123
  return {
2123
2124
  type: "input_image",
2124
- image_url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${part.data}`,
2125
- // OpenAI specific extension: image detail
2125
+ ...part.data instanceof URL ? { image_url: part.data.toString() } : typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
2126
+ image_url: `data:${mediaType};base64,${part.data}`
2127
+ },
2126
2128
  detail: (_b2 = (_a2 = part.providerOptions) == null ? void 0 : _a2.openai) == null ? void 0 : _b2.imageDetail
2127
2129
  };
2128
2130
  } else if (part.mediaType === "application/pdf") {
@@ -2133,8 +2135,10 @@ async function convertToOpenAIResponsesMessages({
2133
2135
  }
2134
2136
  return {
2135
2137
  type: "input_file",
2136
- filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2137
- file_data: `data:application/pdf;base64,${part.data}`
2138
+ ...typeof part.data === "string" && part.data.startsWith("file-") ? { file_id: part.data } : {
2139
+ filename: (_c2 = part.filename) != null ? _c2 : `part-${index}.pdf`,
2140
+ file_data: `data:application/pdf;base64,${convertToBase642(part.data)}`
2141
+ }
2138
2142
  };
2139
2143
  } else {
2140
2144
  throw new UnsupportedFunctionalityError4({