HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
AgentOps-AI
tokencost
Python2023–2024
AgentOps-AI / tokencost

tokencost

Easy token price estimates for 400+ LLMs. TokenOps.

4Distinct people
6Mentions
0Explicit recommenders
2KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Easy token price estimates for 400+ LLMs. TokenOps.

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

No other repository is repeatedly linked in the same discussions.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:03:16 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by week6 dated mentions

Observed mentions: 2023-12-27 01:22:25 UTC to 2024-06-19 01:24:30 UTC. Weeks start Monday, UTC.

0123452023-12-25 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 commentsDec 252024-01-01 00:00:00 UTC to 2024-01-08 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-08 00:00:00 UTC to 2024-01-15 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-15 00:00:00 UTC to 2024-01-22 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-22 00:00:00 UTC to 2024-01-29 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-01-29 00:00:00 UTC to 2024-02-05 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-02-05 00:00:00 UTC to 2024-02-12 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-02-12 00:00:00 UTC to 2024-02-19 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-02-19 00:00:00 UTC to 2024-02-26 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-02-26 00:00:00 UTC to 2024-03-04 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-03-04 00:00:00 UTC to 2024-03-11 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-03-11 00:00:00 UTC to 2024-03-18 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-03-18 00:00:00 UTC to 2024-03-25 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 commentsMar 182024-03-25 00:00:00 UTC to 2024-04-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-01 00:00:00 UTC to 2024-04-08 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-08 00:00:00 UTC to 2024-04-15 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-15 00:00:00 UTC to 2024-04-22 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-22 00:00:00 UTC to 2024-04-29 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-04-29 00:00:00 UTC to 2024-05-06 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-05-06 00:00:00 UTC to 2024-05-13 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-05-13 00:00:00 UTC to 2024-05-20 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-05-20 00:00:00 UTC to 2024-05-27 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-05-27 00:00:00 UTC to 2024-06-03 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-06-03 00:00:00 UTC to 2024-06-10 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-06-10 00:00:00 UTC to 2024-06-17 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2024-06-17 00:00:00 UTC to 2024-06-24 00:00:00 UTC (exclusive): 5 mentions; 1 submissions, 4 commentsJun 17

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
Dec 252023-12-25 00:00:00 UTC2024-01-01 00:00:00 UTC110
Jan 12024-01-01 00:00:00 UTC2024-01-08 00:00:00 UTC000
Jan 82024-01-08 00:00:00 UTC2024-01-15 00:00:00 UTC000
Jan 152024-01-15 00:00:00 UTC2024-01-22 00:00:00 UTC000
Jan 222024-01-22 00:00:00 UTC2024-01-29 00:00:00 UTC000
Jan 292024-01-29 00:00:00 UTC2024-02-05 00:00:00 UTC000
Feb 52024-02-05 00:00:00 UTC2024-02-12 00:00:00 UTC000
Feb 122024-02-12 00:00:00 UTC2024-02-19 00:00:00 UTC000
Feb 192024-02-19 00:00:00 UTC2024-02-26 00:00:00 UTC000
Feb 262024-02-26 00:00:00 UTC2024-03-04 00:00:00 UTC000
Mar 42024-03-04 00:00:00 UTC2024-03-11 00:00:00 UTC000
Mar 112024-03-11 00:00:00 UTC2024-03-18 00:00:00 UTC000
Mar 182024-03-18 00:00:00 UTC2024-03-25 00:00:00 UTC000
Mar 252024-03-25 00:00:00 UTC2024-04-01 00:00:00 UTC000
Apr 12024-04-01 00:00:00 UTC2024-04-08 00:00:00 UTC000
Apr 82024-04-08 00:00:00 UTC2024-04-15 00:00:00 UTC000
Apr 152024-04-15 00:00:00 UTC2024-04-22 00:00:00 UTC000
Apr 222024-04-22 00:00:00 UTC2024-04-29 00:00:00 UTC000
Apr 292024-04-29 00:00:00 UTC2024-05-06 00:00:00 UTC000
May 62024-05-06 00:00:00 UTC2024-05-13 00:00:00 UTC000
May 132024-05-13 00:00:00 UTC2024-05-20 00:00:00 UTC000
May 202024-05-20 00:00:00 UTC2024-05-27 00:00:00 UTC000
May 272024-05-27 00:00:00 UTC2024-06-03 00:00:00 UTC000
Jun 32024-06-03 00:00:00 UTC2024-06-10 00:00:00 UTC000
Jun 102024-06-10 00:00:00 UTC2024-06-17 00:00:00 UTC000
Jun 172024-06-17 00:00:00 UTC2024-06-24 00:00:00 UTC514

What Hacker News says

