miniature-nail-35141
11/29/2025, 8:57 AMtall-airline-16756
11/29/2025, 8:57 AMtall-airline-16756
11/29/2025, 8:58 AMresponse_text = ""
handle = session.generate_reply(user_input="What is the capital of France?")
async for chunk in handle.text_stream:
response_text += chunk
print(response_text)
• Node.js
const handle = session.generateReply({ userInput: "What is the capital of France?" });
let response = "";
for await (const chunk of handle.textStream()) {
response += chunk;
}
console.log(response);
If you want finer control over LLM inputs/outputs (tool use, custom prompts, or different streaming behavior), you can override llm_node() in your Agent subclass. Would you like an example that fits your language (Python/Node) or a sample Agent override?
Sources: Tool definition and use | LiveKit docs | External data and RAG | LiveKit Docs | Agent session | LiveKit docs | Agents v0.x migration guide - Python | LiveKit docs | Pipeline nodes and hooks | LiveKit docsminiature-nail-35141
11/29/2025, 9:00 AMtall-airline-16756
11/29/2025, 9:01 AMSpeechHandle controls audio playout and does not expose a text stream. To get the LLM's string output programmatically, use one of these options.
Which language are you using (Python or Node)? Pick one and I’ll give the exact snippet for your environment.
Options:
• Capture the final LLM text from the session events (recommended if you're inside AgentSession).
◦ Listen for conversation_item_added and read event.item.text_content when role == "agent" — that contains the LLM/TTS input text.
• Intercept the LLM stream by overriding llm_node in your Agent subclass (recommended if you want raw streaming chunks before TTS).
◦ In your override, iterate the default llm_node output, collect chunk.delta.content (or the string chunks), then yield them.
• Skip the agent pipeline and call the LLM directly (if you only need strings, not TTS/STT).
◦ Use the LLM chat API to stream and concatenate chunk.delta.content into a final string.
Tell me your language and whether you want streaming or just the final string and I’ll post the specific code.
Sources: Agent speech and audio | LiveKit docs | Sending text | LiveKit docs | Text and transcriptions | LiveKit docs | Pipeline nodes and hooks | LiveKit docs