Get a costing of voice ai pipeline. when call ends
Project description
Pipecat Costing SDK
A Python SDK for calculating costs associated with voice AI pipelines using Pipecat metrics. This library helps track and estimate costs for LLM, TTS, and STT usage in real-time voice applications.
Features
- Tracks LLM token usage (prompt, completion, cache read, cache creation)
- Monitors TTS character count
- Estimates session duration for STT costs
- Provides detailed cost breakdowns and grand totals
- Integrates seamlessly with Pipecat's frame processing pipeline
Installation
Install the package from PyPI:
pip install pipecat-costing-sdk
Usage
from pipecat_costing_sdk import CostLogger
# Initialize the cost logger with pricing rates
cost_logger = CostLogger(
PRICE_PER_1K_PROMPT_TOKENS=0.0015,
PRICE_PER_1K_COMPLETION_TOKENS=0.002,
PRICE_PER_1K_CACHE_READ_TOKENS=0.00075,
PRICE_PER_1K_CACHE_CREATION_TOKENS=0.00125,
PRICE_PER_1K_TTS_CHARS=0.015,
PRICE_PER_STT_MINUTE=0.011
)
# Integrate into your Pipecat pipeline
# (Assuming you have a pipeline set up with metrics frames)
# After processing, get the cost report
usage, costs = cost_logger.get_cost_report
print("Usage:", usage)
print("Costs:", costs)
API Reference
CostLogger
__init__(PRICE_PER_1K_PROMPT_TOKENS: float, PRICE_PER_1K_COMPLETION_TOKENS: float, PRICE_PER_1K_CACHE_READ_TOKENS: float, PRICE_PER_1K_CACHE_CREATION_TOKENS: float, PRICE_PER_1K_TTS_CHARS: float, PRICE_PER_STT_MINUTE: float): Initialize with pricing rates per unitget_cost_report: Property that returns a tuple of (usage_dict, cost_dict)
Usage Dictionary
prompt_tokens: Total prompt tokens usedcompletion_tokens: Total completion tokens usedcache_read_tokens: Tokens read from cachecache_creation_tokens: Tokens used to create cachetts_characters: Total characters synthesizedsession_seconds: Total session duration in seconds
Cost Dictionary
llm_cost_prompt: Cost for prompt tokensllm_cost_completion: Cost for completion tokensllm_cost_cache_read: Cost for cache read tokensllm_total_cost: Total LLM costtts_cost: Cost for TTSstt_cost: Cost for STTgrand_total: Total cost for the session
Dependencies
- pipecat
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Support
If you encounter any issues or have questions, please open an issue on GitHub.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pipecat_costing_sdk-0.0.5.tar.gz.
File metadata
- Download URL: pipecat_costing_sdk-0.0.5.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b6c0a5c8d9ae792180f6126d932ac1ac86c63021c062b90b931021a7d2ae546
|
|
| MD5 |
dd7c3a7136aca1ae8cfb1a8d02b68334
|
|
| BLAKE2b-256 |
b01e0d3b3284aad92cb868f8588cc64ddfbec5cad98860f1ce8ba1d912effcab
|
File details
Details for the file pipecat_costing_sdk-0.0.5-py3-none-any.whl.
File metadata
- Download URL: pipecat_costing_sdk-0.0.5-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5fe72c3b4cd74089e32b15f5b86810147ae5e3e74b672dfabbdbe6ebb63892f1
|
|
| MD5 |
900a45d8ff11998ac731ffd32ec9ea8e
|
|
| BLAKE2b-256 |
b6e090efe8067fcb5a9a63521fb8c299f84848b85d4646a7d243212fdc760e20
|