raviraina_
06/09/2025, 3:35 PMAI Evy
06/09/2025, 3:35 PMAI Evy
06/09/2025, 3:35 PMcontent_complete: false for partial content, and only set content_complete: true for the final event [(2) ]() . Here's how this works:
Node.js streaming example:
typescript
for await (const event of events) {
if (event.choices.length >= 1) {
let delta = event.choices[0].delta;
if (!delta || !delta.content) continue;
const res: RetellResponse = {
response_id: request.response_id,
content: delta.content,
content_complete: false,
end_call: false,
};
ws.send(JSON.stringify(res) ) ;
}
}
[(1) ]()
Python streaming example:
python
for chunk in stream:
if chunk.choices[0].delta.content is not None:
yield {
"response_id": request['response_id'],
"content": chunk.choices[0].delta.content,
"content_complete": False,
"end_call": False,
}
The key is using the content_complete field to indicate whether each chunk is partial (false) or final (true) content [(2) ]() . This token-level streaming approach helps reduce latency, which is crucial for conversational AI [(3) ]() .AI Evy
06/09/2025, 3:35 PMAI Evy
06/09/2025, 3:35 PMraviraina_
06/09/2025, 3:37 PMAI Evy
06/09/2025, 3:37 PMAI Evy
06/09/2025, 3:37 PMcontent_complete is true [(1) ]() . The streaming logic works as follows:
- The voice agent will start streaming when a complete sentence is met
- Or will start streaming once the content is complete
This is designed to generate audio with proper tonality context . A complete sentence is identified by punctuations (apart from special cases like "Dr.") . Retell also has logic to stream based on timeout .
So you don't need to wait for the entire message - the agent can begin speaking as soon as it receives a complete sentence with proper punctuation, even when content_complete is still false . However, it's still recommended to set content_complete to true after you finish the response, so Retell knows your agent is done for that turn .AI Evy
06/09/2025, 3:37 PMAI Evy
06/09/2025, 3:37 PM