DEDUPED Hot AI repos. Real use cases. What people build. Get the Monday 5

How to extract invoice fields into a validated schema with Py Idp

Turn invoice PDFs into Pydantic-validated fields using one pipeline call or one CLI command.

Short answer: Run pip install py-idp to install the core package. No API key is needed for this step; then Place invoice.pdf in the current directory and run python examples/00_zero_to_extraction.py to see extracted fields from the mock backend; run export OPENAI_API_KEY=... with your own key. All steps.

Who it is forA developer or finance ops engineer who receives a steady stream of invoice PDFs and needs the amounts, dates, and vendor names as clean data.

The problemWriting a parser, chunker, and LLM prompt for every invoice layout takes time and breaks on new formats.

The outcomeA dict of extracted Invoice fields, checked against a Pydantic schema, with per-field confidence and any validation errors.

What you need first

  • Python with pip available
  • An API key for a hosted LLM backend such as OpenAI, or a local backend such as Ollama (the zero-config path runs on the in-tree mock backend without a key)
  • A sample PDF or text file to test with, such as invoice.pdf

Steps

  1. Run pip install py-idp to install the core package. No API key is needed for this step.
  2. Place invoice.pdf in the current directory and run python examples/00_zero_to_extraction.py to see extracted fields from the mock backend.
  3. Run export OPENAI_API_KEY=... with your own key.
  4. Run idp run invoice.pdf --schema Invoice --backend openai to extract the fields with a hosted model.

Prompt for your agent

Using the py-idp repo, run the idp CLI on <path to invoice PDF> with --schema Invoice and --backend openai, then print the extracted fields. Verify that the output is a dict whose keys match the Invoice schema fields and that no validation errors are reported.

Caveat. The zero-config path uses the mock backend, so real extraction quality only shows after you switch to a hosted or local LLM backend.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for rollroyces/py-idp and "Extract invoice fields into a validated schema"

Add Deduped to Claude Code once

claude mcp add --transport http deduped https://dedupedai.com/mcp

Cursor, ChatGPT, others

Share: X LinkedIn Hacker News Email Copy link

Third-party repos we don't own. AI-written use cases can be wrong. Disclaimer