Responses API fails with 500 error

The script below produces:

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

Here is the script:

curl https://api.openai.com/v1/responses \
	-H "Content-Type: application/json" \
	-H "Authorization: Bearer $OPENAI_API_KEY" \
	-d '{
	"input": "Please generate a good complete example resume based on the resume description and/or job description below.  If the resume description and/or job description have enough information for you to generate an example resume, then call the function \"example_resume\" with the data of the example resume.  But if there isn’t enough information for you to generate an example resume, then don’t call the function but instead respond with text explaining the issue.\n\nHere is the resume description delimited by triple quotes:\n\n\"\"\"\njava programmer\n\"\"\"\n\nHere is the job description delimited by triple quotes:\n\n\"\"\"\n\n\"\"\"\n",
	"tools": [
		{
			"type": "function",
			"name": "example_resume",
			"description": "Provide an example resume.  Note that there is no person’s name, location, or contact info.  These will be filled in with generic info before presenting the resume to the user.",
			"parameters": {
				"type": "object",
				"description": "Data of an example resume",
				"properties": {
					"occupation": {
						"type": "string",
						"description": "The job title (occupation) of the person in the resume"
					},
					"blocks": {
						"type": "array",
						"description": "A list of the sections of the resume.  Note that the category of each item can only be 1 of the 3 constant values listed below.  For any category other than \"summary\", \"work_experience\", or \"education\", use category \"text\" and set the title to describe the category.",
						"items": {
							"oneOf": [
								{
									"type": "object",
									"properties": {
										"summary": {
											"type": "string",
											"format": "html",
											"description": "The summary text of the resume in HTML format."
										},
										"category": {
											"type": "string",
											"const": "summary"
										},
										"title": {
											"type": "string",
											"description": "The title of this summary section"
										}
									},
									"required": [
										"category",
										"title",
										"description"
									],
									"description": "The summary section of the resume."
								},
								{
									"type": "object",
									"properties": {
										"work_experience": {
											"type": "array",
											"description": "A list of jobs held",
											"items": {
												"type": "object",
												"description": "One job",
												"properties": {
													"job_title": {
														"type": "string",
														"description": "The title of the job held"
													},
													"company": {
														"type": "string",
														"description": "The company worked for"
													},
													"location": {
														"type": "string",
														"description": "Where the job was"
													},
													"from_month": {
														"type": "string",
														"pattern": "^(|[A-Z][a-z]{2})$",
														"description": "Month of the starting date"
													},
													"from_year": {
														"type": "string",
														"pattern": "^(|[0-9]{4})$",
														"description": "Year of the starting date"
													},
													"to_month": {
														"type": "string",
														"pattern": "^(|[A-Z][a-z]{2}|Current)$",
														"description": "Month of the ending date"
													},
													"to_year": {
														"type": "string",
														"pattern": "^(|[0-9]{4})$",
														"description": "Year of the ending date"
													},
													"description": {
														"type": "string",
														"format": "html",
														"description": "The full description of the job"
													}
												}
											}
										},
										"category": {
											"type": "string",
											"const": "work_experience"
										},
										"title": {
											"type": "string",
											"description": "The title of this work experience section"
										}
									}
								},
								{
									"type": "object",
									"properties": {
										"education": {
											"type": "array",
											"description": "A list of schools attended",
											"items": {
												"type": "object",
												"description": "One school",
												"properties": {
													"field_of_study": {
														"type": "string",
														"description": "The degree and field of study"
													},
													"school": {
														"type": "string",
														"description": "The name of the school"
													},
													"location": {
														"type": "string",
														"description": "The location of the school"
													},
													"start_year": {
														"type": "string",
														"pattern": "^(|[0-9]{4})$",
														"description": "The start year"
													},
													"grad_year": {
														"type": "string",
														"pattern": "^(|[0-9]{4}|Current)$",
														"description": "The graduation year"
													},
													"description": {
														"type": "string",
														"format": "html",
														"description": "Relevant text about the school"
													}
												}
											}
										},
										"category": {
											"type": "string",
											"const": "education"
										},
										"title": {
											"type": "string",
											"description": "The title of this education section"
										}
									}
								},
								{
									"type": "object",
									"description": "A section of the resume other than summary, work_experience, or education",
									"properties": {
										"text": {
											"type": "string",
											"format": "html",
											"description": "The content of the section"
										},
										"category": {
											"type": "string",
											"const": "text",
											"description": "This value must be \"text\"."
										},
										"title": {
											"type": "string",
											"description": "The title of the section"
										}
									}
								}
							]
						}
					}
				}
			}
		}
	],
	"store": false,
	"model": "gpt-4o"
}
'

