# How to use the Gemini API with a PDF?

**URL:** <https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896>\
**Category:** Gemini API\
**Created:** [May 19, 2024, 7:05pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896 "2024-05-19T19:05:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kazu\_Rms](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/kazu_rms/32/2762_2.png) [@Kazu\_Rms](https://discuss.ai.google.dev/u/Kazu_Rms)\
**Post date:** [May 19, 2024, 7:05pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/1 "2024-05-19T19:05:48Z")

</div>

how to use the Gemini API with a PDF?

---

<div class="post-metadata">

**Author:** ![Logan\_Kilpatrick](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/logan_kilpatrick/32/129_2.png) [@Logan\_Kilpatrick](https://discuss.ai.google.dev/u/Logan_Kilpatrick)\
**Post date:** [May 19, 2024, 7:17pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/2 "2024-05-19T19:17:33Z")

</div>

Hey @Kazu_Rms, you can start by doing this in [https://aistudio.google.com](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](https://github.com/google-gemini/cookbook/blob/main/quickstarts/PDF_Files.ipynb)

---

<div class="post-metadata">

**Author:** ![John\_Fiewor](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/john_fiewor/32/5243_2.png) [@John\_Fiewor](https://discuss.ai.google.dev/u/John_Fiewor)\
**Post date:** [June 21, 2024, 11:30pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/3 "2024-06-21T23:30:28Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afirstenberg](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/afirstenberg/32/202_2.png) [@afirstenberg](https://discuss.ai.google.dev/u/afirstenberg)\
**Post date:** [June 21, 2024, 11:59pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/4 "2024-06-21T23:59:07Z")

</div>

Check out the cookbook at [cookbook/quickstarts/file-api at main · google-gemini/cookbook · GitHub](https://github.com/google-gemini/cookbook/tree/main/quickstarts/file-api) which has an example for Node.js.

---

<div class="post-metadata">

**Author:** ![John\_Fiewor](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/john_fiewor/32/5243_2.png) [@John\_Fiewor](https://discuss.ai.google.dev/u/John_Fiewor)\
**Post date:** [June 22, 2024, 9:10am UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/5 "2024-06-22T09:10:55Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![afirstenberg](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/afirstenberg/32/202_2.png) [@afirstenberg](https://discuss.ai.google.dev/u/afirstenberg)\
**Post date:** [June 22, 2024, 2:07pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/6 "2024-06-22T14:07:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Ron\_Parker](https://d1dlmcr85iqnpo.cloudfront.net/user_avatar/discuss.ai.google.dev/ron_parker/32/5412_2.png) [@Ron\_Parker](https://discuss.ai.google.dev/u/Ron_Parker)\
**Post date:** [July 4, 2024, 7:12pm UTC](https://discuss.ai.google.dev/t/how-to-use-the-gemini-api-with-a-pdf/2896/7 "2024-07-04T19:12:43Z")

</div>

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.

> **[Process a PDF file with Gemini  |  Generative AI on Vertex AI...](https://cloud.google.com/vertex-ai/generative-ai/docs/samples/generativeaionvertexai-gemini-pdf#generativeaionvertexai_gemini_pdf-nodejs)**
>
> This sample shows you how to process a PDF document using Gemini.

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