I’m trying to build an automation in Pipedream where OpenAI generates structured product listings (title, description, tags, price) and writes them into Google Sheets.
The problem: OpenAI sometimes returns extra text/markdown, so Pipedream’s JSON parse step fails with errors like:
JSON.parse failed: Expected property name or ‘}’ in JSON at position 1
I’ve seen that the newer OpenAI API supports response_format: { type: “json_schema” }, but I don’t see how to use that in Pipedream’s Chat step.
Has anyone successfully forced valid JSON output in Pipedream?
Is the trick to use a Node.js step with the OpenAI SDK, or is there a clean way to do it in the built-in Chat action?
Would love to hear if others have solved this — I’m starting to wonder if Pipedream is really up to the job for this kind of workflow 
simple possible fixes:
- in your prompt, tell the model not to include anything except json, or tell it to put the json between some delimiters that pipedream can quickly parse… “reply in JSON starting with JSON: and ending in a new line. include the following fields…”
- end your prompt with the beginning of the correct json, so the model just continues it. For example if the json is supposed to be a list of objects that include a field called price then make the last thing in your prompt [{“price”:
- give the model a place to put extra stuff that it wants to tell you, like “first, provide the json response, then, on a new line, provide any necessary thoughts about how you formatted the json
none of this is pipedream specific, and I’d recommend using structured outputs if you can, or even tool calling (your json looks a lot like tool parameters), especially for complex records or lists of complex records.
a quick fix might be to just tack the model’s last response and the parse error message on to the end of the prompt and try again. A lot of times the model will do a better job the second or third time through.