chilly-nest-87883
07/25/2025, 12:06 AMtall-airline-16756
07/25/2025, 12:06 AMtall-airline-16756
07/25/2025, 12:07 AMLK_OPENAI_DEBUG environment variable:
export LK_OPENAI_DEBUG=1
When enabled, this will automatically log all OpenAI API events, including streaming responses. The logs will include outgoing messages (e.g., >>> {msg}) and incoming events (e.g., <<< {event}).
2. Built-in Event Logging
The LiveKit OpenAI plugin automatically logs various streaming events, such as:
• response.text.delta - Text streaming chunks
• response.audio.delta - Audio streaming chunks
• response.audio_transcript.delta - Audio transcript streaming
• response.content_part.done - When content parts complete
• response.done - When the entire response completes
For audio delta events, the actual audio data is replaced with "..." in the logs to avoid logging large binary data.
3. Custom Logging
You can implement custom logging by accessing the logger directly:
from livekit.plugins.openai.log import logger
# Log with additional context
logger.debug("Custom log message", extra={"custom_data": "value"})
4. Event Emission
The realtime model emits raw events that you can listen to for custom logging:
# The raw JSON event is emitted
self.emit("openai_server_event_received", event)
Using LK_OPENAI_DEBUG=1 is the most straightforward way to log all OpenAI streaming responses without requiring code changes.
Sources: livekit-plugins/livekit-plugins-openai/livekit/plugins/openai/realtime/real... | plugins/openai/src/realtime/realtime_model.tschilly-nest-87883
07/25/2025, 12:30 AMtall-airline-16756
07/25/2025, 12:31 AMchilly-nest-87883
07/25/2025, 12:39 AM