Structured Outputs: Recursive schemas cause infinite loop
Derek FrostFeb 5, 2026
When using Structured Outputs with a recursive JSON schema (e.g., a tree structure where nodes can contain child nodes), the API enters what seems like an infinite loop and eventually times out.
{
"type": "object",
"properties": {
"name": {"type": "string"},
"children": {
"type": "array",
"items": {"$ref": "#"}
}
}
}
The request hangs for the full timeout period and then returns a 500 error. Non-recursive schemas work fine. Is recursive $ref supported?
1.5k views9 replies18 likesSolved
Log in to reply to this topic.