Multi-Modal AI Analysis: Image and PDF Processing using Gemini - n8n Workflow

Explore five distinct methods in this powerful n8n workflow for analyzing images and PDFs using Google Gemini. This n8n templates guide covers direct API calls, base64 transformations, and automatic binary passthrough via specialized n8n node configurations.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI Automation Developers: Users looking for robust examples of multi-modal AI integration in n8n.
Data Engineers: Anyone needing to efficiently handle binary files (like PDFs or large images) within an n8n workflow.
n8n Specialists: Users keen to understand the differences between using the specialized LangChain n8n node and a direct HTTP Request n8n node for AI services.
Content Processors: Businesses that need to extract information or generate descriptions from uploaded documents and images using an automated n8n solution.

Overview

Processing multi-modal data—specifically images and PDFs—is crucial for modern AI automation. This sophisticated n8n workflow serves as a comprehensive demonstration, offering five distinct n8n templates for integrating with the Gemini API.

Whether you need the simplicity of automatic binary handling (Method 1), the granular control of custom prompts across multiple items (Method 2), or the precision of direct API calls involving base64 transformation for both images (Method 5) and PDFs (Method 4), this n8n workflow covers it. This solution addresses the complexity of binary file handling in an n8n environment, ensuring developers can choose the best approach for their specific performance and control requirements. Every branch uses an n8n node tailored for a different use case.

How it Works

This n8n workflow is initiated by a manual n8n trigger and immediately splits into five parallel branches, demonstrating various multi-modal analysis techniques:


  1. Simple Single Image Analysis (Method 1): An image is fetched using an HTTP Request n8n node and immediately sent to the specialized AI Agent n8n node. This approach utilizes the automatic binary passthrough feature, eliminating the need for manual data transformation.

  2. Multiple Images with Custom Prompts (Method 2): A Set n8n node defines multiple image URLs and custom prompts. A Split Out n8n node processes these items individually, and a Filter n8n node ensures only selected items are processed. Each image is fetched and passed into a Loop Over Items structure, where the AI Agent n8n node uses the item-specific prompt for analysis.

  3. Standard Item Processing via Direct API (Method 3): Multiple URLs are defined and split. Each URL is fetched, transformed into base64 format using the Extract From File n8n node, and then sent as part of a JSON payload to the Gemini API using an HTTP Request n8n node.

  4. PDF Document Analysis (Method 4): A PDF file is fetched, converted to base64, and analyzed by the Gemini API using an HTTP Request n8n node, specifying the application/pdf MIME type.

  5. Image Analysis via Direct API (Method 5): An image is fetched, converted to base64, and sent to the Gemini API using a similar HTTP Request n8n node structure as Method 4, demonstrating precise control over the API interaction.

Each n8n node is configured to retrieve the media, format it correctly (base64 or binary), and make the necessary API call to Gemini.

Installation Guide

To install and run this n8n workflow, follow these steps:


  1. Import the n8n template: Copy the entire JSON code and import it into your n8n instance via the 'Workflows' > 'New' > 'Import from JSON' option.

  2. Set up Gemini Credentials (LangChain):

You need a Google Gemini API key.
Locate the Google Gemini Chat Model n8n node (used in Methods 1 and 2). Configure a new 'Google PaLM (Gemini)' credential type using your API key.

  1. Set up Direct API Credentials (HTTP Request):

Locate the Call Gemini API1 n8n node (used in Methods 3, 4, and 5).
The workflow uses the 'HTTP Query Auth' type credential named 'Query Gemini Auth account'. Edit this credential and ensure your Gemini API key is configured as a query parameter named key.

  1. Test the n8n workflow: Click on the When clicking ‘Test workflow’ n8n trigger to run all five demonstration paths concurrently.

Node Details

This n8n workflow utilizes several key n8n node types for file handling and AI interaction:

Manual Trigger n8n trigger: The starting point for execution, allowing easy testing of this n8n template.
HTTP Request n8n node (Fetch Files): Used multiple times (e.g., Get PDF file, Get image from unsplash) to retrieve external media files from URLs into the n8n binary data structure.
Set n8n node (Define URLs And Prompts): Prepares the data payload, structuring items with image URLs and specific prompts for multi-item processing in Method 2.
Split Out n8n node: Crucial for converting arrays of data (e.g., URLs) into individual items, allowing subsequent n8n node processing on an item-by-item basis.
Extract From File n8n node (Transform to base64): Essential for Methods 3, 4, and 5. This n8n node converts the binary file data into a base64 encoded string, which is required when sending multimodal data directly through the Gemini HTTP API.
HTTP Request n8n node (Gemini API Calls): Used in Methods 3, 4, and 5 to execute custom POST requests directly to the Gemini API endpoint (generateContent), embedding the base64 data and the prompt within the JSON body.


  • AI Agent n8n node (LangChain Integration): Used in Methods 1 and 2. This specialized n8n node leverages the LangChain interface. When configured with the passthroughBinaryImages option enabled (Method 1), it simplifies image analysis tremendously, reducing the complexity of the n8n workflow.

Related n8n Workflows

Free

Nodes: 10 Nodes
Updated: December 26 2025
View all
Created by

Full Stack Developer turned AI & Automation Engineer, implementing intelligent solutions with custom code, LLMs & n8n. Use my link to book a consultation on automating your business processes.

Featured*