Skip to main content
Classification is extraction where the schema is a closed set. Use a Literal for one label, a List[Literal] for many.
The Literal constrains the model to the closed set. There is no invalid label to clean up downstream.

Multi-label

A review can touch several aspects. Return any subset.

Hierarchical

For a taxonomy, return the path instead of a flat label.

Span labeling

Asking the model to count characters is unreliable. Have it return the exact substring and locate offsets in Python.
The same shape drives PII redaction: detect the spans, then replace each with its tag in post-processing.

Choosing the shape

Other modalities

Image, audio, video, and document classification follow the same schema pattern with a different input argument. See Multimodal inputs.

Next steps

Developer Resources