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

[Bug]: How to calculate the cost of llm api token used in headless mode #349

Open
kevin-support-bot bot opened this issue Apr 2, 2025 · 1 comment

Comments

@kevin-support-bot
Copy link

All-Hands-AI#7649 Issue


@krishgcek, Would you run with DEBUG=1 environment variable?

@Rahulg-ai
Copy link

So, to figure out how much you're spending on tokens in headless mode, just check the usage field in the API response — it tells you how many prompt and completion tokens were used.

Then, look up the token pricing for the model you're using (like GPT-4 or GPT-3.5). Each one charges a certain amount per 1,000 tokens for both input and output.

Now do some quick math:
(prompt tokens / 1000 * prompt price) + (completion tokens / 1000 * completion price) — and that’s your cost for that call.

If you're doing this often, just log the usage automatically and have a script add it all up for you.

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

No branches or pull requests

1 participant