How to Control AI Vendor Spend (The Short Answer)
Set hard per-team budget limits at the API gateway layer before you negotiate a single contract. Most runaway AI bills are not caused by bad vendor pricing. They are caused by no one owning the spend signal until the invoice arrives.
I am Mahmoud Zalt, an independent senior AI systems architect with 16+ years building production software since 2010. As founder of Sista AI, I have spent the last year running autonomous agents in production while watching every line item of model and vendor spend that keeps them alive. I work with engineering teams and executive leadership as a Fractional AI Officer to build the governance layer that keeps AI initiatives from quietly bankrupting a budget. This article is the framework I actually use. Read more about me here.
Why AI Bills Explode (And It Is Rarely What You Think)
The pattern I see repeatedly is this: an engineer adds a GPT-4o call inside a loop, a product manager adds a summarization step to every user event, and someone enables streaming responses without a token ceiling. None of those decisions were malicious. None were reviewed. Six weeks later the finance team is asking why the AI line item is four times the projection.
The root causes, in order of how often I actually encounter them:
- No per-call token budget. Every prompt has an implicit max_tokens ceiling. If you do not set it, the model can and will use the full context window.
- Model overuse. Teams default to the flagship model (GPT-4o, Claude Sonnet, Gemini Ultra) for every task, including tasks that a smaller model handles correctly at one-tenth the cost.
- No chargeback or team attribution. When spend is pooled under one org-level API key, no team feels the pain and no manager sees the signal.
- Retry storms. Exponential backoff without a ceiling turns a transient 429 into a thousand redundant calls.
- Embedding everything. Bulk re-embedding a large document corpus on every schema change is a one-line mistake that costs thousands of dollars.
Observing these patterns across multiple companies, the controllable waste is almost always between 40% and 70% of the total bill. You do not need cheaper tokens. You need a governance layer.
The Controls-First Framework: Four Layers
I structure AI cost governance into four layers, applied in this order. Skipping to contract negotiation before you have layers one and two in place is a waste of energy.
Layer 1: Attribution
Every API call must carry a tag that identifies the team, the product surface, and the use-case. At OpenAI this is the user field. At Anthropic this is the metadata object. For Azure OpenAI, use deployment-level separation. If you are behind a shared gateway (LiteLLM, Portkey, Helicone), enforce tag injection at the gateway, not in application code, so teams cannot forget or bypass it. Without attribution, everything else is guesswork.
Layer 2: Hard Limits, Not Soft Alerts
Alerts tell you money is already gone. Hard limits stop the bleeding. Set limits at three levels:
- Per-request: max_tokens ceiling on every call, sized to the actual task. A classification call does not need 2,000 output tokens.
- Per-team / per-day: a budget cap enforced at the gateway. When the cap is hit, the call fails with a clear error, not silently. The team owns the escalation.
- Org-level monthly circuit breaker: a threshold that pages the AI Officer (or whoever owns the function) and requires explicit override to continue spending.
Layer 3: Model Routing
Use the smallest model that passes your quality bar for each task. I use a tiered routing policy:
| Task type | Default model tier | Escalate to next tier when |
|---|---|---|
| Classification, intent detection, entity extraction | Small (GPT-4o-mini, Claude Haiku, Gemini Flash) | Accuracy below threshold in evals |
| Structured JSON generation, short summarization | Mid (GPT-4o, Claude Sonnet) | JSON parse failure rate above 2% |
| Long-context reasoning, multi-step planning, complex code | Large (o3, Claude Opus, Gemini Ultra) | Required by task definition, not by default |
The escalation trigger is an eval result, not an engineer's intuition. Run a representative eval set of 50 to 200 real examples before promoting a task to a larger model. I have seen teams cut model costs by 60% by routing 80% of their volume to small models after running evals they had been avoiding.
Layer 4: Caching
Semantic caching at the gateway catches exact-match and near-match repeated queries. For retrieval-augmented generation (RAG) pipelines this is especially important: the same user question rephrased slightly still retrieves the same context chunks and deserves a cached answer. Tools like Semantic Cache in Redis, GPTCache, or the caching layer in Portkey/Helicone handle this transparently. Prompt caching at the provider level (Anthropic prompt caching, OpenAI cached inputs) reduces input token cost on long system prompts that repeat across calls. On high-volume pipelines this alone can reduce input token spend by 30 to 50%.
Usage Observability: What to Measure and Where to See It
You cannot govern what you cannot see. The minimum viable observability stack for AI spend has three components.
Per-call telemetry
Log these fields for every LLM call: timestamp, team tag, use-case tag, model, input tokens, output tokens, latency (p50/p95/p99), status code, cost (calculated at log time using current pricing), and a trace ID that links to the parent request. Store this in whatever warehouse you already use. A simple ClickHouse table or even a Postgres table with a date partition handles millions of rows cheaply.
Daily spend dashboard
A dashboard with four panels is enough to start: total spend by day (with a 7-day trend line), spend by team, spend by model, and top 10 use-cases by cost. Anything more than this before you have the basics under control is premature sophistication. I build this in Grafana connected to ClickHouse in under a day. The goal is that every team lead sees their own spend number every morning, without having to ask anyone.
Anomaly alerts
Alert on two patterns: a single team exceeding 150% of their 7-day average in a rolling 4-hour window, and any use-case that was previously zero suddenly generating spend (a new integration or a misrouted key). Both of these fire before the monthly invoice and surface actionable signals while the context is still fresh.
Vendor Contracts: What to Actually Negotiate
Most engineering teams treat AI API contracts as pure pay-as-you-go commodities and never read the terms until something goes wrong. Here are the specific clauses and terms worth negotiating or clarifying before you commit volume.
Committed use discounts
OpenAI, Anthropic, Google, and Azure all offer committed use or enterprise agreements once you cross meaningful monthly spend (typically $5,000 to $10,000 per month). Discounts range from 10% to 40% depending on volume and contract length. The break-even point is usually around 3 months of committed versus on-demand pricing at the same volume. Do not commit before you have 60 days of real usage data, because your model routing improvements will change your volume mix.
Data usage and training clauses
Read the default API terms carefully. Most enterprise/business tiers explicitly exclude your data from model training. The free and developer tiers often do not. If you are processing customer data, PII, or anything proprietary, you need the enterprise tier or a DPA (Data Processing Agreement) in place before the first production call, not after. This is non-negotiable and I flag it as a compliance blocker, not a procurement preference.
SLA and uptime terms
Pay-as-you-go tiers typically offer no SLA. Enterprise agreements can include 99.9% uptime commitments with credit mechanisms. For production use-cases that are user-facing, get the SLA in writing. Also clarify the rate limit terms: what is the default RPM (requests per minute) and TPM (tokens per minute), and what is the escalation path when you need more. Discovering you are rate-limited during a product launch is avoidable.
Model deprecation notice period
Ask for a contractual minimum notice period before a model version is deprecated. OpenAI publishes a 6-month deprecation window in their terms. Anthropic and Google vary. If your product depends on a specific model version for reproducibility reasons, document this and get the deprecation policy confirmed in writing.
Egress and export rights
If you store fine-tuning datasets, RLHF annotations, or evaluation sets with a vendor, confirm you can export them in a standard format at any time. Vendor lock-in via proprietary data formats is a real risk.
The Contrarian Point: Consolidate Vendors, Stop Chasing Cheap Tokens
Here is the opinion that gets pushback, but I hold it firmly after watching teams fall into the trap repeatedly: chasing the cheapest token price across five vendors is almost always more expensive than consolidating to two and negotiating volume discounts on both.
The hidden costs of multi-vendor sprawl are real. Every vendor adds an integration surface, a separate billing account, a separate secrets rotation policy, a separate rate-limit profile, a separate compliance review, and a separate on-call runbook. Each of those costs engineering time that compounds monthly. A team running OpenAI, Anthropic, Cohere, Google, and a self-hosted Ollama instance for 'cost savings' is spending more on the coordination overhead than the token price difference saves.
My standard recommendation is this: pick a primary vendor that covers 80% of your use-cases, pick one fallback vendor for resilience (not cost), and build a lightweight routing abstraction over both using LiteLLM or a similar tool. This gives you failover without sprawl. When your volume on the primary vendor crosses the committed-use threshold, you negotiate a discount. Your effective cost per token drops below anything you could have achieved by shopping five vendors at pay-as-you-go rates.
The exception is specialized capability. If a specific vendor has a model that materially outperforms others on your exact use-case and you have the evals to prove it, that is a valid reason to add a third vendor for that specific route. But 'we might need it later' is not an eval result. It is speculation, and speculation is how you end up with six vendor integrations and no one who owns any of them.
Worked Example: Bringing a $40k/month Bill Under Control in 8 Weeks
A team came to me with a $40,000 monthly OpenAI bill that had grown from $8,000 in four months. No one could explain why. Here is the exact sequence of steps we ran.
Week 1: Attribution. We added team and use-case tags to every call via a shared middleware layer. Within 48 hours we could see that 68% of spend was coming from one internal tool used by the support team that was calling GPT-4o to summarize every incoming ticket, including tickets that were one sentence long.
Week 2: Model routing. We ran an eval on 200 real support tickets. GPT-4o-mini produced summaries that the support team rated as acceptable in 94% of cases. We routed all ticket summarization to GPT-4o-mini. That single change dropped spend by $18,000 in the next billing cycle.
Week 3: Token ceilings. We audited every prompt and found that none of them had explicit max_tokens set. We set conservative ceilings based on actual output length distributions in the logs. Average output token count dropped by 35% with zero quality complaints.
Week 4: Caching. The support tool was receiving many semantically similar questions from customers. We added semantic caching with a cosine similarity threshold of 0.92. Cache hit rate reached 31% within the first week.
Weeks 5 to 8: Observability and limits. We wired up the daily spend dashboard, set per-team hard limits, and negotiated a committed-use agreement with OpenAI based on the now-stable usage pattern. Final steady-state bill: $11,000 per month, down from $40,000. The committed-use discount added another $1,500 in savings monthly.
The total engineering time spent was under 40 hours across three engineers. The savings in the first year exceed $340,000.
What Teams Get Wrong (The Short List)
- Treating AI spend as an infrastructure cost, not a product cost. AI spend should be attributed to product lines and use-cases, not pooled with AWS bills. When a product manager sees that their feature costs $0.04 per user interaction, they make different feature decisions than when the cost is invisible.
- Waiting for the model to 'stabilize' before setting up observability. There is no stable state. The model landscape changes monthly. Governance infrastructure needs to be in place before the first production launch, not after the first budget surprise.
- Fine-tuning before RAG. Fine-tuning is expensive to run and expensive to maintain across model versions. RAG with well-structured retrieval solves 80% of the knowledge-grounding problems that teams reach for fine-tuning to solve. Evaluate RAG thoroughly before committing to fine-tuning.
- Using streaming everywhere. Streaming is great for perceived latency in user-facing interfaces. It adds complexity and makes token counting harder in backend pipelines. Only stream where the user experience actually benefits from it.
- No human-in-the-loop escalation path. For high-stakes outputs (legal language, medical context, financial decisions), there should be a defined threshold below which the model answers autonomously and above which a human reviews before the response is used. This is a product architecture decision, not an afterthought.
Frequently Asked Questions
How do I set up per-team AI spend limits without building a custom gateway?
Use a hosted gateway like LiteLLM (self-hosted), Portkey, or Helicone. All three support virtual API keys with per-key spend limits and attribution tags out of the box. You can be up and running in under a day. Each team gets their own virtual key with a monthly budget cap. When the cap is hit, calls fail with a 429-equivalent error. The team owns the escalation, not the infrastructure team.
What is a realistic token budget for common AI tasks?
Classification and intent detection: 5 to 50 output tokens. Short summarization (a paragraph): 100 to 300 output tokens. Structured JSON extraction: 200 to 800 output tokens depending on schema complexity. Long-form drafting: 500 to 2,000 output tokens. Multi-step reasoning or code generation: 1,000 to 4,000 output tokens. Set max_tokens at 1.5x the 95th percentile of your actual output distribution, measured from real production logs.
How do I negotiate an enterprise AI contract if my spend is only $3,000 per month?
At $3,000 per month you are unlikely to get a custom enterprise agreement with most major providers. Focus instead on: using the business/team tier (which provides DPA, no-training guarantees, and higher rate limits), committing to a prepaid credit package (which typically gives 10 to 15% effective discount), and consolidating spend to one primary vendor to reach their committed-use threshold faster. Revisit formal negotiation at $8,000 to $10,000 per month.
Is it worth self-hosting open-source models to control costs?
For most product teams: no, not at first. Self-hosting Llama, Mistral, or Qwen on GPU infrastructure costs real money in compute, engineering time, and ongoing maintenance. The break-even point versus a managed API is typically 6 to 12 months of sustained high volume, and that calculation ignores the opportunity cost of the engineering time. The valid case for self-hosting is: strict data residency requirements that prevent cloud API use, or volume so high that the API cost genuinely exceeds the TCO of dedicated GPU instances. Run the numbers with your actual usage before committing.
Which AI cost observability tool do you recommend?
For early-stage teams: Helicone (simple, hosted, low setup friction) or LangSmith if you are already in the LangChain ecosystem. For teams that want full control over their data: LiteLLM as a self-hosted proxy writing to ClickHouse, with a Grafana dashboard on top. For enterprises already on Datadog or Dynatrace: their LLM observability integrations are now mature enough to use as the primary layer. The most important thing is that you pick one and actually use it, not that you pick the optimal one.
How often should I review AI vendor contracts?
Review the terms when: you cross a new spend tier (each 2x to 3x increase in monthly spend), a model you depend on is deprecated, you hire your first dedicated ML engineer or AI product manager (the risk profile changes), or you process a new category of sensitive data. At minimum, a full contract and pricing review once per year. The AI pricing landscape moves fast enough that a 12-month-old deal may no longer be competitive.
Work With Me to Get This Under Control
AI vendor spend is solvable. The controls are not complicated, but they require someone to own the governance layer and enforce it across teams and vendors. That is exactly what I do as a Fractional AI Officer: I embed with your team, build the attribution, routing, and observability infrastructure, negotiate your vendor agreements, and leave you with a governance model that scales without me.
If your AI bill is growing faster than your usage, or you are about to sign a multi-year enterprise AI contract and want a second opinion, reach out directly. I work with a small number of companies at a time and I will tell you honestly whether your situation needs a fractional engagement or just a one-day audit.
Hire me as your Fractional AI Officer and stop guessing at your AI spend.







