Use Cases + Implementation

How do you build data extraction with AI agents?

Build extraction as a schema-first agent loop: define the target fields and types, extract with JSON mode, validate each field, and use tools to resolve gaps — a lookup for a missing code, a second pass for an ambiguous section. Agents help when documents are inconsistent or fields need cross-referencing, while plain JSON-mode extraction stays best for uniform layouts.

Key facts

EndpointPOST /v1/chat/completions with JSON mode for extraction and tools for lookups
Schema firstDefine fields, types, formats and confidence before writing prompts
ValidationValidate every field against schema and business rules; retry once, then queue for review
Models30+ models; cheap aliases for uniform documents and stronger ones for messy inputs
Pricing modelFlat monthly self-serve plans with unlimited fair-use usage
Free tierFree plan with 2 free AI models, no card required
GovernanceAudit logs track extraction decisions and model versions
RoadmapBatch and files endpoints are coming soon

TL;DR

  • The schema is the product: define fields, formats and nullability before prompting.
  • Validate every field; valid JSON is not valid data.
  • Use tools to resolve reference data instead of trusting model recall.
  • Queue low-confidence fields for review instead of guessing.
  • Measure per-field accuracy and straight-through processing, not aggregate accuracy.

How it works, step by step

  1. List target fields with types, formats, allowed values and whether null is acceptable.
  2. Split the document into logical sections and identify which sections carry which fields.
  3. Extract with JSON mode, requesting a value and a confidence marker per field.
  4. Validate each value against schema, format and business rules; resolve reference data with tools.
  5. Retry once with the exact validation error, then route unresolved fields to a review queue.
  6. Store values with provenance — page, section and model version — and monitor per-field accuracy.
1List target fieldswith types,formats, allowed2Split the documentinto logicalsections and3Extract with JSONmode, requesting avalue and a4Validate each valueagainst schema,format and business5Retry once with theexact validationerror, then route6Store values withprovenance — page,section and model

Original data

POST /v1/chat/Endpoint30+ models; chModelsFree plan withFree tierSource: Plugsky facts table · updated 2026-09-25

Try it yourself

Open the JSON mode tester →

Architecture of an extraction agent

Six stages, each independently testable:

  • Intake: classify the document type and select the matching schema.
  • Normalize: convert the document to clean text and preserve page or section markers.
  • Extract: JSON-mode call for the fields present in the current section.
  • Validate: schema, format and business-rule checks per field.
  • Resolve: tools for reference lookups — customer ids, product codes, currency conversion.
  • Review: fields that fail validation or fall below confidence go to a human queue.

When to add the agent loop

Plain extraction is one call. Add agent behavior when the document fights back:

  • Inconsistent layouts: invoices from dozens of vendors put the same field in different places.
  • Cross-references: a purchase order number that must be looked up against an ERP before it can be confirmed.
  • Multi-section reasoning: totals that only make sense when compared against line items.
  • Missing fields: the agent searches other sections explicitly rather than inventing a value.

Each added step raises cost and latency, so add them only for document classes that show measurable failures.

Implementation and evaluation

Discipline that keeps extracted data trustworthy:

  • Ask for an explicit null rather than omitting a field; absence and empty mean different things in downstream systems.
  • Require confidence per field and calibrate thresholds against reviewed data.
  • Make writes idempotent with a document hash key, so retries never create duplicate records.
  • Keep a golden set per document type with exact expected values, and re-run it on every change.

Metrics: per-field precision and recall, exact-match rate for formatted values such as dates and amounts, invalid-output rate, review-queue yield and straight-through processing share. A 99% aggregate score can hide a 60% failure rate on one important field.

Limitations

Extraction accuracy depends on input quality:

  • Scanned and handwritten documents need OCR quality checks before extraction; no model recovers text that was never captured.
  • Ambiguous fields — 'total' versus 'subtotal', ship date versus invoice date — need explicit definitions in the schema.
  • Agent loops multiply cost on high-volume, uniform documents where a single call would suffice.
  • The files and batch endpoints are coming soon, so document storage and bulk processing remain your responsibility today.
  • Never let extracted values drive payments or irreversible actions without a validation or review gate.

Honest comparison

CapabilityExtraction agent on PlugskySingle-call extractionTemplate and regex parsing
Layout variationHandles inconsistent documentsWorks on uniform inputsBreaks on any change
Reference lookupsTools resolve codes and idsNot possibleCustom code
ConfidencePer-field markers with review queueOptionalNone
ValidationSchema plus business rulesSchema onlyFormat rules
CostHigher per documentLowLow but engineering-heavy

Frequently asked questions

When do I need an agent instead of a single extraction call?

When document layouts vary, fields need cross-referencing, or values require lookups. Uniform, single-template documents are cheaper and more consistent with one JSON-mode call.

How do I define the extraction schema?

List each field with its type, format, allowed values and whether null is acceptable, then map which document sections typically contain it.

What should a missing field look like?

An explicit null with a confidence marker. Omitting the field silently makes downstream validation impossible.

How do I handle reference data?

Expose lookup tools for customer ids, product codes and similar values instead of trusting the model to remember them correctly.

How do I evaluate extraction quality?

Per-field precision and recall against a golden set, plus invalid-output rate, review-queue yield and straight-through processing share.

Can it process scanned documents?

Only after OCR. Validate extraction quality on the OCR text, because normalization cannot recover characters the scanner missed.

Can I prototype extraction for free?

Yes. JSON mode is live, the free plan includes two free models with no card, and the 14-day full-access trial supports evaluation on your document types.