pip install spidra and your API key in SPIDRA_API_KEY. The example folder holds three invoices from different vendors, each laid out differently.
1. Describe the fields
Adescription on a field tells the AI how to write the value, which keeps dates and currencies consistent across vendors:
2. Check the cost, then parse
estimate_parse() reads each file’s page count without charging anything. parse() then reads the file and fills the schema:
Larger folders
- Many files:
parse_batch()takes up to 50 documents in one request, and one that fails doesn’t stop the others. - Big files: uploads go up to 50 MB; files up to 500 MB use
upload_for_parse()first. - Only some pages: pass
pages="1-2"to parse just the first two pages of each file, and pay for those. - Scanned documents are read with AI automatically. They take longer, and quality depends on the scan.
If something goes wrong
- A file failed. It wasn’t charged. Password-protected and damaged files fail with a plain error such as “This PDF is password protected”.
- A field is
null. The document doesn’t say it, or says it in a way the prompt didn’t cover. Add a hint to the field’sdescription. - Totals come back as text. Make sure the field’s type is
numberin the schema.
client.delete_parse_file(file_id).
