"min-" & "maxItems" are not supported in Structured Output

We have a following response data model where EntityA contains field_a of Array type with constraints on min and max item count:

{
   "$defs":{
      "GenerateResponse":{
         "items":{
            "anyOf":[
               {
                  "$ref":"#/$defs/EntityA"
               }
            ]
         },
         "title":"GenerateResponse",
         "type":"array"
      },
      "EntityA":{
         "properties":{
            "field_a":{
               "items":{
                  "type":"string"
               },
               "minItems":1,
               "maxItems":4,
               "title":"Field A",
               "type":"array"
            }
         },
         "required":[
            "field_a"
         ],
         "title":"EntityA",
         "type":"object"
      }
   },
   "properties":{
      "entities":{
         "$ref":"#/$defs/GenerateResponse"
      }
   },
   "required":[
      "entities"
   ],
   "title":"GenerateOpenAiResponse",
   "type":"object"
}

However, when using gpt4o with structured output, we get “‘minItems’ is not permitted”
and “‘maxItems’ is not permitted” validation error for the response model above.

Any insights when this is going to be supported and if it all?

Thanks!

1 Like

Hi @vmalyi and welcome to the community!

minItems and maxItems are currently not supported, see here.

I am not sure “when” they will be supported - perhaps one of the OpenAI staff can comment.

I found that I can to a certain degree control this via my prompt or by providing this as a description in the Field (I am using Python + Pydantic).

2 Likes