In my app the users don;t upload image files, but rather just enter an image url (example: www.vercel.com/test.png). I don’t understand if i can call the api with the url only or i need the actual file
Great to hear that you’re building with our AI SDK Excited to hear what you end up building, don’t forget to share it over in Community section.
The Vercel AI SDK supports working directly with image URLs, which is perfect for your use case where users enter image URLs rather than uploading files.
To implement this, you can modify the chat component to accept an image URL input instead of a file upload. You’ll store this URL in the component’s state and include it in the messages when submitting to the AI.
When sending the message to the API, you’ll include the image URL as part of the message object. The API route will then use this URL directly with the Gemini model, specifically using the ‘gemini-pro-vision’ model which supports image processing.
On the frontend, you’ll render the image in the chat interface using the provided URL. This allows users to see the image they’ve submitted along with the conversation.
If it helps, feel free to share your project here with us or specific code snippets.