https://github.com/danieldacosta/gpt-pricing-calculator
Pricing calculator for OpenAI GPT API
https://github.com/danieldacosta/gpt-pricing-calculator
gpt nlp
Last synced: over 1 year ago
JSON representation
Pricing calculator for OpenAI GPT API
- Host: GitHub
- URL: https://github.com/danieldacosta/gpt-pricing-calculator
- Owner: DanielDaCosta
- License: mit
- Created: 2024-06-24T21:48:44.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-18T04:46:48.000Z (almost 2 years ago)
- Last Synced: 2025-01-11T01:10:36.847Z (over 1 year ago)
- Topics: gpt, nlp
- Language: Python
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GPT Pricing Calculator
Pricing calculator for OpenAI GPT API
**tiktoken library**
```
pip install tiktoken
```
## Usage
**Example input**
```json
example_message = [
{
"role": "system",
"content": "You are a helpful, pattern-following assistant that translates corporate jargon into plain English.",
},
{
"role": "system",
"name": "example_user",
"content": "New synergies will help drive top-line growth.",
},
{
"role": "system",
"name": "example_assistant",
"content": "Things working well together will increase revenue.",
},
{
"role": "system",
"name": "example_user",
"content": "Let's circle back when we have more bandwidth to touch base on opportunities for increased leverage.",
},
{
"role": "system",
"name": "example_assistant",
"content": "Let's talk later when we're less busy about how to do better.",
},
{
"role": "user",
"content": "This late pivot means we don't have time to boil the ocean for the client deliverable.",
},
]
```
**Command**
Input Params:
- `--model_name`: `gpt-4`, `gpt-3.5`...
- `--file_path`: JSON
```python
python pricing-calculator.py gpt-4 messages_example.json
```
**Output**
```python
Warning: gpt-4 may update over time. Returning num tokens assuming gpt-4-0613.
129 prompt tokens counted by count_num_tokens_message().
```