@okrapdf/cli
v0.2.11
Published
OkraPDF command-line interface for PDF extraction and document chat
Maintainers
Readme
@okrapdf/cli
Command-line interface for OkraPDF - extract tables from PDFs.
Installation
npm install -g @okrapdf/cliOr use with npx:
npx @okrapdf/cli extract invoice.pdfQuick Start
# Set your API key
export OKRA_API_KEY=okra_xxxxxxxxxxxx
# Extract tables from a PDF
okra extract invoice.pdf -o json
# Ask a question about a document
okra run report.pdf "What is the total revenue?"Get your API key from okrapdf.com/settings/api-keys.
Configuration
The CLI looks for your API key in this order:
OKRA_API_KEYenvironment variable.envfile in current directory.okrafile in current directory~/.okrafile in home directory~/.config/okrapdf/config.json
Example .env or .okra file:
OKRA_API_KEY=okra_xxxxxxxxxxxx
OKRA_BASE_URL=https://okrapdf.comCommands
Shortcuts (Most Common)
okra extract <file> # Upload + extract + wait (all-in-one)
okra run <file> "question" # Extract + ask questionDocuments
okra docs list # List all documents
okra docs upload <file> # Upload a PDF
okra docs get <uuid> # Get document details
okra docs delete <uuid> # Delete a documentJobs
okra jobs list # List extraction jobs
okra jobs create <file> # Create extraction job
okra jobs get <job-id> # Get job status
okra jobs wait <job-id> # Wait for completion
okra jobs results <job-id> # Get extraction resultsTables
okra tables list <doc-uuid> # List extracted tables
okra tables get <table-id> # Get table content
okra tables export <id> # Export to CSV/JSONInteractive Chat
okra chat <document-uuid> # Interactive document Q&AOutput Formats
All commands support -o, --output:
table(default) - Human-readable tablesjson- Machine-readable JSONcsv- CSV format
# JSON for scripting
okra jobs list -o json | jq '.[].id'
# Quiet mode for piping
okra extract doc.pdf -o json -q > results.jsonFor AI Agents
The CLI is designed to be agent-friendly:
# Get tables as JSON (for building presentations, reports)
okra extract document.pdf --json --quiet
# Get document list as JSON for processing
okra docs list -o json | jq '.[].uuid'
# Extract with specific processor
okra jobs create document.pdf -p gemini --wait -o jsonEnvironment Variables
| Variable | Description |
|----------|-------------|
| OKRA_API_KEY | API key (required) |
| OKRA_BASE_URL | Custom API URL (for self-hosted) |
| OKRA_OUTPUT_FORMAT | Default output format |
Examples
Batch Processing
for pdf in *.pdf; do
okra extract "$pdf" -o json > "${pdf%.pdf}.json"
doneCI/CD Integration
# Extract and check for tables
RESULT=$(okra extract report.pdf -o json -q)
TABLE_COUNT=$(echo "$RESULT" | jq '.tables | length')
echo "Found $TABLE_COUNT tables"Exit Codes
| Code | Meaning | |------|---------| | 0 | Success | | 1 | General error | | 2 | Invalid arguments | | 3 | Authentication error | | 4 | Resource not found | | 5 | Rate limited |
Development
git clone https://github.com/okrapdf/cli
cd cli
npm install
npm run build
npm link
okra --helpLicense
MIT - see LICENSE
