# Extract PDF content using Gemini

**URL:** <https://community.n8n.io/t/extract-pdf-content-using-gemini/74669>\
**Category:** Questions\
**Created:** [February 3, 2025, 4:52pm UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669 "2025-02-03T16:52:36Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![herskind\_uk](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/herskind_uk/32/55240_2.png) [@herskind\_uk](https://community.n8n.io/u/herskind_uk)\
**Post date:** [February 3, 2025, 4:52pm UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669/1 "2025-02-03T16:52:37Z")

</div>

## Problem/question

What node can be used if I want to ask Gemini to extract text from a PDF? I tried the Basic LLM Chain with a binary image prompt - but it does like PDFs (I seems biased towards images).

## Error message

Bad request - please check your parameters

[GoogleGenerativeAI Error]: Error fetching from [https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent:](https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-pro-latest:generateContent:) [400 Bad Request] Provided image is not valid."

## Information on your n8n setup

- n8n version: 1.75.2,
- Database (default: SQLite): Postgres
- n8n EXECUTIONS\_PROCESS setting (default: own, main): ?
- Running n8n via (Docker, npm, n8n cloud, desktop app): Docker
- Operating system: Linux

---

<div class="post-metadata">

**Author:** ![herskind\_uk](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/herskind_uk/32/55240_2.png) [@herskind\_uk](https://community.n8n.io/u/herskind_uk)\
**Post date:** [February 3, 2025, 5:33pm UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669/2 "2025-02-03T17:33:59Z")

</div>

The quick-and-dirty workaround (please tell me there is a way to do this with nodes… it’s so wrong):

```auto
const { GoogleGenerativeAI } = require("@google/generative-ai");

const genAI = new GoogleGenerativeAI( **APIKEY** );
const model = genAI.getGenerativeModel({ model: "gemini-1.5-pro-latest" });

const result = await model.generateContent([
    {
        inlineData: {
            data: $input.first().binary.data.data,
            mimeType: "application/pdf",
        },
    },
    'Extract content from this document',
]);

return [{response: result.response.text()}]

```

---

<div class="post-metadata">

**Author:** ![physx911](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/physx911/32/23837_2.png) [@physx911](https://community.n8n.io/u/physx911)\
**Post date:** [February 6, 2025, 1:41am UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669/3 "2025-02-06T01:41:54Z")

</div>

It’s a bummer that the basic AI chain only supports image as in input. I was really excited to try Gemini Flash 2 for extracting/OCR PDF to structured outputs until I found n8n can only upload Image to a LLM model.

---

<div class="post-metadata">

**Author:** ![felixvemmer](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/felixvemmer/32/54761_2.png) [@felixvemmer](https://community.n8n.io/u/felixvemmer)\
**Post date:** [February 6, 2025, 8:39am UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669/4 "2025-02-06T08:39:29Z")

</div>

@herskind_uk I built a custom n8n node that just does this. Here’s also a [youtube demo](https://youtu.be/rgpKD7BZHc8?si=t4ytl2PnZK_hwRzt&t=396) of the functionality.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [May 7, 2025, 8:39am UTC](https://community.n8n.io/t/extract-pdf-content-using-gemini/74669/5 "2025-05-07T08:39:55Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
