Cost Control for AI Agents: What I Learned from a Webinar I Missed
Everyone’s talking about agentic AI, and we’re currently helping several clients build agentic platforms. So here’s an article that’s about as fun as salty pretzels at a party: cost control for AI agents. Don’t forget about the cost—focus on impact and value. Otherwise, you’re in for a rude awakening.
A webinar that came at just the right time
Björn Larsson has already described our proposal for how an agentic platform can be built in Azure, with Microsoft Foundry at its core. That’s the fun part, and it’s incredibly cool to see agents start doing real work.
Right in the middle of all that, I received an invitation to a webinar from Anthropic and Microsoft: “Claude in Microsoft Foundry: Control the Cost, Prove the Value.” I signed up. Then I missed it. The follow-up email began with “We missed you.” I watched the recording afterward, and it put into words something I’d been thinking about.
On the very day I’m writing this—November 17, 2026—Microsoft announced that Azure AI Gateway is generally available. A coincidence? It sure felt like one. But when so many people are building agents at the same time, it’s only natural that the question of cost would come up in many places.
Why does an agentic platform cost money in a new way?
Striving for efficiency with agents is absolutely the right approach. After all, that’s why we’re building these platforms. Björn writes that agents in production are measured per run: quality, cost, and value. We’re happy to talk about quality, while cost and value often take a back seat.

As integrators, we’re used to Azure resources that are billed on a pay-as-you-go basis. An agent operates in a loop, and each iteration of the loop is a new call to the model. Anthropic calls this a “turn,” and I’m translating it as “iteration.” With an agent, the number of iterations isn’t predetermined.
Anthropic explains what this means in its guide, “Optimizing for Cost and Intelligence”: the agent resends the entire conversation at each iteration. The guide’s own example is a task with 40 iterations, which sends its first iteration 40 times. Anthropic also reports that runs with the same settings varied in cost in their measurements. Thus, the same task does not necessarily cost the same amount each time. We have not measured how large the difference is on our customers’ platforms.
The webinar I missed was based on three questions that management will ask: Who uses Claude, how much does it cost, and what return does it provide? Replace “Claude” with any model you like, and these questions apply to the entire platform. I don’t have any customer examples to point to. These are my observations, now that more and more companies are building agentic capabilities into their operations.
Which model is best suited for which task?
There is no definitive answer as to which model is best suited for which task, and the answer changes when models are swapped out. In its guide, Anthropic recommends measuring the cost per completed task for your own workload and testing two to three levels of the “effort” setting on a sample of the traffic. Microsoft specifies in the documentation for Claude in Microsoft Foundry what each model is intended for.
I personally find this difficult, and I don’t think I’m alone. One pitfall is going overboard and choosing a more capable model than the task requires, at a cost that could have been lower. If I go the other way, I end up with a model that performs worse, resulting in having to redo the work. The worst part is when I don’t trust the result and end up doing the work myself anyway. That comes at a cost, too.

Håkan Åkerblom, our AI Integration Expert, put it better in the webinar “The AI Sweet Spot Part 2,” which we hosted together with DevScope on May 4, 2026: “Don’t cut trees with atomic bombs.” The right model for the right task. There’s also a responsibility not to use more computing power than the task requires, but that’s a topic for another article.
There’s a third pitfall, and I recognize it from integration projects. When we were building with Logic Apps Consumption, we’d sit in meetings and discuss a polling interval to cut costs. The savings amounted to a couple of öre, and we’d blow through that in consulting fees before the meeting was even over. The same thing could happen here. It’s still worth gaining a basic understanding of which model suits which task. Or do what I do: ask the AI. Just double-check the answer against the vendor’s current list, because the AI doesn’t always know which models are available today.
This choice also needs to be reevaluated when models are replaced. Anthropic notes that old prompts often contain instructions written for older models, such as “verify twice,” and that a newer model follows them to the letter and performs extra verification steps.
How does prompt caching affect the cost?
The model isn’t the only control. One thing that caught my attention in the webinar is caching. Since an agent resends the entire conversation at each iteration, it’s possible to let the beginning of the request remain with the model, making the resend more efficient. According to Anthropic’s guide, this requires that the beginning be identical character by character, in the order of tools, system prompt, and messages. A timestamp at the top of the system prompt is enough to prevent a match. Put what’s stable first and what changes last, and make changes to the system prompt and tools between runs. Microsoft states that prompt caching is supported for Claude in Microsoft Foundry, with a lifespan of five minutes or one hour. Different rules apply to other models, and I haven’t covered those here.
What is Azure AI Gateway?
Azure AI Gateway is a managed service in Azure that sits between your apps and agents and the models and tools they call. Apps and agents call the gateway, which in turn calls the models and tools. For each call, the gateway verifies the caller, applies your rules, forwards the call to the appropriate model or tool, and records telemetry. Microsoft announced on November 17, 2026, that the service is generally available.

