Skip to main content

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 unit
  • get_cost_report: Property that returns a tuple of (usage_dict, cost_dict)

Usage Dictionary

  • prompt_tokens: Total prompt tokens used
  • completion_tokens: Total completion tokens used
  • cache_read_tokens: Tokens read from cache
  • cache_creation_tokens: Tokens used to create cache
  • tts_characters: Total characters synthesized
  • session_seconds: Total session duration in seconds

Cost Dictionary

  • llm_cost_prompt: Cost for prompt tokens
  • llm_cost_completion: Cost for completion tokens
  • llm_cost_cache_read: Cost for cache read tokens
  • llm_total_cost: Total LLM cost
  • tts_cost: Cost for TTS
  • stt_cost: Cost for STT
  • grand_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

pipecat_costing_sdk-0.0.4.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pipecat_costing_sdk-0.0.4-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file pipecat_costing_sdk-0.0.4.tar.gz.

File metadata

  • Download URL: pipecat_costing_sdk-0.0.4.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.7

File hashes

Hashes for pipecat_costing_sdk-0.0.4.tar.gz
Algorithm Hash digest
SHA256 941341e4b6d89805f0259a711850d1a8d4a379377b637538d22c40e3e3cce098
MD5 3c39d24674fde40d4ec41ae12a78b406
BLAKE2b-256 bf8b7d36e811e618a15ad465b8a5e4473c96899f099b986bbb90d7aadf7cac5f

See more details on using hashes here.

File details

Details for the file pipecat_costing_sdk-0.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for pipecat_costing_sdk-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 872c92f958cd3e11d6c2001dce1b6bdc785a02cf6e4af84f2c7b1f25d7147023
MD5 150e857daad6a169c96d3e155c5b8f00
BLAKE2b-256 48ff6abfd0caf25d32513085a0a2e35ae4e39254dbb53951f9f5f1a0412c598b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page