Structured Outputs - Breaking Bug
# support
j
Hi team, we have an issue with structured outputs. The config in ss1 cannot be saved, with the error in ss2. We thought this could be a client validation error, however when trying to create the same via API (Postman) we get a 500 server error. Could we please get assistance here? Thanks in advance. For additional context into our use case, we have a set of questions & answers in varying numbers depending on the appointment type. We're creating a structured output which creates a new set Q/A output in an array. The expected output is in ss3, which can be seen in the preview result. https://cdn.discordapp.com/attachments/1458725421896962109/1458725422106939465/image.png?ex=697d07aa&is=697bb62a&hm=29ca22342e8347483fc494ee805ba96cd3f870bd3c58f21f1add0f3fa48f819d& https://cdn.discordapp.com/attachments/1458725421896962109/1458725422580764774/image.png?ex=697d07aa&is=697bb62a&hm=65845b6923d336b9634de6afaaa34dd2f8b8c3db93486187111abc609d853101&
v
The error occurs because your "Question Answer Sets" array is missing an
items
type definition in your JSON Schema. To fix this, define the
items
property as an object with the required fields. Here’s an example:
Copy code
json
{
  "type": "object",
  "properties": {
    "questionAnswerSets": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "question": { "type": "string" },
          "answer": { "type": "string" }
        },
        "required": ["question", "answer"]
      }
    }
  },
  "required": ["questionAnswerSets"]
}
This should resolve the "missing item type configuration" error when saving your structured output. For more details, see the [Vapi structured output schema documentation](https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create). Source: - [Vapi Structured Output Controller Create API Reference](https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create)
j
That's not it - I have a well formed request body, and also the above AI Generated request gets the following response: { "message": [ "property type should not exist", "property properties should not exist", "property required should not exist" ], "error": "Bad Request", "statusCode": 400 }
This is my current request body: { "name": "Questions and Answers", "description": "Captures booking questions and their corresponding answers from the conversation", "schema": { "type": "object", "properties": { "questionAnswerPairs": { "type": "array", "description": "Array of question and answer pairs from the conversation", "items": { "type": "object", "properties": { "question": { "type": "string", "description": "Booking question asked by the patient" }, "answer": { "type": "string", "description": "Answer provided to the booking question" } }, "required": ["question", "answer"] } } }, "required": ["questionAnswerPairs"] } }
c
Hi bobbychick, Thanks — I reviewed the docs and related threads. Two issues to check and the fixes: 1. Required field: include "type": "ai" at top-level when creating via API (omitting it causes 500). See the quickstart example: https://docs.vapi.ai/assistants/structured-outputs-quickstart 2. Array schema shape: your posted schema is valid, but the API/Dashboard validation errors you showed ("property type/properties/required should not exist") indicate you're sending a schema wrapped where the API expects a JsonSchema object without nested extra wrapper keys, or the Dashboard client is validating a different structure. Use this minimal payload (works for both Dashboard and POST /structured-output): { "name": "Questions and Answers", "type": "ai", "description": "Captures booking questions and answers", "schema": { "type": "object", "properties": { "questionAnswerPairs": { "type": "array", "items": { "type": "object", "properties": { "question": { "type": "string" }, "answer": { "type": "string" } }, "required": ["question", "answer"] }, "description": "Array of question/answer pairs" } }, "required": ["questionAnswerPairs"] } } If you still get a 500 from POST after adding "type":"ai" and using the schema above, include: • full request body you sent • response headers and timestamp (so we can correlate logs) Relevant docs: Create Structured Output API reference: https://docs.vapi.ai/api-reference/structured-outputs/structured-output-controller-create
j
Thanks Aniah, adding the type worked. Unusual that in some previous invalid requests I sent, it returned a "400" must include "type":"ai" but when schema is valid it's a 500
c
Hi there, Thanks for the update! I’m glad adding the
"type"
field resolved the issue. I understand how confusing it can be to see different error codes for similar situations—getting a 400 for missing
"type":"ai"
and a 500 when the schema is valid can definitely feel inconsistent. I’ll make a note of this behavior so we can clarify it for future reference.