@_j Thank you for the informed response.
The finish reason is indeed “Stop” and not “length” which was my first suspicion when I noticed this behavior. Furthermore I believe strict is correctly applied.
I think this is an openAI bug versus an incorrect usage of their API
But just to be sure, here is a heavily redacted version of my payload
{
"messages": [
{
"role": "system",
"content": "You are an AI assistant for a software platform. You are assigned to a structured project and must assist the user based on predefined context. Responses must contain plain newlines only—no markdown, no formatting, and no special characters. Respond only in English. Populate 5 items related to the following category: placeholderCategory."
},
{
"role": "user",
"content": "I want to create the following product: An AI-powered solution designed to enhance a traditional manual process. It adapts to user preferences in real time to provide personalized suggestions. The platform serves both end-users and enterprise clients to improve efficiency and user experience."
}
],
"model": "gpt-4o-search-preview",
"response_format": {
"json_schema": {
"name": "placeholderSchema",
"strict": true,
"schema": {
"type": "object",
"required": ["data"],
"properties": {
"data": {
"type": "object",
"required": ["placeholderCategory"],
"properties": {
"placeholderCategory": {
"description": "Must contain exactly 5 elements",
"type": "array",
"items": {
"type": "object",
"required": ["title", "description", "relatedOrgs"],
"properties": {
"title": {
"type": "string",
"description": "Short label for the item"
},
"description": {
"type": "string",
"description": "Detailed explanation of the item and suggested next steps"
},
"relatedOrgs": {
"type": "array",
"items": {
"type": "object",
"required": ["name", "url"],
"properties": {
"name": {
"type": "string",
"description": "Name of a real, currently active organization"
},
"url": {
"type": "string",
"description": "URL of the organization's website"
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
}
},
"additionalProperties": false
}
},
"additionalProperties": false
}
}
},
"web_search_options": {
"search_context_size": "high"
}
}
adding the redacted response
{
"redacted": "redacted",
"redacted": "redacted",
"redacted": "redacted",
"redacted": [
{
"redacted": [
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "redacted"
},
{
"redacted": "redacted",
"redacted": "Wisconsin
Notice the end mid string, no JSON, no stop reason etc. I believe this to be a bug