I am working with Structured outputs. I have set strict to true
. Here is the response schema I am providing when calling the API:
{
"$defs": {
"Question": {
"discriminator": {
"propertyName": "QuestionType"
},
"anyOf": [
{
"type": "object",
"properties": {
"QuestionType": {
"type": "string",
"enum": ["MC"]
},
"QuestionText": {
"type": "string"
},
"Choices": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": ["QuestionType", "QuestionText", "Choices"]
},
{
"type": "object",
"properties": {
"QuestionType": {
"type": "string",
"enum": ["TE"]
},
"QuestionText": {
"type": "string"
}
},
"required": ["QuestionType", "QuestionText"]
}
]
}
},
"type": "object",
"properties": {
"questions": {
"type": "array",
"items": {
"$ref": "#/$defs/Question"
}
}
},
"required": ["questions"]
}
But I still get the following error
400 Invalid schema: Objects provided via 'anyOf' must not share identical first keys. Consider adding a discriminator key or rearranging the properties to ensure the first key is unique.
Am I adding the discriminator key properly and at the right place?