Migrate from pageindex-search and pageindex-extract
Page Search and Page Extract are now part of the pageindex SDK, as PageSearchClient and PageExtractClient. PageIndexClient handles your documents, collections and metadata. Document, collection and job IDs stay the same.
# Before
from pageindex_search import PageSearch
client = PageSearch()
doc = client.documents.upload("report.pdf")
result = client.search("What was revenue in 2024?", document=doc)
# Now
from pageindex import PageSearchClient
client = PageSearchClient()
doc_id = client.upload("report.pdf")["doc_id"]
result = client.search("What was revenue in 2024?", document=doc_id)
Install and key
pip install -U pageindex
pageindex needs Python 3.10 or newer. Every client reads PAGEINDEX_API_KEY. When it is not set, PageSearchClient reads PAGEINDEX_SEARCH_API_KEY and PageExtractClient reads PAGEINDEX_EXTRACT_API_KEY, so the key you already use works once your account has moved to PageIndex.
All three clients see the same documents. Make one client from another to share its key:
from pageindex import PageExtractClient, PageSearchClient
search = PageSearchClient()
extract = PageExtractClient(client=search.pageindex)
documents = search.pageindex # the PageIndexClient on the same key
What changes in every call
- Results are dicts, as the API returns them, not objects:
result["results"], notresult.results. - Pass IDs as strings, not
Document,Collectionor job objects. - Usage and balance are in credits (1 credit = $0.01), not dollars.
- Errors raise
PageIndexAPIError, with the HTTP status on.status_code. - The clients take no
base_url,timeout,max_retriesorhttp_client, and there is no async client.
Page Search
In the new column, search is a PageSearchClient and documents is search.pageindex.
| Before | Now |
|---|---|
PageSearch(api_key) | PageSearchClient(api_key) |
client.search(questions, document=...) | search.search(questions, document=...), the same arguments, without idempotency_key |
client.documents.search(questions, ...) | search.search_documents(questions, ...) |
client.documents.upload(file, collection=, metadata=) | search.upload(path, collection=, metadata=), a file path only. Returns {"doc_id", "name"} |
client.documents.wait(doc) | documents.wait_document(doc_id) |
client.documents.get(doc_id) | documents.get_document(doc_id) |
client.documents.update(doc, metadata=) | documents.update_document(doc_id, metadata=) |
client.documents.list(collection=, filter=) | documents.list_documents(collection_id=, filter=), which returns {"documents", "total", "limit", "offset"} |
client.documents.schema(collection=) | documents.get_metadata_schema(collection_id=) |
client.documents.pages(doc, [3, 4, 5]) | documents.get_page_content(doc_id, "3-5") |
client.documents.page_image(doc, page, box=) | documents.page_image(doc_id, page, box=), a JPEG, not a PNG |
client.documents.outline(doc) | documents.get_tree(doc_id), a tree of sections rather than headings by page |
client.documents.make_outline(doc) | documents.build_outline_index(doc_id) |
client.documents.delete(doc) | documents.delete_document(doc_id) |
client.collections.create(name) | documents.create_collection(name) |
client.collections.list() | documents.list_collections() |
client.collections.get(collection_id) | documents.get_collection(collection_id) |
client.collections.schema(collection) | documents.get_metadata_schema(collection_id=) |
client.collections.delete(collection) | documents.delete_collection(collection_id) |
client.tools() | documents.agent_tools() and the adapters in Use with your agent |
client.citations(text) | documents.get_citations(text) |
The new SDK has no methods to rename a collection, move a document into or out of one, read a PDF's bookmarks, read usage(), or turn a collection's outlines on and off. upload() takes a file path, not bytes or a file object.
Page Extract
extract is a PageExtractClient.
| Before | Now |
|---|---|
PageExtract(api_key) | PageExtractClient(api_key) |
client.extract(document, schema, ...) | extract.extract(document, schema, ...), the same arguments and defaults. document is a file path or a doc_id |
client.jobs.create(document, schema, ...) | extract.extract(document, schema, ..., wait=False) |
client.jobs.get(job) | extract.get_extract(job_id) |
client.jobs.list(limit=, after=) | extract.list_extracts(limit=, after=), which returns {"jobs", "next"} |
client.jobs.wait(job) | extract.wait_extract(job_id) |
client.jobs.cancel(job) | extract.cancel_extract(job_id) |
client.jobs.delete(job) | extract.delete_extract(job_id) |
A job is a dict:
| Before | Now |
|---|---|
job.status, such as "COMPLETED" | job["status"], such as "completed" |
job.result | job["extract_result"] |
job.sources | job["extract_metadata"]["field_metadata"], each with its "page" |
job.usage | job["usage"] |
job.error | job["error_message"] |
job.parse(Invoice) | Invoice.model_validate(job["extract_result"]) |
From pageindex 0.7.0
0.7.0 put search and extraction on PageIndexClient. They are now on their own clients, made from the one you have:
| 0.7.0 | Now |
|---|---|
client.search(...) | PageSearchClient(client=client).search(...) |
client.search_documents(...) | PageSearchClient(client=client).search_documents(...) |
client.extract(...) | PageExtractClient(client=client).extract(...). A file is now uploaded to the "Page Extract" collection and kept |
client.get_extract(), list_extracts(), wait_extract(), cancel_extract(), delete_extract() | The same methods on PageExtractClient |