Large Document OCR and VLM Processing using SubworkflowAI and Gemini - n8n Workflow

Automate large document processing with this specialized n8n workflow. It uses SubworkflowAI to handle file splitting and polling, then utilizes the Google Gemini VLM for accurate OCR transcription.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation specialists needing to process documents exceeding standard AI context limits (100MB+ or thousands of pages).
Developers building robust document ingestion pipelines.
Users looking for advanced n8n templates demonstrating asynchronous job polling and multimodal AI use.
Organizations implementing document OCR via Visual Language Models (VLM).

Overview

Processing large documents often causes application memory limits or exceeds the context window of standard AI models. This powerful n8n workflow solves this by integrating with SubworkflowAI, which specializes in breaking down large files into manageable, addressable pages (Datasets and Dataset Items).

The n8n workflow first securely downloads a document from Google Drive and uploads it for extraction via the SubworkflowAI Extract API. It then uses a robust corelogicflow_control structure—an n8n polling loop—to wait for the extraction job to complete without tying up the workflow execution immediately. Once complete, the n8n workflow retrieves individual document pages (Dataset Items). Finally, these page share links are passed directly to the Google Gemini n8n node, enabling efficient Visual Language Model (VLM) OCR transcription without requiring memory-intensive binary file downloads within the n8n environment itself. This approach makes this one of the most efficient n8n templates for handling massive document loads.

How it Works

This comprehensive n8n workflow operates in six stages:


  1. Initiation and Download: The process starts via a manual n8n trigger (When clicking ‘Execute workflow’). The Google Drive n8n node downloads the target large document.

  2. File Upload: The file is immediately uploaded to SubworkflowAI using an HTTP Request n8n node targeting the Extract API. This initiates an asynchronous processing job and returns a job ID.

  3. Job Polling Loop: A complex corelogicflowcontrol loop is initiated. The Job Complete? If n8n node checks the job status. If the status is 'INPROGRESS', the workflow polls the Check Job Status endpoint, waits 1 second using the Wait n8n node, and loops back to check the status again. This polling continues until the status is 'SUCCESS' or 'ERROR'.

  4. Dataset Retrieval: Once successful, the n8n workflow retrieves the resulting Dataset and then fetches the individual Dataset Items (document pages) using pagination (fetching 10 items per request, up to 5 times) to efficiently handle high page counts.

  5. Splitting Items: The Split Out n8n node ensures that each page (Dataset Item) is processed as a separate item in the n8n workflow stream.

  6. VLM OCR: The final action uses the Google Gemini n8n node (VLM). It leverages the public 'Share link' provided by SubworkflowAI for the page image, instructing Gemini to 'Transcribe this image to Markdown'. This performs high-accuracy OCR on every page, completing the automated n8n workflow.

Installation Guide

To use this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON and import it directly into your n8n instance as a new n8n workflow.

  2. Google Drive Credentials: Set up credentials for the Google Drive n8n node to allow file download access.

  3. SubworkflowAI Credentials: Obtain an API key from SubworkflowAI. Configure an HTTP Header Authentication credential in n8n and link it to the HTTP Request n8n node steps (Extract API, Check Job Status, Get Dataset, Get Dataset Items).

  4. Google Gemini Credentials: Configure a credential for the Google Gemini (PaLM) n8n node.

  5. Customization: Update the Download file n8n node with the File ID of the specific large document you wish to process.

  6. Activation: Save the n8n workflow and execute it.

Node Details

When clicking ‘Execute workflow’ (Manual Trigger): Serves as the initial n8n trigger to start the process manually.
Download file (Google Drive n8n node): Downloads the specified large binary file from Google Drive to the local n8n instance for temporary handling.
Extract API (HTTP Request n8n node): Uploads the binary document to https://api.subworkflow.ai/v1/extract using multipart-form-data. This is the first step in the SubworkflowAI document processing pipeline.
Job Complete? (If n8n node): The crucial corelogicflow_control component. It checks the status property (SUCCESS or ERROR) to determine if the processing loop should terminate or continue polling.
Check Job Status (HTTP Request n8n node): Used inside the polling loop to retrieve the current status of the asynchronous SubworkflowAI job.
Wait (n8n node): Introduces a 1-second delay in the polling loop to prevent API rate limiting.
Get Dataset Items (HTTP Request n8n node): Fetches individual page records using complex pagination settings, allowing the n8n workflow to handle documents with potentially thousands of pages by retrieving them in batches.
Split Out (n8n node): Prepares the fetched dataset items so that the subsequent VLM steps process one page at a time.


  • Document OCR via VLM (Google Gemini n8n node): The final processing step. It uses the models/gemini-2.5-flash model and the secure share URL provided by SubworkflowAI to perform image transcription (OCR), transforming the document page into Markdown text.

Related n8n Workflows

Free

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

Freelance AI Automation Engineer based in London, UK. Since 2024, my n8n templates have documented my journey into applied AI and have helped hundreds of businesses and organisations get up to speed with AI automation. Today, I continue to explore use-cases as AI evolves and occasionally upload templates which I find novel and interesting. Subscribe to the RSS Feed: https://cdn.subworkflow.ai/n8n-templates/rss.xml

Featured*