Upload audio to gemini using the API in java

Hi guys,

I’ve searched everywhere, I can’t seem to find any examples of being able to upload files to the gemini API in java? Does anyone know how to do this? Please also include which gradle dependency to use, which imports to have, an example of the function please

Hi @Shreekar_Puranik
You can’t upload files directly, but you can include audio in Java by Base64‑encoding it and passing it using inlineData in the JSON body of generateContent.
You can find it here.
Thank!