[Structured Outputs]Response 500 [gpt-4o-2024-08-06]

{
“error”: {
“message”: “The server had an error while processing your request. Sorry about that!”,
“type”: “server_error”,
“param”: null,
“code”: null
}
}

I used the latest structured output feature, but I encountered an error.
Is it because my schema is too complex? Because when I tried reducing my fields, it responded successfully.
For example, I only kept the “Button” component.
Here is my request.

curl --location 'https://api.openai.com/v1/chat/completions' \
--header 'Authorization: xxxxxx' \
--header 'Content-Type: application/json' \
--data '{
  "model": "gpt-4o-2024-08-06",
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "text": "I am developing a user interface on a low-code platform. Please provide the data required to construct the page according to my requirements and the structure requested by the low-code platform.\nMy requirements are:\na Login Page",
          "type": "text"
        }
      ]
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "name": "low_code_response",
      "strict": true,
      "schema": {
        "description": "Schema for a low-code platform UI component structure containing children",
        "type": "object",
        "properties": {
          "children": {
            "type": "array",
            "description": "Array of child components",
            "items": {
              "$ref": "#/$defs/Component"
            }
          }
        },
        "additionalProperties": false,
        "required": ["children"],
        "$defs": {
          "Component": {
            "anyOf": [
              {
                "$ref": "#/$defs/Row"
              },
              {
                "$ref": "#/$defs/Col"
              },
              {
                "$ref": "#/$defs/TypographyTitle"
              },
              {
                "$ref": "#/$defs/Tag"
              },
              {
                "$ref": "#/$defs/TypographyText"
              },
              {
                "$ref": "#/$defs/TypographyLink"
              },
              {
                "$ref": "#/$defs/Rate"
              },
              {
                "$ref": "#/$defs/Button"
              }
            ]
          },
          "TypographyTitle": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "props": {
                "type": "object",
                "description": "Properties specific to Typography.Title component",
                "properties": {
                  "level": {
                    "type": "integer",
                    "description": "The heading level"
                  },
                  "children": {
                    "type": "string",
                    "description": "The text content"
                  },
                  "code": {
                    "type": "boolean",
                    "description": "Whether the text is displayed as code"
                  },
                  "copyable": {
                    "type": "boolean",
                    "description": "Whether the text is copyable"
                  },
                  "delete": {
                    "type": "boolean",
                    "description": "Whether the text is displayed with a strikethrough"
                  },
                  "disabled": {
                    "type": "boolean",
                    "description": "Whether the text is disabled"
                  },
                  "editable": {
                    "type": "boolean",
                    "description": "Whether the text is editable"
                  },
                  "ellipsis": {
                    "type": "boolean",
                    "description": "Whether the text is displayed with an ellipsis if it overflows"
                  },
                  "mark": {
                    "type": "boolean",
                    "description": "Whether the text is highlighted"
                  },
                  "keyboard": {
                    "type": "boolean",
                    "description": "Whether the text is displayed with a keyboard style"
                  },
                  "underline": {
                    "type": "boolean",
                    "description": "Whether the text is underlined"
                  },
                  "strong": {
                    "type": "boolean",
                    "description": "Whether the text is bold"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "level",
                  "children",
                  "code",
                  "copyable",
                  "delete",
                  "disabled",
                  "editable",
                  "ellipsis",
                  "mark",
                  "keyboard",
                  "underline",
                  "strong"
                ]
              },
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Typography.Title"]
              }
            }
          },
          "Row": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props",
              "children"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Row"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Row component",
                "properties": {
                  "align": {
                    "type": "string",
                    "enum": ["top", "middle", "bottom"],
                    "description": "Vertical alignment of the row"
                  },
                  "justify": {
                    "type": "string",
                    "enum": [
                      "start",
                      "end",
                      "center",
                      "space-around",
                      "space-between"
                    ],
                    "description": "Horizontal alignment of the row"
                  },
                  "wrap": {
                    "type": "boolean",
                    "description": "Whether the row should wrap"
                  }
                },
                "additionalProperties": false,
                "required": ["align", "justify", "wrap"]
              },
              "children": {
                "type": "array",
                "description": "Child components",
                "items": {
                  "$ref": "#/$defs/Component"
                }
              }
            }
          },
          "Col": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props",
              "items"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Col"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Col component",
                "properties": {
                  "span": {
                    "type": "integer",
                    "description": "The number of columns the component should span"
                  }
                },
                "additionalProperties": false,
                "required": ["span"]
              },
              "items": {
                "$ref": "#/$defs/Component"
              }
            }
          },
          "Tag": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Tag"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Tag component",
                "properties": {
                  "color": {
                    "type": "string",
                    "description": "The color of the tag"
                  },
                  "children": {
                    "type": "string",
                    "description": "The text content of the tag"
                  },
                  "closable": {
                    "type": "boolean",
                    "description": "Whether the tag is closable"
                  }
                },
                "additionalProperties": false,
                "required": ["color", "children", "closable"]
              }
            }
          },
          "TypographyText": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Typography.Text"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Typography.Text component",
                "properties": {
                  "copyable": {
                    "type": "boolean",
                    "description": "Whether the text is copyable"
                  },
                  "children": {
                    "type": "string",
                    "description": "The text content"
                  },
                  "code": {
                    "type": "boolean",
                    "description": "Whether the text is displayed as code"
                  },
                  "delete": {
                    "type": "boolean",
                    "description": "Whether the text is displayed with a strikethrough"
                  },
                  "disabled": {
                    "type": "boolean",
                    "description": "Whether the text is disabled"
                  },
                  "mark": {
                    "type": "boolean",
                    "description": "Whether the text is highlighted"
                  },
                  "keyboard": {
                    "type": "boolean",
                    "description": "Whether the text is displayed with a keyboard style"
                  },
                  "underline": {
                    "type": "boolean",
                    "description": "Whether the text is underlined"
                  },
                  "strong": {
                    "type": "boolean",
                    "description": "Whether the text is bold"
                  }
                },
                "additionalProperties": false,
                "required": [
                  "copyable",
                  "children",
                  "code",
                  "delete",
                  "disabled",
                  "mark",
                  "keyboard",
                  "underline",
                  "strong"
                ]
              }
            }
          },
          "TypographyLink": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Typography.Link"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Typography.Link component",
                "properties": {
                  "href": {
                    "type": "string",
                    "description": "The URL the link points to"
                  },
                  "target": {
                    "type": "string",
                    "description": "The target attribute specifies where to open the linked document"
                  },
                  "children": {
                    "type": "string",
                    "description": "The text content of the link"
                  }
                },
                "additionalProperties": false,
                "required": ["href", "target", "children"]
              }
            }
          },
          "Rate": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Rate"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Rate component",
                "properties": {
                  "defaultValue": {
                    "type": "integer",
                    "description": "The default value of the rate component"
                  },
                  "allowClear": {
                    "type": "boolean",
                    "description": "Whether the rate component allows clearing"
                  },
                  "allowHalf": {
                    "type": "boolean",
                    "description": "Whether the rate component allows half values"
                  },
                  "autoFocus": {
                    "type": "boolean",
                    "description": "Whether the rate component should auto focus"
                  },
                  "count": {
                    "type": "integer",
                    "description": "The number of stars"
                  },
                  "disabled": {
                    "type": "boolean",
                    "description": "Whether the rate component is disabled"
                  },
                  "tooltips": {
                    "type": "array",
                    "description": "Tooltips for each star",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "additionalProperties": false,
                "required": [
                  "defaultValue",
                  "allowClear",
                  "allowHalf",
                  "autoFocus",
                  "count",
                  "disabled",
                  "tooltips"
                ]
              }
            }
          },
          "Button": {
            "type": "object",
            "required": [
              "componentName",
              "id",
              "hidden",
              "title",
              "isLocked",
              "condition",
              "props"
            ],
            "additionalProperties": false,
            "properties": {
              "id": {
                "type": "string",
                "description": "The unique identifier for the component"
              },
              "hidden": {
                "type": "boolean",
                "description": "Whether the component is hidden"
              },
              "title": {
                "type": "string",
                "description": "The title of the component"
              },
              "isLocked": {
                "type": "boolean",
                "description": "Whether the component is locked"
              },
              "condition": {
                "type": "boolean",
                "description": "The condition for rendering the component"
              },

              "componentName": {
                "type": "string",
                "enum": ["Button"]
              },
              "props": {
                "type": "object",
                "description": "Properties specific to Button component",
                "properties": {
                  "type": {
                    "type": "string",
                    "description": "The type of the button"
                  },
                  "children": {
                    "type": "string",
                    "description": "The text content of the button"
                  }
                },
                "additionalProperties": false,
                "required": ["type", "children"]
              }
            }
          }
        }
      }
    }
  },
  "max_tokens": 4096
}
'

I was also running into 500 errors and for us it turned out to be identical first keys in an anyOf. It looks like this could be the case for you too. They’re now correctly throwing a 400 for this with guidance, but it’s a weird constraint and I assume unintentional. Hope they update it! For now though we can work around it and I suspect that you can too.

1 Like

Thank you very much, but I am curious about how you discovered the cause of this issue before they updated and provided guidance

1 Like

Just lots of trial and error. I removed all of the properties from each object until there was just one, and then removed all of the objects but one (at which point things started working). When I added a second object and saw it start failing again, figured it was the issue (but couldn’t confirm until they started throwing the correct 400 error).