(This would have been nicer as a file attachment, but I can’t do that here I guess.)

No response in 13 days. Horrible. I discussed this with ChatGPT.

I have moved this topic to the documentation category because the type “server error” and parameter “constrained_sampling_specs” are not part of the official documentation.

https://platform.openai.com/docs/guides/error-codes

2 Likes

The exact cause of your odd error ("param": "constrained_sampling_spec_data") is due to a mismatch in your JSON schema definition within the "tools" parameter. Specifically, the schema for the "summary" block incorrectly lists "description" as a required property, but the property defined is actually "summary".

Exact Cause of the Error:

In your schema, you have:

"required": [
    "category",
    "title",
    "description"
]

But the actual property defined is "summary", not "description":

"properties": {
    "summary": {
        "type": "string",
        "format": "html",
        "description": "The summary text of the resume in HTML format."
    },
    "category": {
        "type": "string",
        "const": "summary"
    },
    "title": {
        "type": "string",
        "description": "The title of this summary section"
    }
}

This mismatch causes the internal schema validation to fail, resulting in the cryptic server error.


Exact Repair Required:

Replace "description" with "summary" in the "required" array for the summary block:

Corrected summary block schema:

{
    "type": "object",
    "description": "The summary section of the resume.",
    "properties": {
        "summary": {
            "type": "string",
            "format": "html",
            "description": "The summary text of the resume in HTML format."
        },
        "category": {
            "type": "string",
            "const": "summary"
        },
        "title": {
            "type": "string",
            "description": "The title of this summary section"
        }
    },
    "required": [
        "category",
        "title",
        "summary"
    ],
    "additionalProperties": false
}

Additionally, ensure each of your other resume blocks (work_experience, education, text) explicitly declare their "required" fields and include "additionalProperties": false.


Successful CURL Request Would Be:

curl https://api.openai.com/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "input": "Please generate a good complete example resume based on the resume description and/or job description below. If the resume description and/or job description have enough information for you to generate an example resume, then call the function \"example_resume\" with the data of the example resume. But if there isn’t enough information for you to generate an example resume, then don’t call the function but instead respond with text explaining the issue.\n\nHere is the resume description delimited by triple quotes:\n\n\"\"\"\njava programmer\n\"\"\"\n\nHere is the job description delimited by triple quotes:\n\n\"\"\"\n\n\"\"\"\n",
    "tools": [
      {
        "type": "function",
        "name": "example_resume",
        "description": "Provide an example resume. Note that there is no person’s name, location, or contact info. These will be filled in with generic info before presenting the resume to the user.",
        "parameters": {
          "type": "object",
          "description": "Data of an example resume",
          "properties": {
            "occupation": {
              "type": "string",
              "description": "The job title (occupation) of the person in the resume"
            },
            "blocks": {
              "type": "array",
              "description": "A list of the sections of the resume.",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "description": "The summary section of the resume.",
                    "properties": {
                      "summary": {
                        "type": "string",
                        "format": "html",
                        "description": "The summary text of the resume in HTML format."
                      },
                      "category": {
                        "type": "string",
                        "const": "summary"
                      },
                      "title": {
                        "type": "string",
                        "description": "The title of this summary section"
                      }
                    },
                    "required": ["category", "title", "summary"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "description": "The work experience section of the resume.",
                    "properties": {
                      "work_experience": {
                        "type": "array",
                        "description": "A list of jobs held",
                        "items": {
                          "type": "object",
                          "description": "One job",
                          "properties": {
                            "job_title": {
                              "type": "string",
                              "description": "The title of the job held"
                            },
                            "company": {
                              "type": "string",
                              "description": "The company worked for"
                            },
                            "location": {
                              "type": "string",
                              "description": "Where the job was"
                            },
                            "from_month": {
                              "type": "string",
                              "pattern": "^(|[A-Z][a-z]{2})$",
                              "description": "Month of the starting date"
                            },
                            "from_year": {
                              "type": "string",
                              "pattern": "^(|[0-9]{4})$",
                              "description": "Year of the starting date"
                            },
                            "to_month": {
                              "type": "string",
                              "pattern": "^(|[A-Z][a-z]{2}|Current)$",
                              "description": "Month of the ending date"
                            },
                            "to_year": {
                              "type": "string",
                              "pattern": "^(|[0-9]{4})$",
                              "description": "Year of the ending date"
                            },
                            "description": {
                              "type": "string",
                              "format": "html",
                              "description": "The full description of the job"
                            }
                          },
                          "required": ["job_title", "company", "location", "from_month", "from_year", "to_month", "to_year", "description"],
                          "additionalProperties": false
                        }
                      },
                      "category": {
                        "type": "string",
                        "const": "work_experience"
                      },
                      "title": {
                        "type": "string",
                        "description": "The title of this work experience section"
                      }
                    },
                    "required": ["category", "title", "work_experience"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "description": "The education section of the resume.",
                    "properties": {
                      "education": {
                        "type": "array",
                        "description": "A list of schools attended",
                        "items": {
                          "type": "object",
                          "description": "One school",
                          "properties": {
                            "field_of_study": {
                              "type": "string",
                              "description": "The degree and field of study"
                            },
                            "school": {
                              "type": "string",
                              "description": "The name of the school"
                            },
                            "location": {
                              "type": "string",
                              "description": "The location of the school"
                            },
                            "start_year": {
                              "type": "string",
                              "pattern": "^(|[0-9]{4})$",
                              "description": "The start year"
                            },
                            "grad_year": {
                              "type": "string",
                              "pattern": "^(|[0-9]{4}|Current)$",
                              "description": "The graduation year"
                            },
                            "description": {
                              "type": "string",
                              "format": "html",
                              "description": "Relevant text about the school"
                            }
                          },
                          "required": ["field_of_study", "school", "location", "start_year", "grad_year", "description"],
                          "additionalProperties": false
                        }
                      },
                      "category": {
                        "type": "string",
                        "const": "education"
                      },
                      "title": {
                        "type": "string",
                        "description": "The title of this education section"
                      }
                    },
                    "required": ["category", "title", "education"],
                    "additionalProperties": false
                  },
                  {
                    "type": "object",
                    "description": "A section of the resume other than summary, work_experience, or education",
                    "properties": {
                      "text": {
                        "type": "string",
                        "format": "html",
                        "description": "The content of the section"
                      },
                      "category": {
                        "type": "string",
                        "const": "text"
                      },
                      "title": {
                        "type": "string",
                        "description": "The title of the section"
                      }
                    },
                    "required": ["category", "title", "text"],
                    "additionalProperties": false
                  }
                ]
              }
            }
          },
          "required": ["occupation", "blocks"],
          "additionalProperties": false
        }
      }
    ],
    "store": false,
    "model": "gpt-4o"
  }'