For anyone who has worked with API Management, this pattern is familiar. The service was previously a tier within Azure API Management and is now a standalone product. According to Microsoft’s announcement, it can be used on its own, alongside Microsoft Foundry, or with Agent 365, and it connects to models from multiple providers, including Anthropic and OpenAI. Since all traffic to the models goes through a single point, the platform team can monitor and control costs there.
Three Things to Have in Place for Cost Control in Microsoft Foundry
Björn's proposal sets up the platform with identities and budget alerts right from the start. That's a good start. Based on the webinar and the documentation, I see three questions you'll need to be able to answer before the number of agents grows.
Who bears the cost?
Claude in Microsoft Foundry is billed in Claude Consumption Units, and the cost is tied to the Foundry resource. In Cost Management, it can be broken down by model and by input, output, and cache. Microsoft also notes that allocation by Foundry project is not supported for Claude. How you allocate resources and set tags therefore determines whether the cost can be allocated by team or business unit. Incidentally, this applies to all resources in Azure, and anyone who has worked with FinOps will recognize this. It’s a fundamental architectural decision that belongs at the foundation, alongside identities.
Azure AI Gateway adds a layer on top. According to Microsoft, the gateway tracks tokens and estimated costs per user, team, app, agent, and provider.
What happens when the budget is reached?
A budget alert in Azure is triggered. To stop usage, you'll need to set up your own automation, according to Microsoft's guidance on costs in Foundry.
The announcement on November 17 will be exciting. According to Microsoft, Azure AI Gateway has budgets that stop new calls when the estimated cost reaches the limit, as well as limits on tokens and calls to ensure that one agent does not crowd out the others. Apps also call the model via an alias, so the model can be switched without changing the code. Reevaluating the model choice then becomes a matter of configuration.
Three caveats. The cost for the gateway is an estimate, so the invoice is still being reconciled in Cost Management. The integration that allows prompt agents in Foundry to go through the gateway is in preview. And the gateway has its own price above the free tier, with billing starting January 1, 2027. So the monitoring also costs money, which brings me back to the polling interval. We haven’t deployed Azure AI Gateway in production. What I’m writing about it is based on Microsoft’s blog post.
What is the cost measured against?
A cost per run doesn’t mean much on its own. In Björn’s proposal, the person in charge of the case decides what’s required for the result to be considered a success, and the current solution serves as the baseline before any changes are made. Put these three side by side: the cost of the run, what the owner defines as a success, and what the same work costs today. Then you’ll have an expectation against which to evaluate each run, and any deviation will be apparent before the invoice arrives.
Where do you start?
Start with what you already have. If your platform currently has a budget alert, find out who receives it and what that person is expected to do. Then choose an agent that’s already in use, and write down how much a run costs and what the owner considers a successful outcome. This doesn’t require any new tools.
The cold shower I mentioned at the beginning comes when the invoice is the first time anyone sees the cost. Cost control should be as natural as salted pretzels at a party. They should just be there.
We've outlined the process—from the first workshop to a fully operational platform—on the page about the agentic AI platform in Azure.
Which of the three questions can you answer today? I'd love to hear your answer.
Sources and Further Reading
Everything the article is based on, compiled for those of you who want to dig deeper.
From Contica
- Proposal for an agentic platform in Azure
Björn Larsson’s article about the platform, on which this text builds. - The AI Sweet Spot, Part 2
The webinar with DevScope on May 4, 2026, where Håkan Åkerblom discusses the right AI for the right task.
From Anthropic
- Claude at Microsoft Foundry: Control the Cost, Prove the Value
The webinar from Anthropic and Microsoft on cost and value. Available for on-demand viewing. - Optimizing for Cost and Intelligence
The guide on model selection, effort, and prompt caching, with a sample calculation for 40 iterations.
From Microsoft
- Azure AI Gateway is now generally available
Announcement from November 17, 2026, including features and pricing. - Claude in Microsoft Foundry
What models are available, what they are intended for, and support for prompt caching. - Invoicing for Claude in Foundry
Claude Consumption Unit and how the cost is displayed in Cost Management. - Costs in Microsoft Foundry
Budgets, alerts, and cost analysis.
Share this post
More posts to sink your teeth into
An agentic platform needs more than just a brain
Logic Apps CLI Released in Public Preview. Here's How to Try It Out, and Here's What We've Seen So Far
Logic Apps Automation: When AI Becomes a Team Sport