Hello OpenAI Forum,
I have been experiencing a consistent issue when using the GPT-4o-2024-11-20 model via API with Structured Output. The model fails to return complete responses when processing large JSON inputs, consistently truncating the output at a specific index.
Issue Description
When submitting a structured JSON input for processing, the API successfully generates output but stops at index 255, even though the input continues beyond that point. The pattern is reproducible across multiple attempts and with different files, where truncation occurs at similar indices. Below is a generalized example:
Input JSON Sample (Generalized):
{
"Data": [
{
"Index": 211,
"Text": "Sample text for processing."
},
...
{
"Index": 340,
"Text": "Another sample text at a later index."
}
]
}
Expected Output Format:
{
"ProcessedData": [
{
"Index": 211,
"ProcessedText": "Translated or structured response."
},
...
{
"Index": 340,
"ProcessedText": "Final expected output."
}
]
}
Actual Output (Truncated at Index 255):
{
"ProcessedData": [
{
"Index": 211,
"ProcessedText": "Translated or structured response."
},
...
{
"Index": 255,
"ProcessedText": "Last returned response before truncation."
}
]
}
Observations:
- The API consistently stops generating output at index 255, regardless of different inputs.
- The structured output schema does not explicitly define a hard limit.
- No error message is returned—only an incomplete response.
- The issue persists even when running multiple times with slight variations in input format.
Questions:
- Is there a predefined token or response size limit in Structured Output mode that causes truncation?
- Is there a workaround to ensure complete responses, such as breaking the input into smaller chunks?
- Has anyone else encountered similar structured output truncation in the GPT-4o API, and if so, how was it resolved?
Any insights or guidance on how to resolve this would be greatly appreciated. Thank you!