[{"data":1,"prerenderedAt":394},["ShallowReactive",2],{"project-40710154":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":28,"sentiment":29,"stance_mix":30,"scored_comments":34,"aspects":35,"strip":41,"post_text":44,"what":45,"said":78,"maker_in_thread":196,"shape":205,"grid":210,"attempts":352,"same_week":357,"maker_shows":31,"maker_hidden":386,"reader_version":387,"card":388},"40710154","Tokencost","Token price calculator for 400+ LLMs","title","Show HN: Token price calculator for 400+ LLMs","https:\u002F\u002Fgithub.com\u002FAgentOps-AI\u002Ftokencost","github.com","Areibman",1718653493,2024,268,76,265,3515,8,"legend","dev_tools","cost estimation library","library",[24,25,26,27],"llm cost","token counter","token pricing","openai pricing","curious",0.008,{"positive":31,"neutral":32,"mixed":33,"critical":31},2,20,0,24,{"design":36,"execution":37,"idea":38,"pricing":40},{"positive":33,"critical":33},{"positive":33,"critical":33},{"positive":31,"critical":39},1,{"positive":33,"critical":39},[42,42,33,33,33,42,42,42,33,42,33,33,33,33,33,33,33,33,42,43,33,33,33,39,33,33,42,33,33,42,42,42,42,39,42,33,42,42,43,42],3,5,"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.\n\nTokencost 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 ",{"problem":46,"audience":52,"pricing":57,"motivation":58,"time_to_build":57,"stack":62,"openness":75,"stage":76,"team_size":77},{"value":47,"source":48,"evidence":49},"Hard to track changing LLM pricing and estimate prompt and completion costs before the bill arrives","maker",[50],{"id":51},"post",{"value":53,"source":54,"evidence":55},"Developers building with LLMs and AI agents","inferred",[56],{"id":51},null,{"value":59,"source":48,"evidence":60},"Built internally at AgentOps to track agent spend, then open sourced to help developers avoid large bills",[61],{"id":51},[63,70],{"value":64,"source":54,"evidence":65},"Python",[66],{"id":67,"by":68,"text":69},"40710980","dudeinhawaii","It's open source so you can take a look (I'm not the author): https:\u002F\u002Fgithub.com\u002FAgentOps-AI\u002Ftokencost\u002Fblob\u002Fmain\u002Ftokencost\u002Fcosts.py It looks like tiktoken is the default for most…",{"value":71,"source":72,"evidence":73},"tiktoken tokenizer","commenter",[74],{"id":67,"by":68,"text":69},"open_source","unknown","company",{"praise":79,"objections":95,"requests":128,"questions":162,"alternatives":174},[80,91],{"value":81,"source":72,"evidence":82},"Useful for comparing model costs",[83,87],{"id":84,"by":85,"text":86},"40714720","jaredliu233","wow, this is really useful!! Just the price list alone has given me a lot of inspiration, thank you",{"id":88,"by":89,"text":90},"40720776","neverokay","Gemini also only charges for output tokens, not sure if that’s considered. All in all this is something I was looking for or was roughly going to do to compare costs. Cool stuff.",{"value":92,"source":72,"evidence":93},"Good to have a price list in one place",[94],{"id":84,"by":85,"text":86},[96,110,117],{"value":97,"source":72,"evidence":98},"Claude models listed without a real tokenizer, so counts may be inaccurate",[99,103,106],{"id":100,"by":101,"text":102},"40710871","simonw","I don't understand how the Claude functionality works. As far as I know Anthropic haven't released the tokenizer for Claude - unlike OpenAI's tiktoken - but your tool lists the…",{"id":104,"by":101,"text":105},"40711504","\"This package can be used to count tokens for Anthropic's older models. As of the Claude 3 models, this algorithm is no longer accurate [...]\" I've been bugging Anthropic about…",{"id":107,"by":108,"text":109},"40718459","spencerchubb","Some companies like Anthropic haven't publicly released the tokenizer used in their API, thereby making it impossible for this library to use the appropriate tokenizer in all…",{"value":111,"source":72,"evidence":112},"Some models show zero cost due to precision or data issues",[113],{"id":114,"by":115,"text":116},"40712031","Karrot_Kream","A whole bunch of the costs are listed as zeroes, with multiple decimal points. I noticed y'all used the Decimal library and tried to hold onto precision so I'm not sure what's…",{"value":118,"source":72,"evidence":119},"Per-token pricing is hard to compare across models",[120,124],{"id":121,"by":122,"text":123},"40711000","yelnatz","Can you do a column and normalize them? Too many zeroes for my blind ass making it hard to compare.",{"id":125,"by":126,"text":127},"40711040","ryaneager","Yeah a Tokens per $1 column would vastly help the readability.",[129,139,150,155],{"value":130,"source":72,"evidence":131},"Add Claude tokenizer support",[132,136],{"id":133,"by":134,"text":135},"40711095","refibrillator","> # TODO: Add Claude support There are no cases for Claude models yet. I wonder if anyone has run a bunch of messages through Anthropic's API and used the returned token count to…",{"id":137,"by":11,"text":138},"40711374","Anthropic actually has a Claude 3 tokenizer tucked away in one of their repos: https:\u002F\u002Fgithub.com\u002Fanthropics\u002Fanthropic-tokenizer-typescript At this moment, Tokencost uses the…",{"value":140,"source":72,"evidence":141},"Add image and vision cost calculation",[142,146],{"id":143,"by":144,"text":145},"40711050","ilaksh","Nice. Any plans to add calculations for image input for the models that allow that?",{"id":147,"by":148,"text":149},"40712467","jacobglowbom","Nice. Does it add Vision costs too?",{"value":151,"source":72,"evidence":152},"Show tokens per dollar or normalized price column",[153,154],{"id":121,"by":122,"text":123},{"id":125,"by":126,"text":127},{"value":156,"source":72,"evidence":157},"Add a Rust version",[158],{"id":159,"by":160,"text":161},"40718195","J_Shelby_J","Would anybody be interested in this for Rust? I already do everything this library does with the exception of returning the price in my LLM utils crate [1]. I do this just to…",[163,167],{"value":164,"source":72,"evidence":165},"How are Claude 3 token counts computed without a tokenizer",[166],{"id":100,"by":101,"text":102},{"value":168,"source":72,"evidence":169},"Does it account for function calls and images",[170],{"id":171,"by":172,"text":173},"40718055","pamelafox","Are you also accounting for costs of sending images and function calls? I didn't see that when I looked through the code. I developed this package so that I could count those…",[175,182,189],{"value":176,"source":72,"evidence":177},"LiteLLM model price file",[178],{"id":179,"by":180,"text":181},"40712600","zackfield","Very cool! Is this cost directory you're using the best source for historical cost per 1M tokens? https:\u002F\u002Fgithub.com\u002FBerriAI\u002Flitellm\u002Fblob\u002Fmain\u002Fmodel_prices_and_context_window.json",{"value":183,"source":72,"evidence":184},"openai-messages-token-helper",[185,186],{"id":171,"by":172,"text":173},{"id":187,"by":172,"text":188},"40718073","I have a package here that includes calculation for images for OpenAI: https:\u002F\u002Fgithub.com\u002Fpamelafox\u002Fopenai-messages-token-helper",{"value":190,"source":72,"evidence":191},"anthropic-tokenizer",[192],{"id":193,"by":194,"text":195},"40718364","GranPC","Sorta: https:\u002F\u002Fgithub.com\u002Fjavirandor\u002Fanthropic-tokenizer",{"comments":42,"answered":42,"key":197},[198,199,202],{"id":137,"text":138},{"id":200,"text":201},"40712982","Best one I've found out there. If there's another, very open to replacing",{"id":203,"text":204},"40711455","Perhaps at some point! Right now, we haven't been seeing most demand on the language side of things as multi-modal image really hasn't popped off yet",{"commenters":206,"max_depth":207,"maker_replies":42,"first_comment_mins":208,"lifespan_hours":209},44,7,63,186,[211,213,214,218,221,224,226,229,231,232,233,234,236,237,238,242,245,249,252,254,257,260,263,266,269,272,274,276,280,283,286,288,290,294,297,301,304,307,310,313,314,316,318,321,323,324,326,329,331,333,335,339,343,347,349,351],[121,33,42,212,122,33],"project\u002Fneutral\u002Fdesign",[125,33,42,212,126,33],[215,33,33,216,217,33],"40711163","commenter\u002Fneutral\u002Fnone","qeternity",[219,33,33,216,220,33],"40713082","Tao3300",[222,33,33,216,223,33],"40713795","andenacitelli",[225,33,33,216,220,33],"40713808",[227,33,33,216,228,33],"40717296","ynniv",[100,39,42,230,101,33],"project\u002Fneutral\u002Fexecution",[67,39,42,230,68,33],[133,39,42,230,134,33],[193,39,42,230,194,33],[235,39,33,216,101,33],"40711161",[137,39,33,230,11,39],[104,39,42,230,101,33],[239,39,33,240,241,33],"40711734","other\u002Fneutral\u002Fpricing","throwaway211",[243,39,33,240,244,33],"40712333","kevindamm",[246,39,33,247,248,33],"40712570","other\u002Fneutral\u002Fnone","MattGaiser",[250,39,33,240,251,33],"40714914","_flux",[253,39,33,247,244,33],"40727334",[255,39,33,240,256,33],"40715972","scoot",[258,39,33,240,259,33],"40749171","sitkack",[261,39,33,247,262,33],"40720216","szundi",[264,39,33,240,265,33],"40777992","Breza",[267,39,33,247,268,33],"40715060","itake",[270,39,33,240,271,33],"40717521","amanda99",[273,39,42,230,160,33],"40718095",[159,31,43,275,160,33],"project\u002Fpositive\u002Fidea",[277,42,42,278,279,33],"40711341","project\u002Fneutral\u002Fidea","Lerc",[281,42,33,216,282,33],"40712921","curious_cat_163",[284,42,33,216,285,33],"40713311","mvdtnz",[287,42,33,216,279,33],"40713472",[289,42,33,216,265,33],"40788282",[291,42,39,292,293,33],"40715521","project\u002Fcritical\u002Fidea","codewithcheese",[295,42,33,216,296,33],"40715879","michaelt",[298,299,33,247,300,33],"40711063",4,"Ilasky",[302,299,33,240,303,33],"40711502","SubiculumCode",[305,299,42,212,306,33],"40714327","visarga",[308,43,33,247,309,33],"40717573","sakex",[311,43,33,216,312,33],"40718221","weird-eye-issue",[107,43,33,216,108,33],[88,43,42,315,89,33],"project\u002Fneutral\u002Fpricing",[171,317,42,230,172,33],6,[319,207,42,278,320,33],"40714390","oopsallmagic",[322,207,42,278,251,33],"40714663",[179,18,42,230,180,33],[200,18,33,325,11,39],"maker\u002Fneutral\u002Fnone",[114,327,39,328,115,33],9,"project\u002Fcritical\u002Fpricing",[143,330,42,278,144,33],10,[203,330,33,332,11,39],"maker\u002Fneutral\u002Fidea",[334,330,33,247,172,33],"40718070",[336,337,42,278,338,33],"40717022",11,"yumaueno",[340,337,42,341,342,33],"40717214","project\u002Fneutral\u002Fnone","lgessler",[344,345,42,278,346,33],"40719275",12,"armen99",[84,348,43,275,85,33],13,[147,350,42,278,148,33],14,[187,350,33,247,172,33],[353,356],{"id":354,"t":355,"points":42,"comments":39},"38778028",1703640145,{"id":4,"t":12,"points":14,"comments":15},[358,363,368,372,377,382],{"id":359,"name":360,"points":361,"category":362},"40694254","MUREX Robotics network switch",666,"hardware",{"id":364,"name":365,"points":366,"category":367},"40717398","Radius",351,"consumer_social",{"id":369,"name":370,"points":371,"category":20},"40669337","Shpool",323,{"id":373,"name":374,"points":375,"category":376},"40719782","Billard",306,"creative",{"id":378,"name":379,"points":380,"category":381},"40722317","RTranslator",236,"languages",{"id":383,"name":384,"points":385,"category":20},"40700343","SQLite Database Explorer",188,false,"v2",{"id":389,"name":5,"line":6,"ai":386,"cat":20,"year":13,"points":14,"comments":15,"rec":28,"s":390,"top":18,"kw":391,"maker":11,"domain":10,"tier":19,"attempts":31,"strip":392,"url":9,"mix":393,"praise":81,"objection":97,"sub":21},40710154,0.01,[24,25,26,27],"3300033303000000003500010030033331303353",[31,32,33,31],1794036656423]