Skip to main content

Tool for estimating the cost of using different OpenAI API models

Project description

GPT Cost Estimator

This Python package, GPTCostCalculator, provides a simple yet effective tool for estimating the cost of using different ChatGPT models. It is designed for anyone using ChatGPT models in their applications and need to estimate the cost of a particular query. You do NOT need an OpenAI API key to use this package.

Features

  • Provides cost estimation for input and output tokens of various ChatGPT models.
  • Supports multiple models including GPT-4, GPT-4-32k, GPT-4-1106-preview, GPT-3.5-turbo-1106, and GPT-3.5-turbo-instruct.
  • Easy integration with existing Python projects.

Supported Models

As of the current release, the package supports the following ChatGPT models:

  • gpt-4: Input Price - $0.03, Output Price - $0.06 per 1000 tokens.
  • gpt-4-32k: Input Price - $0.06, Output Price - $0.12 per 1000 tokens.
  • gpt-4-1106-preview: Input Price - $0.01, Output Price - $0.03 per 1000 tokens.
  • gpt-3.5-turbo-1106: Input Price - $0.001, Output Price - $0.002 per 1000 tokens.
  • gpt-3.5-turbo-instruct: Input Price - $0.0015, Output Price - $0.002 per 1000 tokens.

Installation

To install the package, simply run the following command:

pip install GPTCostCalculator

Usage

Here is a basic example of how to use the package:

from GPTCostCalculator import Calculator

# Initialize the calculator
calculator = Calculator()

# Estimate the cost
report = estimator.cost_estimate(model="gpt-4", input_text="Your input text here", output_text="Expected output text", info_text = True)

output_text is not mandatory.

Dependencies

  • tiktoken: Used for tokenizing the input and output texts.

Contributing

Contributions to the GPTCostCalculator package are welcome. Please feel free to fork the repository, make your changes, and create a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contact

For any queries or feedback, please contact me.

Disclaimer

Please note that the costs provided by this package are estimates and may vary based on actual usage of ChatGPT models.

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

GPTCostCalculator-1.0.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

GPTCostCalculator-1.0.1-py3-none-any.whl (4.6 kB view hashes)

Uploaded Python 3

Supported by

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