📱

Get Our Mobile App

Take your business learning on the go!

Download on the App StoreGet it on Google Play

I Cut My OpenClaw Costs by 95% (Here's How)

Nick Puru | AI Automation18:07

Transcription

Your Claudebot is running up your API bill right now and you have no idea. Now, while you are watching this video, while you are sleeping tonight, while you are doing literally anything else, your agent, it is making API calls that you never asked for. And every single one of them, it is costing you money for absolutely nothing.

I found this out the hard way recently. I've been running my Clawbot for about a week, maybe two weeks, sending a few messages a day through Telegram, having it do some background monitoring. Nothing too crazy, right? Then I checked my anthropic dashboard and the number made zero sense. I mean, I was burning through $50 a week and most of it was just happening while I was not even using the agent.

So, I did something that most people never bother doing. I went through my API logs line by line and I did a full cost audit. I tracked every single token, where it went, what triggered it, and whether it actually produced anything actually useful. And what I found out was that about 85% of the total spend had nothing to do with the work that I was actually asking the agent to do. It was all just background noise. So invisible overhead. There was money disappearing into simple processes that I never actually initiated.

And once I understood what was happening, I fixed it. My weekly cost jumped from, you know, about $50 to less than $10. Same agent, same task, same capabilities, just configured properly.

In this video, I'm going to be showing you exactly what those invisible costs actually are, how to find them in your own setup, and the three layers of fixes that actually brought my own spend down personally. I've also built a companion guide that I will have on screen as we go through each section. So, you can grab it for free. Link will be down below in the description. Let's get into it.

Okay, so the first thing that you need to do, and honestly, I think this is the most valuable part of this entire video, is understand where your money is actually going. Because until you do this, you are quite literally just guessing. and guessing is how you end up overpaying for months without actually knowing it. So, here's how to run a basic cost audit on your Claudebot. Just go to your Enthropic dashboard, pull up your usage logs, and start looking at the individual API calls. Now, what you're looking for is going to be three different things. What triggered the call, how many tokens it actually consumed, and whether the output was something that you actually needed.

Now, when I did this, I found that my spend it fell into actually three different categories. And the split wasn't really what I had expected. I would say the least. So about 60% of my total spend was pure overhead. So these were just calls that happened automatically in the background without me asking for anything at all. Now the biggest culprit was something called the heartbeat. I'll explain this in a second, but if you've been using CloudBot, you're probably familiar with the heartbeat or at least you have seen it. But there were also these session loads, these context refreshes and memory compiles that I never requested and I never saw the actual results of.

Now about 25% was what I would call misdirected spend. Now these were real tasks, things I had actually asked my agent to do, but they were just being handled by a model that was way too powerful for what the task actually required. So you can think of it like paying a surgeon to put on a band-aid. The task gets done, but you are just massively overpaying for it.

And then there was only about 15% of my spend on actual productive work. So these are tasks that I had requested, handled by inappropriately powered model producing output that I actually had used. So about 85% of my money was either just wasted entirely or poorly allocated. And I bet if you run the same audit on your own setup, you will find something that's going to be very similar to this as well.

Now, let me show you what was specifically eating that 60% overhead. So this is the heartbeat problem where your agent, it runs a background process called a heartbeat. So, this is just a periodic check-in every 30 to 60 minutes by default where the agent basically is just asking itself, am I still running? Anything need attention? Is there any open tasks? Now, it's the simplest possible operation. It's quite literally just a status check. But here's what's actually happening under the hood of that. Every time that heartbeat fires, it doesn't just send a tiny ping. It actually loads your entire context. So things like your personality file, your memory, your user file, your session history, all of it is getting compiled and sent to the API as part of the request. So what should be a 2C status check often turns into a full API call with tens of thousands of tokens attached. And this is happening around the clock. So even at 3:00 a.m. when you're asleep, when you're not using it, even on the weekends when you haven't touched the agent in 2 to 3 days, it just keeps on firing off. So when I added up the heartbeat costs alone over a week, it accounted for almost 40% of my total spend for nothing. Literally for my agent just confirming to itself that it actually exists.

Next up is the context loading problem. So the second piece of that overhead is just how your agent handles context on every single interaction. So when you send a message, your agent doesn't just read your message. It first compiles everything that it thinks it might need. So your full conversation history, all your context files, previous tool outputs, memory archives, all of this just gets loaded into the request before your agent even looks at what you actually said. Now on my setup, this just meant that every single message was carrying about 40 to 60 kilobytes of context. Now, most of which was completely relevant to what I was asking, but I would send a message like, "What is on my calendar today?" And the API call would just include three weeks of conversation history in every file in my workspace. So that is the overhead.

Now let me show you how I fixed it. Starting with the biggest impact change and I'm just going to be working down from there. So the first layer of fixes targets that 60% overhead. So that is just going to be the stuff that is costing you money without producing any value whatsoever. Now there's going to be two different changes here and together they limited almost all of the invisible drain that was going on.

So fix a this is just redirecting our background processes to a free local model. So the heartbeat it doesn't need intelligence. It does not need claw. It does not need any paid API at all. It is just checking the system status. So the fix is to run a free language model locally on your machine and pointing your heartbeat at that instead. So there's actually tool called Lama. Coincidentally, I just uploaded a video on how to utilize this that makes this dead simple. So there's just going to be two terminal commands. So you just install Lama. You put a small model on there. I'm running a three billion parameter model that takes up about 2 GB of storage and it runs on basically any machine and it handles the status checks instantly and then from there you just update one setting in your cloudbot configuration file to tell the heartbeat to use your local models instead of cloud and that is practically the entire fix. Now every background check it is firing locally. It costs nothing and it doesn't count against your API rate limits. Huge save. I kept getting rate limit errors by Enthropic and I for the life of me could not figure it out because I wasn't even using the agent that heavily. So when I checked the logs, I just realized that every heartbeat was a full API call loading my entire context. So not only was I paying for these, they were also eating into my rate limit budget and just causing actual tasks to just completely fail. So once I moved the heartbeats off of this paid API, both problems they had disappeared. So the impact of this, this was about 40% of my spend that was just going to heartbeats going to zero overnight.

Fix B was telling our agents exactly what to load. So the other half of the overhead problem, it is just coming down to context loading. Fix it is pretty straightforward. This is just where we added a rule to our agents system prompt that just explicitly defined what gets loaded on startup and what actually stays on disk until your agent actually needs it. So here's what I tell my agent on every session start. Load only four different things. your core operating file, my user profile, the Asian identity, and today's notes if they do happen to exist. That's going to be it. Everything else is just full memory archives, old conversation history, previous tool outputs, and none of that loads automatically. But the important part with this is that your agent still has access to everything. So, it just retrieves information on demand. So if I ask something about whatever it was from last week, it searches for the relevant piece instead of just preloading every single conversation that we have ever had. So think of it like a search engine versus reading every single page in the internet before answering your questions. Now at the end of each session, what the agent does is it just saves a quick summary of what we had worked on and any open items. So your memory, it stays organized in daily files instead of just becoming one giant blob that is just going to grow and grow forever. Now before I made this change, every single interaction it carried about 40 to 60 kilobytes of context overhead. After this came to be about 6 to 10 kilobytes and because you are paying per token that's a direct cost reduction on every single API call that your agent actually makes. So and not just the ones that you are initiating but also any automated tasks or any scheduled reports anything like that. Now between redirecting the heartbeats and controlling context loading that 60% overhead category it essentially goes to zero.

Now, let's deal with the 25% that was being misdirected. Okay, so at this point, the invisible drain is gone, but you're still overpaying on the work that your agent actually does because by default, every single task, no matter how simple it is, it gets routed through the same premium model, which is most commonly opus 4.5, maybe 4.6. So, that leads us to Fixie, matching the model to the job. So, Enthropic, they do offer multiple different models at very different price points, as you should probably already know. But now the one that most people default to Sonnet 4.5 or Opus 4.5 or 4.6. It is excellent for complex reasoning, writing strategic work, but it's overkill for about 80% of what your agent actually does dayto-day. So think of like checking files, organizing data, sending formatted messages, or even pulling information from memory. Now, none of that it requires any advanced reasoning. So the cheaper model, Haiku, it handles pretty much all of that just as well. And the cost difference, it is very significant. So everyday tasks you're looking at roughly a 10 to 12x cost reduction per call.

So the setup of this it has two different parts. First you have to update your config to set haik coup as the default model and create shortcuts so your agent can actually switch when it is needed. Second you need to add a rule to your system prompt that actually tells your agent when to escalate. So mine says to use the default model for everything and only switch to the premium model for things like architecture decisions, production code, security work, or complex multi-step reasoning. Now if it is not sure, start with the cheaper option. Now here's something that is not so obvious is that this does not just save money, but it actually makes your agent much much faster. So Haiku responds a lot quicker than Sonnet because it is a smaller model. So your routine tasks, they complete faster and your back and forth just feels, you know, a lot snappier. You're also getting better performance and lower cost at the same time for the majority of your interactions as you could imagine. Now, after making the switch, the cost of my actual productive work, it dropped by roughly 70 to 75%. So, we had the same outputs, the same quality on the tasks that actually mattered, just smarter routing.

Now, fix D, this is trimming the context files. Now, this one, it is very easy to overlook, but it does have a significant compounding effect on everything else. So every line in your core config files, your operating instructions, even your user profile or any reference documents, all of that is getting sent with every single API call. So if you've got a 500word backstory in your users, your file that is being transmitted and built hundreds of times a day. So my rule with this is pretty simple. Just only include what your agent needs to make decisions right now. So think of core operating principles, mono rooting rules, rate limits, your name, even your time zone, and what you're working on. That is it. Everything else it is just going to be detailed company information, project context, historical notes that goes into separate files that load on demand.

Now, a trick that I actually stumbled upon that I haven't seen many other people talk about is I had to track token usage and report costs after each task as one of the operating principles in my agent's core file. And it had completely changed how my agent behaves. So now it tells me the estimated cost before starting a task and it reports the actual usage when it's done. So if something is running kind of hot, I catch it immediately instead of finding out when I check my dashboard a week later when I am shocked at the cost. So it's like giving somebody just a company credit card and telling them to submit expense reports. They naturally just become more thoughtful about what they are actually spending things on. Maybe not the best comparison, but I think you get the picture.

Now fix E. This is setting budget guard rails. So even with smart routing and lean files, you still are likely going to need a safety net because one poorly designed automation loop or one task that triggers a cascade of a whole bunch of different subtasks, it can still burn through budget in hours if there is nothing stopping it. So what I did is I added rate limits and budget caps just directly into my agents operating instructions. So there was a minimum delay between the API calls but a maximum number of web searches per batch before taking a break. Now the batch similar operations. Now we have it batched similar operations into single requests whenever it is actually possible into only hard daily and monthly spending limits with alerts before they are actually reached.

Now this piece is one of the most important insights throughout this entire video. So until you have run your agent for at least a week with these optimizations in place and you're confident that everything is stable, do not set up automatic billing. You want to load small amounts manually. So just do55 or $10 at a time and just watch how it drains. Understand the patterns about it. Really understand how your system is working in billing you because from there things will open up. I've seen some stories of people on Twitter, even a few people in my community who woke up to hundreds of dollars in charges just because they did not do this. And once it's spent, obviously it's spent. You cannot get it back. You can't get a refund.

All right. So layer 1 eliminated the invisible overhead. Layer two made your actual work dramatically cheaper. This next layer, layer three, it multiplies all of those savings. So, this next fix is going to be to stop paying full price for the same content repeatedly. So, this is something that actually bothered me once I understood how the API actually works. Is that your system prompt and core context files, they get sent with every single API call and you are also paying full price every single time. even though the content has not changed at all since the last call. You're literally just paying to send the same information just over and over again.

Now, the prompt caching, this actually fixes this. So, the first time that you send your context, you pay full price, but then it gets stored in every subsequent call within a 5minute window, it gets a 90% discount on that cached content. So, you're only paying full price for the new stuff and the actual message and the response. Now the key with this is being very strategic about what actually gets cached, right? So anything that rarely changes, it should be cached. Okay? So think of your operating instructions, your user profile, any reference documents, anything that changes frequently that should not be cached. So any daily notes, any recent messages, any tool outputs. Now how you actually enable this? You go inside your config. You can organize your workspace so stable content stays actually stable ideally. Also, do not edit your operating instructions midsession because that breaks the cash. Also, save updates for when you are actually doing maintenance as well. Just a quick piece to throw in there.

But why I actually call this the multiplier is because caching doesn't just save money on its own. It makes every other optimization way more powerful. So, you already trimmed your context files in layer 2, right? So, the content that does get cached is very, very lean. And because you're making fewer unnecessary API calls just from layer one, you're not paying cash storage costs on waste. Everything is compounding.

So, let me show you what the full stack actually looks like. So, layer 1, like I mentioned, we knocked out the overhead. My weekly idle cost went from about 12 to $15 down to basically zero. Layer two, it made productive work a lot cheaper. So, my per task cost dropped around 70 to 75%. And layer three applies a discount on top of it all. So the end result is that my total weekly spend went from about $15 $20 down to about 50 cents to a dollar and the agent it is doing the exact same work often faster because HiQ is quicker on the routine tasks.

Now I could end this video here but I want to leave you with something that goes beyond just saving money. So when I first set up Clawbot I treated it like a very simple toy. So I loaded it up, played around with it, didn't really think much about the cost. But once I actually went through this process, once I actually audited the usage, understood the architecture and optimized pretty much all of the configuration, something completely shifts. I stopped treating it like this novelty and started treating it like an actual infrastructure inside of our company. So this is a real system that I depend on to run parts of my business, quite literally. That being said, that mental shift, it matters because the people who are actually going to win with AI agents over the next couple of years, they are not the people who just set them up. They're the people who know how to actually manage them, who understand the cost structure, who can diagnose issues, who can make them run efficiently, all at scale. Now, that is a real skill set and right now almost nobody has it, which means that if you do, you have a real edge over others. Now whether you're using it for your own business or offering it as a service to others, it is a significant advantage.

Everything I covered today, the audit framework, all three layers of the fixes, the config templates, the monitoring setup, it's all going to be in the guide. I'll have a link down below in the description. There's also going to be checklist at the bottom. So go through it step by step. The guide, the configs, everything is going to be for free inside of my community. Link will be down below in the description. But with that being said, thank you guys for watching. But with that being said, thanking you guys for watching. Let me know how you guys are using Clawbot or what your charges are looking like, what you've been able to get it down. Drop it down in the comments. I'd be interested to check it out. I look at every single comment. So, that being said, thank you guys for watching. Hope you found some value within this. Make sure to subscribe for more weekly content on how to use AI to actually grow your business or grow a new business if you're looking to do that. But see you guys in the next.