How to Chat with All Your PDFs Using the PDF.ai API
Publish date
Oct 10, 2026
AI summary
The chat‑all endpoint lets you send a single message to the PDF.ai API and receive an answer that draws from all PDFs in your library, with references to each source document and page; you must have at least one uploaded PDF, can filter by tags, control the number of matches, optionally save the chat, and choose models or language, while handling authentication, credit usage, and error responses.
Language
People look up a way to chat with all their PDFs through an API when one document is not the unit of work anymore. A support bot has to answer from a whole manual set. An internal tool has to search every contract a team uploaded. Sending the same question to each
docId one by one does not scale, and you still have to merge the answers yourself.This page is the one message → answer across your library path on the PDF.ai API v1 chat-all endpoint. It does not replace the API Hub (keys and plan live there). It does not re-rank the head term pdf api. For questions about one file, see How to Use the PDF.ai Chat API. To get documents into the library first, see How to Use the PDF.ai Upload API.
What chat-all is for
After a clean chat-all call on the PDF.ai API v1, three things should be true:
- You sent a
messagewith yourX-API-Key, and nodocId
- The response includes a
contentstring with the answer
- The response includes
references, and each one names thedocId,pageNumber, line range, andurlit came from
Docs: Chat with all PDFs, Upload PDF, Update tags for an uploaded PDF, Get all documents, API limits.
Practical rule: chat-all needs at least one PDF uploaded through the v1 upload endpoint. It searches what you uploaded, not the open web.
The request at a glance
From Chat with all PDFs:
Field | Required | What it does |
X-API-Key (header) | Yes | Your API key from the developer hub |
message | Yes | The question you want answered from your PDFs |
tag | No | Only consider documents with this tag, e.g. "Books" |
topMatches | No | Max number of best-matched documents used to answer. Default: 10 |
save_chat | No | Boolean. Save the chat-all history |
use_gpt4 | No | Boolean. Get the response from a GPT-4 model (default model: gpt-4-turbo) |
model | No | Pick the GPT-4 model: "gpt-4o" or "gpt-4-turbo" (default) |
language | No | Response language, e.g. "french" |
sys_prompt | No | Your own system prompt |
Endpoint:
POST https://pdf.ai/api/v1/chat-all. A successful response is JSON with content and a references array.How to call chat-all
1. Have an API key
Open https://pdf.ai/developer, generate a key, and store it as a secret. Send it as the
X-API-Key header on every call.2. Upload your PDFs with tags
Tags are how you keep one library from bleeding into another. The v1 upload endpoints accept a
tags array next to the file:- By URL:
POST https://pdf.ai/api/v1/upload/urlwithurlandtags(300-second timeout)
- By file:
POST https://pdf.ai/api/v1/upload/filewithfileandtags(300-second timeout, 4.5 MB file limit)
import requests
headers = {"X-API-Key": "YOUR_API_KEY"}
response = requests.post(
"https://pdf.ai/api/v1/upload/url",
headers=headers,
json={
"url": "https://example.com/handbook.pdf",
"tags": ["HR"]
}
)
print(response.json()) # {"docId": "..."}If the PDF is a scan, upload with
ocr on so the text is searchable. The full upload walkthrough is in How to Use the PDF.ai Upload API.3. Fix tags you forgot
If a document went in without tags, set them afterwards with
POST https://pdf.ai/api/v1/tags. Send the docId and the full list of tags you want. The list replaces the old one, and an empty array [] removes all tags. The docs say this endpoint does not consume API credits.import requests
response = requests.post(
"https://pdf.ai/api/v1/tags",
headers={"X-API-Key": "YOUR_API_KEY"},
json={"docId": "YOUR_DOC_ID", "tags": ["HR", "Policies"]}
)
print(response.json()) # {"message": "Successfully updated tags!"}To see which documents you have,
GET https://pdf.ai/api/v1/documents returns each document's id (the docId), name, size, isPublic, uploadedAt, url, and importUrl.4. Example: ask across one tagged set
import requests
url = "https://pdf.ai/api/v1/chat-all"
headers = {
"X-API-Key": "YOUR_API_KEY",
"Content-Type": "application/json"
}
data = {
"message": "How many vacation days do new employees get?",
"tag": "HR",
"topMatches": 5
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result["content"])
for ref in result["references"]:
print(ref["docId"], ref["pageNumber"], ref["fromLine"], ref["toLine"])The same call with cURL:
curl -X POST https://pdf.ai/api/v1/chat-all \
-H "X-API-Key: YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"message": "How many vacation days do new employees get?", "tag": "HR", "topMatches": 5}'5. Read the references, not only the answer
Each item in
references carries docId, pageNumber, fromLine, toLine, and url. Across a library, that is the part your users need: which document and which page the answer came from. Show it next to the answer, or link to the source PDF with url.Practical rule: if the answer cites documents you did not expect, narrow the call withtagbefore you change the prompt. A smaller, cleaner set usually beats a cleverersys_prompt.
6. Handle the documented errors
The chat-all page lists these responses:
- 200 —
contentplusreferences
- 401 —
{"error": "Invalid API key"}: fix the key or header before you touch the request body
- 400 — e.g.
{"error": "No API key present"}: the API key ormessageis missing
Saving chat-all history
Set
save_chat to true to keep the conversation. The docs say saved chat-all history shows up at PDF.ai/documents/chat/all. The separate history endpoint (POST https://pdf.ai/api/v1/history) is documented per document and takes a docId, so plan to store chat-all answers in your own database if your product needs to read them back by API.Credits and limits before you scale
The chat-all page prices the GPT-4 options directly: a gpt-4o message costs 2 credits and a gpt-4-turbo message costs 4 credits. On the Dedicated API plan, API limits also lists 2 credits per file upload, 1 credit per gpt-3.5-turbo or gpt-4o-mini message, and a rate limit of 500 requests/minute.
Run a few test questions and check your usage on https://pdf.ai/developer before you point a whole support bot at chat-all. For the full credit picture across v1 and v2, see How to Understand PDF.ai API Credit Usage.
When chat-all is the wrong tool
- You already know which file holds the answer. Use Chat with one
docId(How to Use the PDF.ai Chat API). It skips the library search.
- You want one summary per document. Use Summarize (How to Use the PDF.ai Summarize API).
- You work on v2 parsed documents. Ask (
POST https://pdf.ai/api/v2/ask) takes apromptand one or more parseddocIds(How to Use the PDF.ai Ask API). Do not assume a v1 uploaddocIdworks there without checking.
- You need named fields as JSON, not prose. Use
POST /v2/extractwith a schema (How to Use the PDF.ai Extract API).
- You wanted a generic "pdf api" hub. Stay on https://pdf.ai/developer. This page is the chat-all how-to, not a replacement hub.
A short action plan
- Open https://pdf.ai/developer, create a key, store it once.
- Upload your PDFs through v1 with
tags(OCR on for scans). Fix missing tags with/v1/tags.
POST https://pdf.ai/api/v1/chat-allwithmessage, plustagandtopMatchesto keep the search tight.
- Show
referencesnext to every answer, spot-check a few against the source pages, then scale.
Sibling guides: How to Get Started with the PDF.ai API, How to Use the PDF.ai Upload API, How to Use the PDF.ai Chat API, How to Understand PDF.ai API Credit Usage.
If you want the rest of the PDF workflow, start at PDF.ai. Use chat-all when the question belongs to your whole library, not to one file.