Document and Image Ingestion: File Formats, OCR, and API Limits
Which file and image types AI search and agent APIs accept, how OCR and uploads work, and size limits across major providers.
Most of this page draws on Cloudflare AI Search for indexing documents and images into a searchable corpus, and on the Perplexity Agent API for in-request document Q&A and image analysis. Cloudflare Workers AI adds a separate path: vision models that query, caption, point at, or detect objects in an image at inference time. If you are deciding how to ship PDFs, scans, or photos into an AI product, the binding constraints are usually format, size, text vs scan (OCR), and inline bytes vs public URL.
Supported file types: plain text, rich documents, and images
Section titled “Supported file types: plain text, rich documents, and images”What Cloudflare AI Search can index
Section titled “What Cloudflare AI Search can index”AI Search data source documentation states that ingestion covers both plain-text-style files and rich formats:
AI Search can ingest a variety of file types. The following plain text files and rich format files are supported.
Plain-text ingestion includes common source and config types (for example *.md, *.json, *.py, *.yaml, *.env, and many others listed in Plain text file types). Rich formats are converted toward Markdown for indexing; oversized or unsupported files are skipped and show up in error logs (see File limits).
For images, the same page lists:
AI Search supports .jpg, .jpeg, .png, .webp, .gif, .bmp, .tif, .tiff, .heic, and .heif images.
Multimodal embedding models embed supported images directly; text-only embedding models caption images before embedding (Images and optical character recognition).
What the Perplexity Agent API accepts as documents
Section titled “What the Perplexity Agent API accepts as documents”Working with Files describes native document parts on POST /v1/agent (and the /v1/responses alias): add an input_file part with exactly one of file_data or file_url. Recognized types include PDF, DOC, DOCX, UTF-8 TXT, and RTF, but supported combinations depend on the chosen model and provider; unsupported pairs return HTTP 400 before streaming starts.
The October 2026 Perplexity changelog mirrors that set for Agent API file input:
The Agent API now accepts PDF, DOC, DOCX, TXT, and RTF documents as input_file content. Send a document inline with file_data or provide a public HTTPS file_url.
Legacy Sonar media attachments document the same document MIME families with a 50 MB per file cap and up to 30 files per request—limits that differ from the Agent API’s combined inline budget (see below).
Image formats for vision requests
Section titled “Image formats for vision requests”Image Attachments for the Agent API:
Supported formats for base64 encoded images: PNG (image/png), JPEG (image/jpeg), WEBP (image/webp), and GIF (image/gif).
Image analysis examples note that animated GIFs are accepted but only the first frame is analyzed, and that vision requires a vision-capable model (not every model supports input_image).
File size limits: indexing vs inline API upload
Section titled “File size limits: indexing vs inline API upload”Limits differ by product and by whether the file is indexed once or sent with every request.
| Context | Plain text / code | PDF (text layer) | PDF (scan / needs OCR) | Other rich formats | Images (inline) |
|---|---|---|---|---|---|
| Cloudflare AI Search (limits, data source) | 10 MiB | 4 MiB without OCR | 10 MiB with OCR enabled | 4 MiB (converted to Markdown) | Supported types per data source; OCR billed separately |
| Cloudflare Workers binding upload (Workers binding) | Up to 10 MiB | > 4 MiB indexed only if OCR enabled | Same | Up to 4 MiB | (via file item rules) |
| Perplexity Agent API (Working with Files) | Part of 50 MiB combined inline decode | Native input_file |
Native (provider may parse) | Same | 50 MB per image (base64) |
| Perplexity Sonar (legacy) (Media & Attachments) | 50 MB per file | 50 MB per file | — | Same | 50 MB per image |
Cloudflare’s platform limits table (Limits & pricing) also caps files per instance (100,000 on paid Workers, with hybrid-search variants), metadata (5 custom fields per instance; filterable strings use the first 64 UTF-8 bytes), and website crawl volume—relevant when the “document” is really a crawled site rather than an upload.
For Agent API continuation, Working with Files documents:
Document parts — 30, including documents inherited by a continuation
Inline document bytes — 50 MiB combined after base64 decoding
Complete JSON request body — 72 MiB
Use previous_response_id to ask follow-ups without resending inline bytes; inherited documents stay available for the original response retention period (up to 30 days).
Migrate from Sonar summarizes the content-part rename: Sonar file_url / pdf_url maps to Agent input_file with file_data or HTTPS file_url, with 30 active files and 50 MiB combined for native input rather than Sonar’s per-file allowance.
OCR for scanned PDFs and images (AI Search)
Section titled “OCR for scanned PDFs and images (AI Search)”OCR is a Cloudflare AI Search indexing feature, not a Perplexity Agent API switch in this cluster.
From Images and optical character recognition:
Optical character recognition (OCR) extracts text from scanned PDFs and images. Set indexing_options.use_ocr to true when creating or updating an instance. OCR is disabled by default and changing this setting triggers a full reindex.
OCR is available for every account. OCR usage is billed as image-processing ingestion tokens.
Changelog entries (for example AI Search is generally available) repeat the size trade-off:
Optical character recognition (OCR) is available on every account for scanned PDFs. Plain-text or code files and PDFs with OCR enabled can be up to 10 MiB. PDFs without OCR and other supported formats remain limited to 4 MiB.
If you upload large PDFs through the Workers binding, the same rule applies: PDFs above 4 MiB are indexed only when OCR is enabled.
Sending images in search and chat requests
Section titled “Sending images in search and chat requests”Image queries in Cloudflare AI Search
Section titled “Image queries in Cloudflare AI Search”Both the REST API and public endpoint accept an image_url part over HTTPS or as data:image/<subtype>;base64,...:
Set messages[].content to an array containing an image_url part. The URL must use HTTPS or an inline
data:image/<subtype>;base64,...URI.
The response includes query_kind as image. Image-only responses omit search_query. Add a text part for a multimodal query. Native image embedding requires @cf/qwen/qwen3-vl-embedding-2b or google-ai-studio/gemini-embedding-2b. Text-only embedding models caption the image before embedding it.
So image search quality depends on picking a multimodal embedding model; otherwise you are searching text derived from an auto-caption.
Image attachments in the Perplexity Agent API
Section titled “Image attachments in the Perplexity Agent API”Per Image Attachments, each user message can mix input_text and input_image; image_url accepts either a public HTTPS URL (the service fetches it) or a data URI. Base64 payloads are capped at 50 MB per image.
For a two-step “identify then research” pattern, see Image Analysis: first call with input_image, second call with web_search tool enabled—Step 2 quality depends on Step 1 labels.
Workers AI vision (Moondream): query, caption, point, detect
Section titled “Workers AI vision (Moondream): query, caption, point, detect”Moondream 3.1 on Workers AI documents four image operations:
Query — ask open-ended questions about an image, with an optional reasoning parameter
Caption — generate short, normal, or long descriptions of an image
Point — return coordinates for objects matching a target phrase
Detect — return bounding boxes for objects matching a target phrase
Use this path when you need structured coordinates or boxes at inference time, rather than retrieving chunks from an AI Search index.
Perplexity Decisions API: images in state
Section titled “Perplexity Decisions API: images in state”Decisions API quickstart uses OpenAI-style image_url parts inside state, with stricter rules than Agent image chat:
The API never fetches a URL: an http or https image URL returns 400.
Up to 8 images per question. More returns 400.
PNG, JPEG, and WebP data URLs are accepted.
Images are read in 32 × 32 tiles; keep ((width/32) × (height/32) ≤ 2048) or the request may hang and return 504. Image tokens count toward usage.input_tokens (roughly ~1,000 input tokens per megapixel in their earlier tests).
Document Q&A workflows and common mistakes
Section titled “Document Q&A workflows and common mistakes”Native document input vs pasted text
Section titled “Native document input vs pasted text”Document Q&A contrasts two patterns:
- Native
input_file(PDF, Office, TXT, etc.)—handled by the model pipeline; use Working with Files forfile_urlon a public HTTPS URL without credentials or fragments (port 443). - Local text extraction—read
*.txt,*.csv,*.md,*.jsonyourself; the cookbook default truncates at 50,000 characters (~12,500 tokens) and does not parse binary PDF/Office without a library.
Multi-turn Q&A in the cookbook does not re-read the file; the document text must appear in the first turn (or you rely on previous_response_id with Agent native files).
Mistakes that cause 400s, failed indexing, or silent skips
Section titled “Mistakes that cause 400s, failed indexing, or silent skips”| Mistake | What goes wrong |
|---|---|
| Large scan PDF in AI Search without OCR | File stays at 4 MiB cap or fails indexing (data source) |
| Enabling OCR casually | Full reindex + OCR token charges |
| HTTPS image URL on Decisions API | 400—must use data URLs (Decisions quickstart) |
Private or non-direct file_url / image URL |
Fetch or parse fails (Perplexity URL docs; image analysis limitations) |
Model without input_image / wrong embedding model |
Request rejected or image-only search lacks true multimodal behavior |
| Documents + browser tools on Agent API | HTTP 400 (Working with Files) |
| Oversized Agent JSON body | Exceeds 72 MiB total request limit |
How to check this on your site
Section titled “How to check this on your site”- For Cloudflare AI Search, confirm each uploaded or crawled file type and size against File limits and Limits & pricing; inspect instance error logs for rejected files.
- If you use scanned PDFs or image-heavy sources, verify
indexing_options.use_ocrand expect a full reindex after changes (Images and optical character recognition). - Run a test image query against your instance via the REST API or public endpoint and confirm
query_kindand that your embedding model matches multimodal vs caption-only behavior. - For Perplexity Agent API, send a small
input_fileandinput_imagerequest per Working with Files and Image Attachments; confirmstatus: "completed"and testprevious_response_idwithout resending the file. - You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match the linked documentation or your live API behavior, write to yimasynthetic@gmail.com with the page URL and the exact statement you believe is wrong.