Skip to main content
Use a Literal for one label and a List[Literal] for multiple labels.
The Literal constrains the result to the labels defined in the schema.

Multi-label

A review can touch several aspects. Return any subset.

Hierarchical

For a taxonomy, return the parent and child path.

Span labeling

Asking the model to count characters is unreliable. Have it return the exact substring and locate offsets in Python.
str.find() returns -1 when the returned text is not a verbatim substring, which is the signal that the model paraphrased despite the instructions. Guard the offset before you use it. find() also returns the first match only. When the same substring appears more than once, track the search offset or match occurrences in order before assigning spans. 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