Skip to main content
cast(data, target) asks the model to interpret input as a value of the target type.
For structured results, pass a Pydantic model or dataclass:
Use instructions to disambiguate the conversion. Use extract when the input can contain multiple matching values.
cast_async is the async counterpart. Both accept agent, thread, and context; see the API reference.