Response_format and Fields with Pydantic

hi – does anyone know where to find ALL of the parameters for response_format in JSON mode – is there a way to enforce requirements on the output similar to Instructor?

Hi @dmc1 and welcome to the forums!

I haven’t used Instructor (have heard of it; similar to Outlines). But in general setting strict to True yields strict enforcement of the schema.

Regarding what parameters are supported, OpenAI official documentation is quite comprehensive, but to provide some references:

Also note that there are some intricacies when using JSON definition for your response_format. For example, you have to provide "additionalProperties": false for every object.

So I tend to define my schema in Pydantic and just pass the Pydantic class as my response_format.

2 Likes

Thanks! but for here - https://openai.com/index/introducing-structured-outputs-in-the-api/ - for the UI output, how is the JSON output structured like this? is it the assistant specifically or is it not clear from the example? output in question.

{
“type”: “div”,
“label”: “”,
“children”: [
{
“type”: “header”,
“label”: “”,
“children”: [
{
“type”: “div”,
“label”: “Green Thumb Gardening”,
“children”: ,
“attributes”: [{ “name”: “className”, “value”: “site-title” }]
},
{
“type”: “div”,
“label”: “Bringing Life to Your Garden”,
“children”: ,
“attributes”: [{ “name”: “className”, “value”: “site-tagline” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “header” }]
},
{
“type”: “section”,
“label”: “”,
“children”: [
{
“type”: “div”,
“label”: “”,
“children”: [
{
“type”: “div”,
“label”: “About Us”,
“children”: [
{
“type”: “div”,
“label”: “At Green Thumb Gardening, we specialize in transforming your outdoor spaces into beautiful, thriving gardens. Our team has decades of experience in horticulture and landscape design.”,
“children”: ,
“attributes”: [
{ “name”: “className”, “value”: “about-description” }
]
}
],
“attributes”: [{ “name”: “className”, “value”: “about-section” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “content” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “about-container” }]
},
{
“type”: “section”,
“label”: “”,
“children”: [
{
“type”: “div”,
“label”: “”,
“children”: [
{
“type”: “div”,
“label”: “Our Services”,
“children”: [
{
“type”: “div”,
“label”: “Garden Design”,
“children”: ,
“attributes”: [
{ “name”: “className”, “value”: “service-item” }
]
},
{
“type”: “div”,
“label”: “Plant Care & Maintenance”,
“children”: ,
“attributes”: [
{ “name”: “className”, “value”: “service-item” }
]
},
{
“type”: “div”,
“label”: “Seasonal Cleanup”,
“children”: ,
“attributes”: [
{ “name”: “className”, “value”: “service-item” }
]
},
{
“type”: “div”,
“label”: “Custom Landscaping”,
“children”: ,
“attributes”: [
{ “name”: “className”, “value”: “service-item” }
]
}
],
“attributes”: [{ “name”: “className”, “value”: “services-list” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “content” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “services-container” }]
}
],
“attributes”: [{ “name”: “className”, “value”: “landing-page” }]
}