.. image:: https://img.shields.io/badge/chatGPT-74aa9c.svg?logo=openai
.. image:: https://img.shields.io/pypi/pyversions/setuptools.svg
==================
OpenAI Cost Logger
==================
* Simple **cost logger** for **OpenAI requests**.
* Track the cost of every request you make to OpenAI and visualize them in a user-friendly way.
* Homepage on `PyPI <https://pypi.org/project/openai-cost-logger/>`_.
* `Demo file <https://github.com/drudilorenzo/track-openai-cost/blob/master/demo.ipynb>`_ with a usage example.
How to install:
---------------
* .. code-block:: python
pip install openai-cost-logger
* .. code-block:: python
from openai_cost_logger import OpenAICostLogger
from openai_cost_logger import OpenAICostLoggerViz
from openai_cost_logger import OpenAICostLoggerUtils
from openai_cost_logger import DEFAULT_LOG_PATH, MODELS_COST
Key Features:
-------------
* Track the cost of every request you make and save them in a JSON file.
* Choose the feature you want to track (prompt_tokens, completion_tokens, completion, prompt, etc.).
* Check the cost of your requests filtering by model or strftime aggregation (see the docs).
Models supported:
-------------------
* The response generation is totally up to the user. The library support every model which response contains the fields **usage.prompt_tokens** and **usage.total_tokens** (e.g. chat completions, embeddings, etc.).
Note:
-----
* Every cost is specified per **million tokens**.
* If you don't specify the cost, the library will look to the **MODELS_COST** dictionary and get the cost of the model you are using. Be aware that if the model is not in the dictionary, an exception will be raised.
Viz example:
-------------
.. image:: images/example.png
:alt: Viz example (prints + plot)
:align: center
Raw data
{
"_id": null,
"home_page": "https://github.com/drudilorenzo/openai-cost-tracker",
"name": "openai-cost-logger",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": "openai, cost, logger, tracker, viz, llms",
"author": "Lorenzo Drudi | Mikolaj Boronski | Ivan Zakazov",
"author_email": "lorenzodrudi11@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/5a/7f/67f8f2881f000564738cd09dfbbb2cf6325801f000511c401b4a2ab37b15/openai-cost-logger-0.3.1.tar.gz",
"platform": null,
"description": ".. image:: https://img.shields.io/badge/chatGPT-74aa9c.svg?logo=openai\n.. image:: https://img.shields.io/pypi/pyversions/setuptools.svg\n\n==================\nOpenAI Cost Logger\n==================\n\n* Simple **cost logger** for **OpenAI requests**.\n* Track the cost of every request you make to OpenAI and visualize them in a user-friendly way.\n* Homepage on `PyPI <https://pypi.org/project/openai-cost-logger/>`_.\n* `Demo file <https://github.com/drudilorenzo/track-openai-cost/blob/master/demo.ipynb>`_ with a usage example.\n\nHow to install:\n---------------\n* .. code-block:: python\n\n pip install openai-cost-logger\n\n* .. code-block:: python\n\n from openai_cost_logger import OpenAICostLogger\n from openai_cost_logger import OpenAICostLoggerViz\n from openai_cost_logger import OpenAICostLoggerUtils\n from openai_cost_logger import DEFAULT_LOG_PATH, MODELS_COST\n\nKey Features:\n-------------\n* Track the cost of every request you make and save them in a JSON file.\n* Choose the feature you want to track (prompt_tokens, completion_tokens, completion, prompt, etc.).\n* Check the cost of your requests filtering by model or strftime aggregation (see the docs).\n\nModels supported:\n-------------------\n* The response generation is totally up to the user. The library support every model which response contains the fields **usage.prompt_tokens** and **usage.total_tokens** (e.g. chat completions, embeddings, etc.).\n\nNote:\n-----\n* Every cost is specified per **million tokens**.\n* If you don't specify the cost, the library will look to the **MODELS_COST** dictionary and get the cost of the model you are using. Be aware that if the model is not in the dictionary, an exception will be raised.\n\nViz example:\n-------------\n.. image:: images/example.png\n :alt: Viz example (prints + plot)\n :align: center\n\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "OpenAI Cost Logger",
"version": "0.3.1",
"project_urls": {
"Homepage": "https://github.com/drudilorenzo/openai-cost-tracker"
},
"split_keywords": [
"openai",
" cost",
" logger",
" tracker",
" viz",
" llms"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "5a7f67f8f2881f000564738cd09dfbbb2cf6325801f000511c401b4a2ab37b15",
"md5": "5b226ffe0d2eab0be84914e33af57eb5",
"sha256": "2cf033d05ef0a6155728c260bc47718d4fe804c74efafd474e74a61808df8ca1"
},
"downloads": -1,
"filename": "openai-cost-logger-0.3.1.tar.gz",
"has_sig": false,
"md5_digest": "5b226ffe0d2eab0be84914e33af57eb5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 6206,
"upload_time": "2024-04-27T13:48:24",
"upload_time_iso_8601": "2024-04-27T13:48:24.383707Z",
"url": "https://files.pythonhosted.org/packages/5a/7f/67f8f2881f000564738cd09dfbbb2cf6325801f000511c401b4a2ab37b15/openai-cost-logger-0.3.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-04-27 13:48:24",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "drudilorenzo",
"github_project": "openai-cost-tracker",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "openai",
"specs": [
[
"==",
"1.13.3"
]
]
},
{
"name": "matplotlib",
"specs": [
[
"==",
"3.6.3"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"7.4.2"
]
]
}
],
"lcname": "openai-cost-logger"
}