Page Search API
Find the pages that answer your questions, each with its relevance, and send them to your own LLM. Or find first which documents answer.
For the concepts, see the Page Search quick start.
Upload a document to search
POST /doc with algorithm=none · WRITE key
Upload with Upload a document and algorithm=none: the pages are stored without a tree, at $0.10 per 1,000 pages.
curl https://api.pageindex.ai/doc \
-H "api_key: $PAGEINDEX_API_KEY" \
-F "file=@10-K-2023.pdf" \
-F "algorithm=none" \
-F "wait=60"
{
"doc_id": "pi-cm3k9x2qv0001l50856dh4a2f",
"name": "10-K-2023.pdf",
"status": "completed"
}
A document can be searched once its status is completed. Pass wait, or poll Get a document's tree.
A document uploaded with outline or flash can be searched too.
SDK: Python PageSearchClient.upload().
Search a document's pages
POST /doc/{doc_id}/page-search · READ key
Judges every page of a document against each question, and lists the pages that help answer it, most relevant first.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
doc_id | string (path) | Yes | The document's id. | |
questions | array (JSON) | Yes | 1 to 10 questions, each 1 to 2,000 characters. | |
top_k | integer (JSON) | No | List exactly this many pages for each question, 1 to 1,000. | |
include_text | boolean (JSON) | No | false | Give each listed page's text. |
start_page | integer (JSON) | No | 1 | The first page to search. |
end_page | integer (JSON) | No | last page | The last page to search, included. A search covers up to 5,000 pages. |
Each question lists the pages likely to help. That is pages of relevance 0.3 or more; when fewer than 3 are, and none is 0.5 or more, pages of 0.2 or more.
curl https://api.pageindex.ai/doc/pi-cm3k9x2qv0001l50856dh4a2f/page-search \
-H "api_key: $PAGEINDEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"questions": ["What was capital expenditure in 2023?"], "start_page": 30, "end_page": 60}'
{
"id": "srch_4f9c2a7e1b3d5f6a8c0e2b4d",
"doc_id": "pi-cm3k9x2qv0001l50856dh4a2f",
"results": [
{
"question": "What was capital expenditure in 2023?",
"pages": [
{ "page": 42, "relevance": 0.9, "read": "text" },
{ "page": 57, "relevance": 0.6, "read": "image" }
],
"more_pages": [
{ "page": 41, "relevance": 0.2, "read": "text" }
]
}
],
"failed_pages": [],
"usage": {
"pages": 31,
"questions": 1,
"billable_pages": 31,
"credits": 0.31,
"balance": 4825.12
},
"seconds": 3.84
}
| Field | What it is |
|---|---|
relevance | The chance the page helps answer the question, from 0 to 1, to one decimal. |
read | How to read the page: text, or image for a page that is a picture, such as a scan or a chart. |
text | With include_text, the page's text. |
more_pages | Up to 10 of the next most relevant pages. |
failed_pages | Pages that could not be judged. They are not charged. |
usage.credits | What the search cost, in credits. One credit is one US cent. |
usage.balance | Your balance after the search, in credits. |
The price is $0.10 per 1,000 pages for one question, and $0.02 per 1,000 pages for each further question. Only the pages judged are charged. See Pricing.
| Status | When |
|---|---|
| 402 | insufficient_credits: your balance does not cover the search. |
| 403 | The document is not yours. |
| 404 | The document does not exist. |
| 409 | The document's pages are not ready yet. |
| 422 | A question that is empty or too long. start_page after end_page. start_page past the last page. More than 5,000 pages. |
| 503 | The search could not be done just now. Try again after Retry-After seconds. |
SDK: Python PageSearchClient.search(questions, document=doc_id).
Find the documents that answer
POST /docs/search · READ key
Judges each document in a scope against each question, and lists the documents likely to answer it, most relevant first.
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
questions | array (JSON) | Yes | 1 to 10 questions, each 1 to 2,000 characters. | |
document_ids | array (JSON) | No | Search among these documents, up to 1,000. | |
collection_id | string (JSON) | No | Search among a collection's documents. | |
folder_id | string (JSON) | No | Search among a folder's documents. root is the documents at the root of your folders. | |
recursive | boolean (JSON) | No | false | With folder_id, also search its subfolders. With root, every folder. |
metadata_filter | object (JSON) | No | Search among the documents whose metadata meets it. Same operators as List documents. | |
top_k | integer (JSON) | No | List exactly this many documents for each question, 1 to 1,000. |
- Leave the scope out to search all your documents.
- A search covers up to 1,000 documents. Name them in
document_ids, or narrow the scope.
curl https://api.pageindex.ai/docs/search \
-H "api_key: $PAGEINDEX_API_KEY" \
-H "Content-Type: application/json" \
-d '{"questions": ["Which suppliers raised prices in 2024?"], "collection_id": "cm3ka1b7r0002l508x9w3e7tq"}'
{
"id": "srch_7b1d3f5a9c2e4a6b8d0f1c3e",
"results": [
{
"question": "Which suppliers raised prices in 2024?",
"documents": [
{
"id": "pi-cm3k9x2qv0001l50856dh4a2f",
"name": "acme-invoice-2024-03.pdf",
"pageNum": 4,
"folderId": null,
"collectionId": "cm3ka1b7r0002l508x9w3e7tq",
"metadata": { "supplier": "Acme GmbH" },
"relevance": 0.8
}
],
"more_documents": []
}
],
"failed_documents": [],
"processing_documents": [],
"usage": {
"documents": 42,
"questions": 1,
"billable_documents": 42,
"credits": 1.26,
"balance": 4823.86
},
"seconds": 2.91
}
| Field | What it is |
|---|---|
relevance | The chance the document answers the question, from 0 to 1, to one decimal. |
more_documents | Up to 10 of the next most relevant documents. |
failed_documents | Documents that could not be judged. They are not charged. |
processing_documents | Documents not ready yet. They are not searched or charged. |
The price is $0.30 per 1,000 documents for one question, and $0.10 per 1,000 documents for each further question. Only the documents judged are charged. See Pricing.
| Status | When |
|---|---|
| 400 | A question that is empty or too long. Parameters that do not go together. A filter that is not valid. More than 1,000 documents in the scope. A named document that failed. |
| 402 | insufficient_credits: your balance does not cover the search. |
| 404 | The folder, the collection, or a named document does not exist. |
| 422 | A field that is not known, or a value out of range. |
| 503 | The search could not be done just now. Try again after Retry-After seconds. |
SDK: Python PageSearchClient.search_documents().
Search pages across documents
No single endpoint searches pages across documents. The SDK does it with two calls:
POST /docs/searchfinds the documents most likely to answer each question.POST /doc/{doc_id}/page-searchsearches the pages of each of those documents, for the questions that chose it.
Python PageSearchClient.search() does this when you leave document out. Both calls are charged: the documents judged, then the pages searched. See Search pages.
The JavaScript SDK searches through MCP tools, search_pages and search_documents: see Connect over MCP.