How to give Gemini AI API multiple files
The Problem
I am working with Google Gemini AI API on Herkules.dk and when you upload multiple files to Google's Gemini API using the Files API, there's no built-in way to reference which file is which in your conversation. The API doesn't preserve the original filename in a way that's accessible to the model, it only gets the file URI and MIME type. I think that is a bit weird.
Here's what happens when you upload files:
const file = new File([buffer], "report-2025.pdf", { type: "application/pdf" });
const response = await ai.files.upload({ file });
Read full post