Display text from Response AI / Prompt steps as it is generated by enabling ?completion_events=true on the Interact Stream API. Your interface can render partial responses while the step is still generating text.

📘 Only the Response AI / Prompt step produces completion events.
Example Response completion_events=false
This is what a response might look like normally. The user might have to wait a bit before seeing the message.
Example Response completion_events=true
With completion_events turned on, it still takes the same total time to get the entire message, but the user will be able to see the first chunk of text within milliseconds: Welcome to our servi...”
Enabling completion_events means the API will return a completion trace instead of a text (or speak) trace. There is a payload.state property which is one of three values:
state: "start"to signal the start of a completion stream.state: "content"to stream in additional text to the same text block, under thecontentpropertystate: "end"to signal that the completion is now finished, and the final LLM token usage
These trace types facilitate the delivery of text streaming as the large language model (LLM) generates the response message. Note, the content data may not always be in complete sentences or words.
It is the responsibility of the API caller to stitch the data together and have it reflect live on the conversation interface.
Examples
See our streaming-wizard demo (NodeJS). Note the use of the "end" state as a marker to start a new line in the conversation.
Deterministic and Streamed Messages
It may be jarring to pair this with existing deterministic messages that come out fully completed. Some messages stream in, while others are sent as whole. To mitigate this, you can either:
- create a fake streaming effect for deterministic messages that matches what messages streamed through completion events look like
- accumulate enough completion traces to form a complete sentence, and send group streamed responses into sentences before displaying them. Look for delimiters such as
.?!;\n(newline). You can then send the completion as a group of smaller complete messages.