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.

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.

NameTypeRequiredDefaultDescription
doc_idstring (path)YesThe document's id.
questionsarray (JSON)Yes1 to 10 questions, each 1 to 2,000 characters.
top_kinteger (JSON)NoList exactly this many pages for each question, 1 to 1,000.
include_textboolean (JSON)NofalseGive each listed page's text.
start_pageinteger (JSON)No1The first page to search.
end_pageinteger (JSON)Nolast pageThe 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
}
FieldWhat it is
relevanceThe chance the page helps answer the question, from 0 to 1, to one decimal.
readHow to read the page: text, or image for a page that is a picture, such as a scan or a chart.
textWith include_text, the page's text.
more_pagesUp to 10 of the next most relevant pages.
failed_pagesPages that could not be judged. They are not charged.
usage.creditsWhat the search cost, in credits. One credit is one US cent.
usage.balanceYour 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.

StatusWhen
402insufficient_credits: your balance does not cover the search.
403The document is not yours.
404The document does not exist.
409The document's pages are not ready yet.
422A question that is empty or too long. start_page after end_page. start_page past the last page. More than 5,000 pages.
503The 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.

NameTypeRequiredDefaultDescription
questionsarray (JSON)Yes1 to 10 questions, each 1 to 2,000 characters.
document_idsarray (JSON)NoSearch among these documents, up to 1,000.
collection_idstring (JSON)NoSearch among a collection's documents.
folder_idstring (JSON)NoSearch among a folder's documents. root is the documents at the root of your folders.
recursiveboolean (JSON)NofalseWith folder_id, also search its subfolders. With root, every folder.
metadata_filterobject (JSON)NoSearch among the documents whose metadata meets it. Same operators as List documents.
top_kinteger (JSON)NoList 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
}
FieldWhat it is
relevanceThe chance the document answers the question, from 0 to 1, to one decimal.
more_documentsUp to 10 of the next most relevant documents.
failed_documentsDocuments that could not be judged. They are not charged.
processing_documentsDocuments 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.

StatusWhen
400A 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.
402insufficient_credits: your balance does not cover the search.
404The folder, the collection, or a named document does not exist.
422A field that is not known, or a value out of range.
503The 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:

  1. POST /docs/search finds the documents most likely to answer each question.
  2. POST /doc/{doc_id}/page-search searches 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.