Skip to main content
USE CASE

Extract data from documents

Use case: Extract structured data from invoices, POs, and PDFs

Invoices, purchase orders, delivery notes and scanned contracts arrive as PDFs and photos, not structured data, which means someone on your team is retyping totals, line items and dates into your accounting or ERP system by hand. Webanto's chat endpoint runs Qwen3.6, a multimodal reasoning model that reads the document image directly, no separate OCR step, and returns the fields you ask for as JSON, ready to insert into a database or push to an accounting API. Because Qwen reasons before it answers, extraction on messy scans and multi-column layouts is noticeably more reliable than a plain vision-OCR pipeline, though the output still needs a schema check before it touches financial records.

What to expect

  • Line items, totals, dates and vendor details pulled into JSON without manual retyping.

  • Multimodal reading means scanned PDFs and phone-camera photos of paper invoices work the same as clean digital exports, with no separate OCR tool in the pipeline.

  • Reasoning before answering tends to handle unusual layouts, rotated tables, multi-currency line items, better than template-matching OCR, though results still vary by document quality.

  • One API call replaces a manual data-entry step, freeing that time for exception handling instead of routine typing.

How to set this up

  1. 1

    Get a Webanto AI API key from the dashboard and store it as WEBANTO_API_KEY — never hardcode it in the extraction script.

  2. 2

    Define the JSON schema you want back (vendor, invoice number, date, line items, subtotal, tax, total) and write it into the system prompt as an explicit example, not just a description.

  3. 3

    Convert each document page to an image (PNG or JPEG) if it isn't already — Qwen accepts image content blocks alongside text in the same POST /api/v1/chat request.

  4. 4

    Set max_tokens with headroom for reasoning: Qwen emits internal reasoning tokens before the visible JSON, so a 3-page invoice needing roughly 4,000 total tokens (about 2 credits at 2,000 tokens per credit) should request at least 1,500-2,000 max_tokens, or the response can come back empty.

  5. 5

    Parse the JSON response and validate it against your schema — types, required fields, plausible ranges — before writing to your database. Treat the model's output as untrusted input, the same as any external API response.

  6. 6

    Log any document that fails schema validation to a review queue rather than silently dropping it or guessing at missing fields.

  7. 7

    Track credits consumed per document type in your usage dashboard so you can catch a format change, such as a new vendor's invoice layout, that starts inflating token counts.

Products that power this use case

Frequently asked questions

  • Do I need a separate OCR tool before sending documents to the API?

    No. Qwen3.6 is multimodal, so you send the document image, or a page rendered to an image, straight in the chat request alongside your extraction prompt. It reads the text in the image itself rather than relying on a pre-processing OCR pass.

  • Can I trust the extracted totals for accounting entries without checking them?

    No. Treat this as a first-pass extraction, not a source of truth. Schema-validate every field, sanity-check totals against each other, and route anything with financial or legal consequences through a human review step before it posts to your books. LLM extraction reduces retyping; it doesn't replace review for high-stakes data.

  • Why did I get an empty response back?

    This is almost always a max_tokens problem. Qwen is a reasoning model — it spends tokens thinking before it writes the visible answer, and if max_tokens is too small the whole budget gets used on reasoning with nothing left for output. Raise max_tokens and retry.

  • What document formats work?

    Anything you can render to an image: PDF pages, scanned TIFFs, JPEG photos of paper documents, PNG screenshots. Multi-page PDFs need to be split into per-page images before the request; there is no native multi-page-PDF upload.

  • How much does extracting a typical invoice cost?

    A short single-page invoice with a handful of line items runs roughly 1,500-2,500 total tokens including reasoning, or about 1 credit at 2,000 tokens per credit. Longer multi-page purchase orders with many line items cost proportionally more as page count and text density go up.

Other use cases

Ready to try it?

Start a 14-day free trial on any paid plan. No credit card required.

Newsletter

Stay Ahead

Occasional, engineering-led notes on applied AI — what we're building, running, and learning in production.