6 sources
>> tiktoken.encoding_for_model(model) > Calling this where model == 'gpt-4o' will encode with CL200k no? No, it will never use O200K, I don't know how to word where its located without sounding aggro, apologies: read below, i.e. the rest of the method. They copied demo code for Tiktoken with an allowlist without gpt-4o in it, because the demo code is from before 4o. The demo code has an allowlist, that does string matching, and if its not one of 5 models, none of which are gpt-4o, it says "eh, if it starts gpt-4, just use gpt-4-0613, and make a recursive call" You can't really blame them, because all they did was copy demo code from OpenAI from before gpt-4o, but I hope you get a giggle out of the extreme clown car this situation is. It's a really bad paper-thin out-of-date tiktoken wrapper that can only do c100k and claims support for 40
Read the rest
0 LLMs. Really bonkers. I know you gotta read the whole method to get it, but, people really shouldn't have just been like "my word! its mean to say they don't get it!" -- it's horrible. https://github.com/AgentOps-AI/tokencost/blob/e1d52dbaa3ada2...
In Show HN: Token price calculator for 400+ LLMs
I really appreciate your engagement here and think it has great value on a personal level, but the length and claims tend to hide two very obvious, straightforward things that are hilariously bad to the point its unbelievable: 1. They only support GPT3.5 and GPT4.0. Note here: [1], and that gpt-4o would get swallowed into gpt-4-0613. 2. This will lead to massive, significant, embarrassingly large error in calculations. Tokenizers are not mostly the same, within 10% error. # Explicating #1, Responsive to ex. "It's not just C100K though. It is for a few models [0]". The link is to Tiktoken, OpenAI's tokenization library. There are literally more than GPT3.5 and GPT4.0 there, but they're just OpenAI's models, no one else's, none of the others in the long list in their documentation, and certainly not 400. Most damning? There's only 2 other t
Read the rest
okenizers, long deprecated, used only for deprecated models not served anymore, thus you're not calculating costs with them. The only live ones are c100k and o200k. As described above, and shown in [1], their own code kneecaps the o200k and will use c100k # Explicating #2 Let me know what you'd want to see if you're curious about the 30%+ error thing. I don't want to guess at a test suite that would make you confident you need to revise a prior that there's only +/- 10% difference between arbitrary tokenizers. For context, I run about 20 unit tests, for each of the big 5 providers, with the same prompts, to capture their input and output token counts to make sure I'm billing accurately. # Conclusion Just to save you time, I think the best way I can provide some value is token count experiments demonstrating error. You won't be able to talk me down to "eh, lets just say its +/- 10%, thats good enough for most people!" --- It matters, if it didn't, they'd explicate at least some of this. Instead, its "tokenization for 400 LLMs!" [1] https://github.com/AgentOps-AI/tokencost/blob/e1d52dbaa3ada2...*
In Show HN: Token price calculator for 400+ LLMs
> Tangential critiques are preferable? Not at all. Reasoned arguments and adding information (the examples I gave were what I thought your main points were) to the discussion are preferable to (what seemed to be) character attacks. Your comment here, as an example, was mostly great. It provides the same level of usefulness to anyone reading it (highlighting that the computation is just C100K and that people will be misled if they try to use it the wrong way), and you also added reasoned counter-arguments to my OOM idea and several other interesting pieces of information. To the extent that you kept the character attacks against the author, you at least softened the language. Respectfully attacking ideas instead of people is especially important in online discourse like this. Even if you're right, attacking people tends to spiral a conver
Read the rest
sation out of control and convince no one (often persuading them of the opposite of whatever you were trying to say). > just C100K It's not just C100K though. It is for a few models [0], but even then the author does warn the caller (mind you, I prefer mechanisms like an `allow_approximate_token_count=False` parameter or whatever, but that's not fraud on the author's part; that's a dangerous API design). Going back to the "tone" thing, calling out those sorts of deficiencies is a great way to warn other people, let them decide if that sort of thing matters for their use case, point out potential flaws in your own reasoning (e.g., it's not totally clear to me if you think the code always uses C100K or always uses it for a subset of models, but if it's the former then you'd probably be interested in knowing that the tokenizer is actually correct for most models) and discuss better API designs. It makes everyone better off for having read your comment and invites more discussions which will hopefully also make everyone better off. > outside the realm of even needing a function Maybe! I'd argue that it's useful to have all those prices (especially since not all tokens are created equally) in one place somewhere, but arguing that this is left-pad for LLM pricing is also a reasonable thing to talk about. > it's impossible to get definitive error bars That's also true, but that doesn't matter for every application. E.g., suppose you want to run some process on your entire corporate knowledge-base and want a ballpark estimate of costs. The tokenizer error is on average much smaller than the 30%+ you saw for some specific (currently unknown to us here at HN) very small input. Just run your data through this tool, tally up the costs, and you ought to be within 10%. Nobody cares if it's a $900 project or a $1300 project (since nobody is allocating expensive, notoriously unpredictable developers to a project with only 10-30% margins). You just tell the stakeholders it'll cost $2k and a dev-week, and if it takes less then everyone is happily surprised. If they say no at that estimate, they probably wouldn't have been ecstatic with the result if it actually cost $900 and a dev-day anyway. [0] https://github.com/AgentOps-AI/tokencost/blob/main/tokencost...
In Show HN: Token price calculator for 400+ LLMs
Areibman·Jun 17, 2024Submission

Show HN: Token price calculator for 400+ LLMs

Hey HN! Tokencost is a utility library for estimating LLM costs. There are hundreds of different models now, and they all have their own pricing schemes. It’s difficult to keep up with the pricing changes, and it’s even more difficult to estimate how much your prompts and completions will cost until you see the bill. Tokencost works by counting the number of tokens in prompt and completion messages and multiplying that number by the corresponding model cost. Under the hood, it’s really just a simple cost dictionary and some utility functions for getting the prices right. It also accounts for different tokenizers and float precision errors. Surprisingly, most model providers don't actually report how much you spend until your bills arrive. We built Tokencost internally at AgentOps to help users track agent spend, and we decided to open sou
Read the rest
rce it to help developers avoid nasty bills.
268 points · Open discussion

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.