How to use the Gemini API with a PDF?

how to use the Gemini API with a PDF?

Hey @Kazu_Rms, you can start by doing this in https://aistudio.google.com, and then when you want to move to code, you can follow this cookbook: cookbook/quickstarts/PDF_Files.ipynb at main · google-gemini/cookbook · GitHub

1 Like

this seems like a python approach. Please how can i work with PDFs using Nodejs?

Check out the cookbook at cookbook/quickstarts/file-api at main · google-gemini/cookbook · GitHub which has an example for Node.js.

I’ve checked and the example is for an image, not a PDF

Sending an image or PDF through the File API should be the same.

1 Like

Here is the code I got to work. I used the Python version, but I would imagine that the Node.js version will work the same.

FYI, this is Vertex AI API. Google Studio AI API PDF file upload still is not working.

1 Like