←back to thread

268 points Areibman | 2 comments | | HN request time: 0s | source

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 source it to help developers avoid nasty bills.

Show context
refulgentis[dead post] ◴[] No.40714113[source]
[flagged]
visarga ◴[] No.40714335[source]
You don't like a repo, you don't use it. Stop shaming people for their open source repos.
replies(1): >>40714397 #
oopsallmagic ◴[] No.40714397[source]
When did the software community get so bad at handling legitimate critique?
replies(1): >>40714847 #
1. fbdab103 ◴[] No.40714847[source]
"You should really be ashamed of yourself for doing this" is an inappropriate response for basically anything but kicking puppies.
replies(1): >>40714946 #
2. anoncareer0212 ◴[] No.40714946[source]
That sounds somewhat specious, lying about what you support in your cost calculation library is a pretty big oof. It's hard to rank it versus kicking puppys, but, I don't think we have to stack-rank bad things to figure out if it's okay to call out unethical behavior.