Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Estimate token use/cost #17

Open
fn5 opened this issue Mar 27, 2023 · 2 comments
Open

Feature request: Estimate token use/cost #17

fn5 opened this issue Mar 27, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@fn5
Copy link

fn5 commented Mar 27, 2023

A low priority idea.
There is a slight delay between the use of tokens and when it shows up on the usage page: https://platform.openai.com/account/usage

It would be good to know the tokens required to send a query and/or the tokens used for a query.

Some ideas:

  • If a flag (confirmtokens) is set to true, after entering an input the number of tokens will be displayed and a further confirmation - like enter - is required to move on.
  • If a flag (showtokens) is set to true, the token usage / cost of an input will be displayed with the output such as [Tokens used: XX Est. Cost $0.0002]
  • The values should adjust based on which model is selected

OpenAI do provide some information on the way token usage should be estimated, or can be called from the API:
https://platform.openai.com/docs/guides/chat/introduction#:~:text=it%27s%20more%20difficult%20to%20count%20how%20many%20tokens

Can't immediately see pricing information via the API, however they are published here: https://openai.com/pricing

@evilpan
Copy link
Owner

evilpan commented Mar 27, 2023

Good idea! Token usage is a significant problem for online API call, especially for those expensive models (e.x $0.12 / 1K tokens for gpt-4-32k). I'd like to work on the showtokens feature first, and for the confirmtokens, maybe setting a money threshold to trigger the confirm would be better.

@evilpan evilpan added the enhancement New feature or request label Mar 27, 2023
@SDcodehub
Copy link

SDcodehub commented Jun 19, 2023

We alredy calculating tokens , we can get the pricing from the openai

Then calculate cost.

Make sure each time before going to query we check the cost condition

Add flag to arg parser

How is my approach, if you find it online i can work on this issue
@evilpan

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants