I already have normal OpenAI streaming working in my Bubble app using the Responses API.
Right now, I stream the assistant’s plain text response to the user in real time.
Now I’m trying to move from plain text responses to JSON structured outputs, so that the AI can return both:
- a message to display in the chat
- structured data to drive UI actions
For example:
{
“assistant_message”: “I created a section based on your reference material.”,
“proposal_type”: “section”
}
The issue is that when I use Structured Outputs with json_schema and stream: true, the streamed response.output_text.deltacontains the JSON text itself, like:
{“assistant_message”:“I created…
instead of streaming only the assistant_message value.
I also noticed that I can create a response field from:
response.output_text.done -> text
which seems to provide the final JSON string after completion.
My question is:
What is the best practice in Bubble for combining OpenAI streaming with JSON structured outputs?
Should I:
- keep using the text stream for real-time display
- capture the final JSON from
response.output_text.done - parse it after completion for UI actions
Or is there a better way to stream only the chat message while still receiving the structured JSON at the end?
Any examples or recommended patterns would be very helpful.