Skip to main content

Introduction

Retab classifications use the resource-based POST /v1/classifications API. A classification request analyzes a document, chooses exactly one category, and persists the result as a Classification object that you can later retrieve or list. Common use cases include:
  1. Document Routing: Route incoming files to the right downstream extraction pipeline
  2. Pre-filtering: Choose the right schema before extraction
  3. Mailroom Automation: Sort attachments by document type
  4. Quality Control: Verify documents match the expected category in a workflow
Key features of the Classification API:
  • Single Decision: Returns exactly one category for the document
  • Reasoned Output: Includes an explanation for the selected category
  • Custom Categories: Define categories specific to your workflow
  • Consensus Support: Run multiple votes with n_consensus when you want more stability
  • Stored Resource: The result is persisted and can be fetched later

Classification API

ClassificationRequest
ClassificationRequest
Returns
Classification Object
A stored classification resource containing the decision, consensus metadata, and usage.

Use Case: Document Routing in a Processing Pipeline

Classify incoming documents, then route them to the right extraction schema based on output.category.

Use Case: Email Attachment Filtering

Classify attachments first, then branch on output.category.

Classify vs Split

Use Classify when:
  • You need to know what kind of document you have
  • The document should map to one main category
  • You are routing to another workflow or extraction schema
Use Split when:
  • The file contains multiple sections with different meanings
  • You need page-level grouping
  • You plan to extract multiple subdocuments from one upload

Best Practices

Category Definition

  • Be Specific: Describe what makes each category unique
  • Use Visual Cues: Mention layouts, headers, logos, or tables when useful
  • Keep Overlap Low: Categories should be distinguishable from each other
  • Add a Catch-all: Include an other category when documents can fall outside the expected set

Reasoning and Consensus

  • Review output.reasoning when you need an audit trail or human validation
  • Use n_consensus > 1 for noisy or ambiguous document sets
  • Inspect consensus.choices to understand close calls between categories

Performance

  • Use 3-7 categories for best results in most routing setups
  • Limit pages with first_n_pages when the first page contains enough signal
  • Start with retab-small and only scale up when accuracy demands it