Guide

Quick start

Upload a PDF, then ask questions about it. You get back, for each question, the pages likely to answer it.

1. Get an API key

Sign in to the console and create a key. It is shown once; keep it in an environment variable.

export PAGEINDEX_SEARCH_API_KEY=pis_live_...

2. Upload a document

Send a PDF of up to 100 MB. The call waits until the document is ready (up to 10 seconds by default; set wait to change it), then returns it. A larger document may come back with "status": "processing" and a 202; search it once it is ready.

import os
import requests

API = "https://api.search.pageindex.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['PAGEINDEX_SEARCH_API_KEY']}"}

with open("report.pdf", "rb") as f:
    doc = requests.post(f"{API}/documents", headers=headers, files={"file": f}).json()
print(doc["id"], doc["status"], doc["pages"])
Response
{
  "object": "document",
  "id": "doc_60a07bcef3094b68806070f2",
  "filename": "report.pdf",
  "status": "ready",
  "pages": 160,
  "image_pages": 0,
  "bytes": 1252586,
  "created_at": "2026-10-26T06:52:57Z",
  "expires_at": "2026-11-25T06:52:57Z",
  "duplicate": false
}

3. Search it

Ask up to 10 questions in one search. Each page is judged against all of them at once.

result = requests.post(f"{API}/documents/{doc['id']}/search", headers=headers, json={
    "questions": ["What was capital expenditure in 2018?", "Who is the CEO?"],
}).json()

for answer in result["results"]:
    print(answer["question"])
    for page in answer["pages"]:
        print("  page", page["page"], page["relevance"])
Response
{
  "object": "search",
  "id": "srch_51b0c2…",
  "document_id": "doc_60a07bcef3094b68806070f2",
  "results": [
    {"question": "What was capital expenditure in 2018?",
     "pages": [{"page": 39, "relevance": 0.98}, {"page": 126, "relevance": 0.96}, {"page": 60, "relevance": 0.95}]},
    {"question": "Who is the CEO?",
     "pages": [{"page": 8, "relevance": 0.99}, {"page": 134, "relevance": 0.99}, …]}
  ],
  "failed_pages": [],
  "usage": {"pages": 160, "questions": 2, "billable_pages": 160, "cost_usd": 0.112, "balance_usd": 4.888},
  "seconds": 0.88
}

Each question lists the pages likely to help, most relevant first, each with its relevance from 0 to 1, and always at least 3 (every page, for a shorter document). Set "top_k": 5 to get exactly that many pages instead. Search the same document as often as you like: it is processed once.

Next

  • How it works: how pages are read, what relevance means, and how long documents are kept.
  • API reference: every endpoint, field and error.