Structured output with responses API returns tons of \n\n\n\n

If I want to include the content after “\n\n \t\t” as part of the input, would the above method still resolve the issue? In my case, I need to save both the part before and after “\n\n \t\t” from the model’s response as input.

The AI going into a repeating stream of linefeeds or tabs likely doesn’t terminate in any useful way. There is no frequency_penalty parameter that can break this on Responses API endpoint, so all you can do there is specify a high temperature and hope that random lower rank tokens could be sampled.

Using a stop parameter, only offered on Chat Completions (where you can discourage these constant token loops after they have been produced for a while), will terminate the AI generation if there is a recognized string produced, which can be cross-token. Since the token-by-token production was terminated, there is no more text after the stop sequence to provide to you. Stopping was the whole point.

This stop sequence string and any fragments after it is also then removed, thus not giving you all the tokens the AI model generated. That prevents some straightforward uses, like detecting the end of a JSON, or finding which of many sequences in your list was detected.

You would need to use max_completion_tokens to set an output budget, and take all that the AI wants to write up to your limit, if you still find any use for an output that has this persistent fault. (You could emulate your own stop sequence in a streaming API response, detecting within output and closing the connection only when you like)

I wonder why @OpenAI_Support has not addressed the issue yet since it’s been quite some time already.