How you’d make a Python API call:

(function specification shortened)

from openai import OpenAI

client = OpenAI()

tools = [{
    "type": "function",
    "name": "example_resume",
    "description": "Provide an example resume. Note that there is no person’s name, location, or contact info. These will be filled in with generic info before presenting the resume to the user.",
    "parameters": {
        "type": "object",
        "description": "Data of an example resume",
        "properties": {
            "occupation": {
                "type": "string",
                "description": "The job title (occupation) of the person in the resume"
            },
            "blocks": {
                "type": "array",
                "description": "A list of the sections of the resume.",
                "items": {
                    "oneOf": [
                        {
                            "type": "object",
                            "description": "The summary section of the resume.",
                            "properties": {
                                "summary": {
                                    "type": "string",
                                    "format": "html",
                                    "description": "The summary text of the resume in HTML format."
                                },
                                "category": {
                                    "type": "string",
                                    "const": "summary"
                                },
                                "title": {
                                    "type": "string",
                                    "description": "The title of this summary section"
                                }
                            },
                            "required": ["category", "title", "summary"],
                            "additionalProperties": False
                        }
                        # similarly correct other blocks (work_experience, education, text)
                    ]
                }
            }
        },
        "required": ["occupation", "blocks"],
        "additionalProperties": False
    }
}]

response = client.responses.create(
    model="gpt-4o",
    input="Please generate a good complete example resume based on the resume description and/or job description below. If the resume description and/or job description have enough information for you to generate an example resume, then call the function \"example_resume\" with the data of the example resume. But if there isn’t enough information for you to generate an example resume, then don’t call the function but instead respond with text explaining the issue.\n\nHere is the resume description delimited by triple quotes:\n\n\"\"\"\njava programmer\n\"\"\"\n\nHere is the job description delimited by triple quotes:\n\n\"\"\"\n\n\"\"\"\n",
    tools=tools,
    store=False
)

print(response.output)

Tool use iteration really requires more code than a CURL test command.


Summary of the Fix:

  • Cause: Incorrect "required" field ("description" instead of "summary").
  • Repair: Replace "description" with "summary" in the "required" array.
  • Additional Recommendations:
    • Explicitly define "required" fields for all schema blocks.
    • Include "additionalProperties": false consistently.

Applying these corrections will resolve your server error and produce successful responses from the OpenAI Responses API.

2 Likes