Send a PDF to the Perplexity Agent API

Use the native document route, check model and privacy constraints before sending, and verify the answer against the PDF before adding more files.

PDF document and blue connector on a porcelain desk beside a laptop

Send a PDF to Perplexity’s Agent API as an input_file part inside a user message. Use file_data for a base64-encoded local file or file_url for a public HTTPS document, then check the answer against the original PDF. The selected model must support that document source, and document inputs can’t be combined with browser tools.

I’d start with one non-sensitive PDF and a question whose answer you can locate yourself. That makes a missing paragraph, wrong table column or unsupported claim easier to catch before you build a longer document workflow.

Check the document and account before sending

This is the developer API workflow. Upload allowances in the Perplexity chat app, Spaces and consumer subscriptions don’t establish the API’s limits.

You’ll need an API key available only to your server or private runtime, an API account able to make paid requests, and a model/provider combination that accepts PDF input. Keep the key out of browser code, source control and screenshots. The native document contract recognizes PDF, DOC, DOCX, UTF-8 TXT and RTF, but support varies by model and input source. Recognized format doesn’t mean every model accepts it.

Check permission to send the document before encoding it. Perplexity’s API privacy rules say customer content isn’t used for generative-model training by default under the API terms, subject to product-specific terms. That doesn’t mean zero retention. Zero Data Retention requires an eligible account configuration and written agreement, and native document inputs are unavailable under ZDR. Third-party model providers’ terms also apply.

For a document-only question, choose a compatible model explicitly and omit unnecessary tools. You don’t need sandbox or file_search to send a native document. Browser tools are unavailable with document inputs and with continuations that inherit documents. An effort setting that enables a browser tool can create the same conflict.

Send one PDF in the user message

Use POST /v1/agent on api.perplexity.ai; /v1/responses is an alias. Start from the official local-file HTTP example for your language. Set PERPLEXITY_API_KEY in your private runtime and send it as a Bearer token over HTTPS. The fields below describe that documented request structure.

  1. Choose the model. Check the example’s model ID against the current Agent API model catalog and confirm that model’s PDF and source support. A working text-file example alone doesn’t establish PDF compatibility.
  2. Put the question in an input_text part. Ask for a narrow answer, the supporting section or page where available, and a short quotation you can find in the PDF. Tell the model to identify missing information rather than fill the gap.
  3. Add an input_file part to the same user message. For a local PDF, base64-encode the file’s bytes into file_data. Standard base64 and a base64 data URI are accepted. Don’t read binary PDF bytes as ordinary text.
  4. Check the filename. filename is optional, but a supplied name such as report.pdf should describe PDF content. The resulting basename, including an automatically added extension, must fit within 255 UTF-8 bytes. A conflicting extension or data-URI media type returns HTTP 400.
  5. Send exactly one source field. Use either file_data or file_url, never both. Keep the original PDF available for the answer check.
Send a document block with input_file in a user message and the file_data or file_url choice
Put the document in the user message and choose exactly one source field. On a narrow screen, scroll the detail horizontally to read it.

For a remote document, replace the inline data with file_url. The URL must be public HTTPS on port 443, with no embedded credentials or fragment. Without a filename, URL input defaults to PDF; for another supported format, provide a matching filename. The provider retrieves the file, and the API doesn’t verify its contents in advance. An initially accepted request can still fail during retrieval or parsing.

I’d use inline data for a private document that you’re authorized to send, rather than make that document public just to obtain a URL. A public report that already has a stable HTTPS address may suit the URL route.

Check the combined limits before a larger request

The Agent API’s document limits apply across the active request, including inherited document context. Provider-specific size, page-count and context limits can be lower.

LimitWhat to check
30 document partsCount new documents and documents inherited through a continuation.
50 MiB decoded inline bytes combinedAdd the original byte sizes of inline files. This isn’t a separate 50 MiB allowance for each PDF.
72 MiB complete JSON bodyInclude base64 expansion, the prompt and every other field.
Provider limitsA request inside these API budgets can still exceed the selected provider’s limits.

Two 30 MiB inline PDFs total 60 MiB, so they exceed the combined 50 MiB budget even though neither file reaches 50 MiB. Base64 also adds roughly one third to the encoded size: a 45 MiB file becomes about 60 MiB before the surrounding JSON. These are size calculations, not an allowance to exceed a provider’s smaller limit.

Native document input doesn’t support a reusable file_id. Uploading a JSONL batch request file is a separate operation, and listing files produced by the agent is an output workflow. Neither replaces the PDF’s input_file part.

Check completion, then check the evidence

First inspect the response’s status. The official Document Q&A example checks for completed before reading the answer. With raw HTTP, inspect output[] for a message and its output_text content parts. The SDK exposes output_text as a convenience; don’t assume a raw response has the old Chat Completions choices layout.

Completion only tells you the request finished. Find the quoted passage in the PDF and compare the claim with the surrounding paragraph or table. Check dates, units, footnotes and whether a number belongs to the right row. A page label in an answer still needs that check. If the passage doesn’t support the answer, narrow the question and request the specific supporting text before using the claim.

For a scanned page or complex table, confirm that the answer includes the content you need. Don’t assume an accepted PDF guarantees complete recognition. If you send extracted text instead, check that extraction preserves headings, table relationships and the relevant pages.

The cookbook also contains a separate local-text workflow with optional web enrichment. That workflow reads text and truncates large files; it doesn’t parse a binary PDF. Don’t carry its optional search configuration or truncation behavior into the native-PDF route unnoticed. Keep external research separate when you need to distinguish what the PDF says from what another source says.

Continue the conversation or fix the failed request

For inline documents, pass the first response’s id as previous_response_id under the same API project to ask a follow-up without resending the file. The next model must support all inherited documents, and the combined limits still apply. Inline documents remain available for the original response’s retention period, up to 30 days; follow-ups don’t restart that clock. After deletion or expiry, resend the file in a new conversation. A URL-based document must remain accessible for follow-ups.

If the request fails, check the branch that matches the failure before retrying:

  • HTTP 400 before output: check model/source compatibility, conflicting source fields, filename/media type, combined limits, ZDR and browser-tool settings. Resending the same invalid payload won’t correct those conditions.
  • Retrieval or parsing failure: check whether the provider can reach the public URL, follow its redirects and parse the actual document format. A browser session that opens the link doesn’t establish public provider access.
  • Completed but incomplete answer: compare the relevant pages with the response, narrow the question and check extraction. A larger output allowance can’t restore document content that never reached the model.

Budget from the selected model’s token rates and any enabled tool fees; PDF megabytes don’t establish a flat question price. Inspect usage on a representative document and compare the estimate with Billing. Start by verifying one answer against its source passage, then expand the document set once that check works for your task.