Get structured output in unescaped JSON

Hey!

I’m using the Structured Output as documented and the API response looks fine overall, except the output I need and that I have defined in the JSON schema is returned as escaped JSON instead of standard JSON.

Does anyone know if there is any way to get the schema returned as standard JSON, it would make the integration on my end a bit easier. :slight_smile:

Thank you! :green_heart:

Hi and welcome!

I would personally deterministically convert one to the other as an external step.

I’m aware that is an option, but it seems a bit like wasted effort when it looks from the API documentation (https://platform.openai.com/docs/guides/structured-outputs?api-mode=responses#example-response) that just getting back standard JSON from the API should be an option?

Same issue..using lo/noCode to integrate AI. Always used the old json output but having upgraded some calls to the new ‘responses’ mode i tried starting to use the json_schema. It looks like somehow the “text” key in the Create a model response POST used to nest the schema is literally triggering a response as actual text instead of json..
The available json parsers in my noCode solution do not recognize the API response (GET) value (..content, first item’s text’s value - which then starts with "{/ so the whole workflow collapses..

It will take a lot of trial and error to recognize the output as clean json with regex patterns. Which is a bit of a step back … or.. am I missing an option?

Have been trying “strict” and referring to specific schema but no difference.

So my understanding is correct that this is the envisaged behavior and no further need to work around it?

unescaping JSON is a standard function in most JSON libraries, as escaped JSON is the correct way to ensure that all ascii possibilities are handled, so yes, I would expect what you are seeing to be standard behaviour.