Skip to content

Page Ranges

The page ranges parameter allows you to control which pages of a document are processed, enabling selective parsing for efficiency or targeted content extraction.

Page ranges can be configured in two ways:

  • max_pages: Limit the total number of pages to process (starting from page 1)
  • target_pages: Specify exact pages or ranges using 1-based indexing

Both options use 1-based page numbering (unlike v1 which used 0-based indexing), meaning the first page is page 1.

The page ranges should be included at the root level of your parsing request:

{
"page_ranges": {
"max_pages": 10,
"target_pages": "1,3,5-10"
}
}

Limit processing to the first 5 pages of the document:

{
"page_ranges": {
"max_pages": 5
}
}

Parse only pages 1, 3, and pages 7 through 12:

{
"page_ranges": {
"target_pages": "1,3,7-12"
}
}

Parse only the first page:

{
"page_ranges": {
"target_pages": "1"
}
}

Parse pages 5-10 and page 15:

{
"page_ranges": {
"target_pages": "5-10,15"
}
}
Terminal window
curl -X 'POST' \
'https://api.cloud.llamaindex.ai/api/v2/parse' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \
--data '{
"file_id": "<file_id>",
"tier": "cost_effective",
"version": "latest",
"page_ranges": {
"target_pages": "1-5,10,15-20"
}
}'