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

How to extract typed fields from receipts into structured data with TypeLLM

Turn receipt text or images into merchant, total, expense type and reimbursable flags as typed values.

Short answer: Run pip install -U typellm; then run export TYPELLM_API_KEY="tl-sk-..." with your key from the API keys page; create a TypeLLMClient with your key and call generate() with the receipt text as context. All steps.

Who it is forAn finance or operations analyst who must turn many receipts into rows for expense reports and needs every field in the right type.

The problemFree-text model output is hard to load into a spreadsheet or database because amounts, categories and yes/no answers arrive in inconsistent formats.

The outcomeEach receipt returns a dict with a string merchant, a float total, one enum expense type, and a boolean reimbursable value, ready to load.

What you need first

  • Python with pip installed
  • A TypeLLM API key from typellm.ai (includes $5 free credit), or a GPU server running SGLang with a compatible model such as Qwen3.8-27B
  • Documents or text to process, and a list of the fields you want back

Steps

  1. Run pip install -U typellm
  2. Run export TYPELLM_API_KEY="tl-sk-..." with your key from the API keys page
  3. Create a TypeLLMClient with your key and call generate() with the receipt text as context
  4. Define questions with type string, number and boolean, and an enum of expense types such as meal, travel and equipment
  5. Read the typed values from response.result and write them to your expense table

Prompt for your agent

Use the Python package typellm in the repo TypeLLM/TypeLLM to extract merchant, total, expense_type and reimbursable from the receipt text at <receipt_path>. Call TypeLLMClient.generate() with an enum for expense_type and return response.result as JSON. Verify that expense_type is one of the enum values and total is a number.

Caveat. The README example uses a text receipt; for scanned receipts, the README shows image input with a vision-language model, so check that your chosen model supports images before you rely on it.

Use this in your AI agent

Ask your agent

Using the Deduped MCP, get the setup steps for TypeLLM/TypeLLM and "Extract typed fields from receipts into structured data"

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