AI costs can spiral out of control before you know it. One day youâre building an AI feature that promises to bring in a solid chunk of revenue for the company. The next day youâre obsessing over an astronomically high cloud bill that will significantly eat into your profits â or consume them entirely.
To help you solve this problem, we brought in Jeremy Daly, Director of Research (and AI cost management guru) at CloudZero. His advice will help you rein in rogue costs and keep your AI budget under control.
How To Run AI In The Cloud While Keeping Costs Under Control
1. Have a foolproof way to monitor your AI costs in real time
The only way youâll know if your AI costs have spun wildly out of control â before you get your next bill â is if youâre watching them grow on a daily basis. You want to know what costs youâve already incurred this month, which resources generated those costs, and what your projected costs are for the remainder of the month.
Thatâs why Jeremy recommends implementing a cost management platform as the first step toward liberating yourself from uncontrollable cloud costs.
âGood cost monitoring goes well beyond generative AI. If youâre doing machine learning or other resource-intensive processes, staying on top of your real-time costs is just as important. Itâs about keeping those runaway costs in check so you donât get hit with a huge, unexpected bill.â
CloudZero monitors all your cloud costs â AI included â so you can see the full picture of where your money goes and why.
2. Take advantage of savings plans and spot instances
If you’ve been in the SaaS world for some time, youâve probably used â or at least heard of â provider savings plans and spot instances as a potential solution for saving some money.
Savings plans are just what they sound like: You commit to a certain amount of usage, and your cloud provider offers you a discount as long as you stick to the terms of the agreement.
A savings plan wonât prevent your AI costs from snowballing, but it will guarantee your base costs are lower â and, therefore, that the ultimate price of your AI applications is lower than it would otherwise be.
Since savings plans typically require a specific commitment (and so, you need to know ahead of time what your usage might look like), theyâre best for steady workloads.

According to Jeremy, âYou could certainly think about savings plans if you have ongoing AI training. Machine learning workloads are also a little bit more predictable. So you could get an Amazon SageMaker savings plan because youâll likely have predictable workloads on that.â
With spot instances, you can snap up unused compute resources from your provider at a steep discount, as long as youâre willing to let go of those resources at a momentâs notice when a higher bidder comes along.
âIf you donât need to run your AI training programs constantly, Amazon EC2 spot instances are a great choice.â
3. Look for opportunities to rightsize your instances
âRightsizing your AI workloads is important,â Jeremy explains. âIf youâre running machine learning models, for example, you can rightsize your SageMaker instances in order to do that cost effectively.â
Rightsizing is most effective when you can make decisions based on your companyâs unique cost data. If you have plenty of data youâve collected from allocating your costs with CloudZero, you can pick out places where instances might not be sized correctly for the workloads they support.
Downsizing idle resources might not seem like a huge money saver in the moment, but those savings will add up over time.
4. Go serverless
âSageMaker now has a serverless option,â Jeremy says. âIf youâre not running machine learning applications all the time, you donât need servers up and running the whole time either. Itâs also possible to run smaller models using AWS Lambda functions or some other serverless compute in order to run these jobs on-demand.â
That means you can run your ML applications without having to manage infrastructure or incur the costs to keep them running.
5. Choose generative AI models carefully
âIf youâre using generative AI, the model you use should really match your workload,â Jeremy explains. âFor example, letâs say youâre doing something really complex, like writing a blog post or generating some code. Youâll need a larger, more mature model that can handle these complex tasks.â
Naturally, however, these larger models will cost more to use. That means picking one model based on its robust capabilities and sticking with it for all tasks could cost you unnecessary money. If youâre doing something simple, you can save costs by opting for a less powerful AI model.
Jeremy gives an example:
âBack in the day, natural language processing was a very complex problem to solve. Maybe you wanted to grab the sentiment of a passage or extract entities from a piece of natural language â those were difficult things to do. Now, with generative AI, itâs much easier.â
Letâs say a customer asks a question in a customer service chatbot. You need to categorize that input: Is it an account question? A technical question? A billing question? âYou can use one of the very cheap models, like Claude Haiku, that barely cost anything to run and use that to do the first classification step. That way, youâre not spending a huge chunk of money on the simple task of classification.
After your simple AI model classifies the problem, then you can pass it off to a more complex model to solve the problem.â
6. Use intelligent prompt routing
The above point begs the question: How can you tell which model would be most efficient for the task you need to complete? The answer lies in intelligent prompt routing.
âWith AWS, for example, you can enable intelligent prompt routing to take the question you ask and figure out which model you need to use. Itâs basically automating your classification step without you having to manually configure it.â
This functionality is great because âit gives you the ability to take complex tasks and route them to the right model. That way, youâre not overspending on powerful AI models you donât really need for the given problem.â
7. Try prompt caching and input caching
Think of how many AI prompt requests are basically different versions of the same scenario.
As Jeremy explains, âWe generally send in these big system prompts that tell the AI how to respond whenever we get a user input. These system prompts may be something like, âYouâre a helpful customer service agent that specializes in X, Y, and Z. You respond to these common scenarios in the following ways, et cetera et cetera.ââ
These system prompts get sent with every request from a user, and theyâre typically the same for most users in a system.
âSo with prompt caching, we can cache that big system prompt so it doesnât have to be sent in and interpreted by the AI over and over again.â
This means you can save costs because your AI model only needs to process the variable content at the end of your prompts.
Similarly, Jeremy recommends input caching when you expect many user prompts to be essentially the same.
âThink of the requests that get sent into a bankâs chatbot. You probably have several variations on, âWhatâs my ABA routing number?â âWhatâs the ABA routing number for my bank?â âWhere do I find my ABA routing number?â And so on.
Do you really need to run those almost identical questions through a complex model every time in order to effectively answer the question? Instead, you can cache that question and run it first through an extremely cheap search engine first. If it returns results, your system thinks, âOh, we already know the answer to this question. Thereâs no need to even send it through a complex AI model.ââ
Jeremy says that can save a tremendous amount of money, especially if your companyâs chatbot handles numerous similar questions day in and day out.
Take The First Step Right Now
Thereâs no way around it: To visualize, understand, and ultimately control your costs through any of the most effective methods, you need a way to allocate and view those costs.
CloudZero was designed to help you do exactly that with next to no effort on your part. Our goal is to give you the cost data you need to choose great savings plans, rightsize your instances, and detect when AI costs have gone awry simply by glancing at your dashboard.
to see the cost-saving decisions you could make if you had the data to guide you.