To help you keep a close eye on costs for both LiveKit and OpenAI real-time usage, here’s a friendly step-by-step guide:
1. OpenAI Real-Time Cost Monitoring:
- You can use the metrics_collected event to track token usage, including input, output, and cached tokens.
- Then, calculate costs based on the token rates for text and audio.
- For example: input_cost = input_tokens * INPUT_TOKEN_RATE.
2. LiveKit Cost Monitoring:
- Keep track of important elements like connection minutes, bandwidth usage, and transcoding minutes.
- Use formulas such as Bandwidth Cost = Total Bandwidth (GB) × cost per GB to estimate expenses.
3. Real-Time Tracking System:
- It’s great to set up a system that logs session metadata, calculates costs in real-time, and even sends alerts when you’re nearing your budget limits.
4. Unified Monitoring:
- Consider using LiveKit Inference to bring together billing for both OpenAI and LiveKit usage—this can make tracking much simpler.
If you’d like, I’m here to walk you through the details of setting up these monitoring systems or help you create those cost alerts. Just let me know! Sources:
livekit-plugins/livekit-plugins-openai/README.md |
Understanding LiveKit Cloud Pricing |
agent-examples/.env.examples |
LiveKit Blog