Feature Request: Integrate Token Usage Cost Calculation Based on OpenAI's Pricing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 19.3k
- Forks
- 1.6k
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
Token Usage Cost Calculation:
I would like to request the addition of a feature that calculates the cost of token usage based on OpenAI's current pricing. This feature would allow developers to estimate the cost directly while using Tiktoken for tokenization.
Real-Time Pricing API:
While I understand that real-time pricing information was discussed in a separate issue (https://github.com/openai/openai-python/issues/2074), I believe it would be valuable to integrate this information into Tiktoken as soon as OpenAI provides an official API for retrieving current pricing.
Benefits:
- Cost Management: Helps developers manage their budget by providing instant token usage cost estimation.
- Optimization: Guides developers in optimizing token usage to avoid unnecessary costs.
- Convenience: Provides a seamless experience by consolidating tokenization and cost calculation in one place.
Thank you for considering this suggestion, and I look forward to any potential discussions!
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue does not name a file, test, or entry point. Start by reviewing tiktoken's public API and the discussion in openai/openai-python issue 2074, then determine whether an official OpenAI pricing API exists. Done would require an agreed pricing source and a defined interface for calculating token costs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100