Overview
The PageIndex CLI provides a command-line interface for processing PDF and Markdown documents. The main entry point isrun_pageindex.py.
Source: run_pageindex.py
Basic Usage
Process PDF Document
Process Markdown Document
You must specify either
--pdf_path or --md_path, but not both.Global Options
These options apply to both PDF and Markdown processing:str
default:"gpt-4o-2024-11-20"
OpenAI model to use for processingExample:
str
default:"yes"
Whether to add sequential node IDs. Values:
yes or noExample:str
default:"yes"
Whether to generate AI summaries for each node. Values:
yes or noExample:str
default:"no"
Whether to generate a document description. Values:
yes or noOnly works if --if-add-node-summary yesExample:str
default:"no"
Whether to include full text in nodes. Values:
yes or noExample:PDF-Specific Options
These options only apply when using--pdf_path:
int
default:"20"
Number of pages to check for table of contentsExample:
int
default:"10"
Maximum number of pages per nodeExample:
int
default:"20000"
Maximum number of tokens per nodeExample:
Markdown-Specific Options
These options only apply when using--md_path:
str
default:"no"
Whether to apply tree thinning. Values:
yes or noMerges small nodes (below threshold) with their parentsExample:int
default:"5000"
Minimum token threshold for nodes when thinning is enabledExample:
int
default:"200"
Token threshold for generating summaries vs. using full textExample:
Complete Examples
PDF: Fast Processing (No Summaries)
PDF: Full-Featured Processing
PDF: Minimal (Structure Only)
Markdown: Basic Processing
Markdown: With Thinning and Summaries
Markdown: Full-Featured
Output
The CLI saves results to the./results/ directory:
- PDF:
./results/{pdf_name}_structure.json - Markdown:
./results/{md_name}_structure.json
File Format Validation
The CLI validates input files:PDF Files
- Must have
.pdfextension - File must exist at specified path
- Must be a valid PDF
Markdown Files
- Must have
.mdor.markdownextension - File must exist at specified path
Environment Variables
The CLI requires the OpenAI API key to be set:Using .env File
Create a.env file in the project root:
Using Shell Export
Performance Tips
Fast Processing (Seconds)
Balanced (1-3 Minutes)
Full-Featured (3-10 Minutes)
Common Use Cases
Research Papers
Financial Reports
Technical Manuals
Documentation Sites (Markdown)
Batch Processing
Process multiple files with a shell script:Troubleshooting
”API key not found"
"Module not found"
"Out of memory"
"Processing too slow”
See Also
- page_index() - Python API equivalent
- page_index_main() - Lower-level Python API
- md_to_tree() - Markdown processing function
- ConfigLoader - Configuration management