Skip to main content
result_type specifies the Python value a task should produce. It defaults to str and can be a scalar, collection, dataclass, Pydantic model, or set of classification labels.

Structured values

The model receives the result schema. Invalid results produce validation feedback and can be retried. A valid type or rating range does not establish that the content is correct.

Classification

Pass labels, a Literal, or an enum to constrain the result:
For a classification helper and multi-label examples, see classify.

Custom validation

A result_validator must return the value to store or raise an exception to reject it. It replaces the task’s ordinary result-validation path, so it must perform any validation or conversion your application needs.
For work that only performs actions, use result_type=None. See running tasks for task states and failure handling.