告诉HN:我将Claude API的费用从每月70美元降到了几分钱。

13作者: ok_orco大约 9 小时前原帖
第一次在运行 Chatter.Plus(我正在开发的一个工具,用于汇总来自 Discord、GitHub 和论坛的社区反馈)一天后查看使用成本时,我看到的费用是 2.30 美元。算了一下,按月算是 70 美元,按年算是 840 美元。仅仅是一个实例,感觉非常糟糕。 我之前做过粗略的计算,所以知道这可能是个 bug,但仍然感到不安。结果发现这只是部分是 bug,其余的则是我需要重新思考我构建这个工具的方式。 接下来的几天我花时间拆解它,进行调整,使用实时数据进行测试,检查结果,再次尝试。我发现我发送 API 请求的频率太高,并且没有优化我发送和接收的数据。 以下是我所做的改进,按影响程度从大到小排列(除了那个每天花费我一美元的 bug): - 完全放弃了 Claude Sonnet - 在相同数据上测试了两个模型,Haiku 实际上以三分之一的成本表现更好。 - 开始对所有请求进行批处理 - 每小时调用一次简直就是在烧钱。 - 在 AI 处理之前进行过滤 - “哈哈”和“谢谢”是很多在线聊天内容。我在花钱让 AI 告诉我这些不是反馈。尽管如此,我仍然会处理像“+1”和“我也是”这样的协议。 - 输出更简短 - 使用“H/M/L”代替“高/中/低”,推荐 40 个字符的标题。 - 在处理之前剔除代码片段 - 只是重复问题,导致请求膨胀。 到周末时:每天只需几分钱,质量依然如故。 我并不是在构建一个可以亏损运营多年的风险投资支持的应用。我失业了,正在尝试构建一些可能也能支付房租的东西。这个数学模型必须从第一天起就能奏效。 好处是:这些节省让我可以将定价层级限制提高三倍,并增加间歇性的质量检查。这是我原本无法获得的余地。 欢迎提问。
查看原文
The first time I pulled usage costs after running Chatter.Plus - a tool I&#x27;m building that aggregates community feedback from Discord&#x2F;GitHub&#x2F;forums - for a day hours, I saw $2.30. Did the math. $70&#x2F;month. $840&#x2F;year. For one instance. Felt sick.<p>I&#x27;d done napkin math beforehand, so I knew it was probably a bug, but still. Turns out it was only partially a bug. The rest was me needing to rethink how I built this thing. Spent the next couple days ripping it apart. Making tweaks, testing with live data, checking results, trying again. What I found was I was sending API requests too often and not optimizing what I was sending and receiving.<p>Here&#x27;s what moved the needle, roughly big to small (besides that bug that was costin me a buck a day alone):<p>- Dropped Claude Sonnet entirely - tested both models on the same data, Haiku actually performed better at a third of the cost<p>- Started batching everything - hourly calls were a money fire<p>- Filter before the AI - &quot;lol&quot; and &quot;thanks&quot; are a lot of online chatter. I was paying AI to tell me that&#x27;s not feedback. That said, I still process agreements like &quot;+1&quot; and &quot;me too.&quot;<p>- Shorter outputs - &quot;H&#x2F;M&#x2F;L&quot; instead of &quot;high&#x2F;medium&#x2F;low&quot;, 40-char title recommendation<p>- Strip code snippets before processing - just reiterating the issue and bloating the call<p>End of the week: pennies a day. Same quality.<p>I&#x27;m not building a VC-backed app that can run at a loss for years. I&#x27;m unemployed, trying to build something that might also pay rent. The math has to work from day one.<p>The upside: these savings let me 3x my pricing tier limits and add intermittent quality checks. Headroom I wouldn&#x27;t have had otherwise.<p>Happy to answer questions.