yachty66 / openai_pricing_logger

🚀 openai_pricing_logger: Track & log OpenAI API costs with ease. A Python package for monitoring GPT-3.5-turbo & GPT-4 usage costs. Lightweight, automatic cost logging. Ideal for developers, data scientists. OpenAI cost tracking, API logging, Python, GPT models
https://pypi.org/project/openai-pricing-logger/0.0.2/
MIT License
52 stars 1 forks source link

openai_pricing_logger

openai_pricing_logger is a Python package that logs OpenAI API costs and timestamps. It's designed to help you keep track of API usage and related costs, providing an easy way to monitor and analyze the expenses.

Features

Installation

To install openai_pricing_logger, run the following command in your terminal:

pip install openai_pricing_logger 

Usage

  1. Import the openai_api_listener context manager from the logger_package:
from logger_package import openai_api_listener
  1. Wrap your OpenAI API calls with the openai_api_listener context manager:
import openai

with openai_api_listener():
    # Your OpenAI API calls go here
  1. The package will automatically log the cost and timestamp of each API call to a file named api_calls.log in the current directory.

Contributing

Contributions are welcome! Please feel free to open issues and submit pull requests on the GitHub repository.

License

openai_pricing_logger is licensed under the MIT License.