Skip to main content
documents.classify scores one original file against caller-defined classes. Classify the whole document once, or return one unit per selected page.
Classify reads the original file and does not accept a parse-result source.

Basic usage


Method signature

Parameters

Unread pages are reported with a classification_unread_pages disclosure.

Returns

A Job. After success, job.result is a ClassifyResult containing units and any non-fatal disclosures. Unread pages are disclosed as classification_unread_pages.

Define classes

Each class has a stable id, display label, and model guidance:
Class IDs must be unique. Keep IDs stable when display labels or descriptions change because result labels join back to the request by class_id.

Subclasses

Use subclasses when a broad class has meaningful variants:

Document or page classification

The default document granularity returns one unit for the entire source:
Use page when a file contains different content on different pages:

Select pages


Handle unknown content

Start with allow when the set of possible documents is open-ended. Use force_best only when every input must belong to your closed class set.

Configure alternatives and reasons

max_alternatives defaults to 3, accepts 1–10, and includes the winner. Reasons are included by default.

Response structure

Labels are sorted best-first. rank === 1 is the assigned class, or the top candidate when unknown === true. The reserved other ID can appear when no requested class matches. confidence is DREX’s probability for the label, averaged over the menu orders, when DREX decided it. When any other label in the unit lacks one, every such label is the share of pages or sheets assigned that class. Runner-up labels on an abstained unit keep DREX’s probability for that option. disclosures carries non-fatal notices. A classification_gap_fill disclosure names the pages that were assigned a fallback label and the label used.

Complete example


Error handling

Common failures include empty or duplicate class IDs, reserved IDs, invalid page ranges, unsupported file types, and a parse-result source.

Best practices

Separate nearby classes

Explain how similar classes differ rather than repeating their labels.

Keep IDs stable

Treat class_id as the durable join key and labels as display text.

Allow unknowns first

Avoid forcing unrelated documents into a class while developing the taxonomy.

Use page mode deliberately

Page granularity is for mixed packets; document granularity is simpler for one logical file.

Next steps