brash-barista-66564
07/31/2025, 9:11 AMtall-airline-16756
07/31/2025, 9:11 AMtall-airline-16756
07/31/2025, 9:12 AMstream=True and stream_options={"include_usage": True} when calling the OpenAI chat completions API.
• JavaScript Implementation: Similarly, the JavaScript version enables streaming with stream: true and stream_options: { include_usage: true } in the chat completions request.
For example, in Python:
from livekit.plugins import openai
from livekit.agents import ChatContext
llm = openai.LLM(model="gpt-4o-mini")
chat_ctx = ChatContext()
chat_ctx.add_message(role="user", content="Hello, this is a test message!")
# Streaming happens automatically
stream = llm.chat(chat_ctx=chat_ctx)
async for chunk in stream:
# Process streaming chunks
pass
The plugin handles all the streaming configuration internally, so you can achieve real-time text streaming without any additional setup.
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/__init__.py | plugins/openai/src/realtime/realtime_model.ts | Large language model (LLM) integrations | LiveKit Docsbrash-barista-66564
07/31/2025, 9:16 AMtall-airline-16756
07/31/2025, 9:18 AM