How to send multiple images to OpenAI using the Vercel AI SDK #2306
-
Hello everyone! I want to send multiple images to the ChatGPT API, but I am not sure what a reliable way is; do we simply create an array of image urls and pass it to "image"? This is my current code that can send only one image. ` // Create an OpenAI API client (that's edge friendly!) export const dynamic = "force-dynamic"; export async function POST(req: Request) { let userMessage: CoreMessage; console.log("Image URL is being sent", data.imageUrl); // Call the language model return result.toAIStreamResponse(); |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
We have added a "attachments" feature to use chat that you can use in combination with Btw you are mixing the OpenAI SDK and the Vercel AI SDK with an OpenAI provider, which is confusing and can lead to issues. |
Beta Was this translation helpful? Give feedback.
We have added a "attachments" feature to use chat that you can use in combination with
convertToCoreMessages
. You can find an example here: https://sdk.vercel.ai/docs/ai-sdk-ui/chatbot#attachments-experimentalBtw you are mixing the OpenAI SDK and the Vercel AI SDK with an OpenAI provider, which is confusing and can lead to issues.