Skip to main content
Streaming responses are beneficial for providing real-time updates, enhancing user interaction by allowing text to be displayed as it’s generated. This approach improves user experience by lowering perceived latency — letting text appear word by word, similar to typing, instead of a single block at the end.
Streaming Example
When you use Pawa Chat or the Sandbox, you’re already benefiting from streaming: the text flows in gradually, enhancing interactivity and responsiveness.
Streaming responses use Server-Sent Events (SSE) to deliver partial outputs (deltas) in real time, instead of waiting for the entire generation to complete. To enable streaming, you must set stream : true in your chat request request, or agent chat request. But for the text to speech streaming is already done on our side so you change the request set-up to stream the response from our servers.

Basic chat request with Streaming

Streaming Response Example

You will receive the chunks of the response, been given out at a time, so so you should show that to the user in real-time.

Tool calling request with Streaming.

In a tool-calling request, when the model decides to call one of your custom tools, it will not stream the response, even if stream=true is set.
This makes it easier to parse the tool response and then send a follow-up request.

Response format example for tools calling stream

Error recovery

When a streaming request is interrupted due to network issues, timeouts, or other errors, you can recover by resuming from where the stream was interrupted. This approach saves you from re-processing the entire response.

The basic recovery strategy involves:

  • Capture the partial response: Save all content that was successfully received before the error occurred
  • Construct a continuation request: Create a new API request that includes the partial assistant response as the beginning of a new assistant message
  • Resume streaming: Continue receiving the rest of the response from where it was interrupted ​