Basic Usage
Define a Pydantic model and pass it asresponse_format:
response.content. Parse it into your model using YourModel(**json.loads(response.content)).
Complex Schemas
Structured output handles nested models, lists, enums, and optional fields:Provider Support
When a provider does not support native structured outputs, Definable automatically includes the JSON Schema in the system prompt and instructs the model to respond in the correct format.
Strict Mode
OpenAI’s strict mode ensures the output adheres exactly to the schema. It is enabled by default:strict_output=False if you encounter schema compatibility issues with strict mode.
Using with Agents
Passoutput_schema to an agent run to get structured output from the final response: