Prompt

How do I send documents to an OCR API in batches?

Artificial Intelligence / Computer Vision1 observationLast seen Oct 11, 2026

Latest observation

Oct 11, 2026OpenAI APIWeb search: off

To send documents to an OCR API in batches, you usually want to:

  1. Collect documents into a list
  2. Split them into smaller chunks (batch size)
  3. Send each batch to the API
  4. Handle retries, rate limits, and failures
  5. Combine the results

Basic approach

1) Group documents

If you have many files, organize them into batches of, say, 10–50 documents each depending on the API limits.

2) Send one batch per request

Many OCR APIs accept either:

  • multiple files in one multipart request, or
  • a JSON payload containing file URLs/base64 content, or
  • one file per request but support parallelization

Check the API docs for:

  • maximum files per request
  • maximum file size
  • supported file types
  • async vs sync processing

3) Example workflow

import requests
from itertools import islice

def chunked(iterable, size):
    it = iter(iterable)
    while batch := list(islice(it, size)):
        yield batch

documents = [
    "doc1.pdf",
    "doc2.pdf",
    "doc3.pdf",
    "doc4.pdf",
]

API_URL = "https://example.com/ocr"

for batch in chunked(documents, 2):
    files = []
    for path in batch:
        files.append(("files", open(path, "rb")))

    response = requests.post(API_URL, files=files)
    response.raise_for_status()
    print(response.json())

If the API uses file URLs instead of uploads

Some OCR services prefer you upload files to storage first, then send URLs:

payload = {
    "documents": [
        {"url": "https://storage.example.com/doc1.pdf"},
        {"url": "https://storage.example.com/doc2.pdf"}
    ]
}
response = requests.post(API_URL, json=payload)

Best practices

  • Respect rate limits: add delays or concurrency control.
  • Use async jobs for large PDFs or many documents.
  • Track results by document ID so responses map back correctly.
  • Retry transient errors like 429/500 with exponential backoff.
  • Validate inputs before sending.

If you’re using multiprocessing or async

You can send multiple batches in parallel, but cap concurrency:

  • 2–5 concurrent requests for moderate APIs
  • more only if the API explicitly allows it

Recommended pattern

  • Pre-upload large files to object storage
  • Send OCR API a batch of URLs
  • Poll for completion if processing is asynchronous

If you want, I can show:

  • a Python example with retries and batching
  • a Node.js version
  • or a version tailored to a specific OCR API like Google Vision, Azure OCR, AWS Textract, or OpenAI vision-based OCR.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (1 observation for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.