The Cost Explosion in AI Coding
AI coding tools deliver immense value, but their costs can spiral out of control. At Databricks, agentic coding improved every velocity metric and drove order-of-magnitude gains in some teams. Yet the aggregate cost curve is unsustainable. Left unchecked, it could overtake revenue. Enterprises face a paradox: maximize AI transformation while keeping costs within a fixed envelope per user.
Several early adopters have converged on a set of proven techniques. This post draws on Databricks' experience and conversations with Stripe, Coinbase, Uber, and Ramp. The numbers are directional, based on informal surveys.
The Efficiency Frontier: A Better Metric Than Raw Intelligence
Frontier models are the highest intelligence models, but for day-to-day coding, what matters is the efficiency frontier: the best price for a given level of intelligence. Most coding doesn't require mathematical proofs. The efficiency frontier is advancing faster than the intelligence frontier, with new models released weekly that offer better intelligence per dollar.
Cost Lever #1: Move to Open Source and Lower-Cost Models
Rapidly adopting newer, more efficient models delivers the largest cost wins. But you need to know which models beat your incumbents. Public benchmarks often misrepresent real-world coding performance. Companies build internal automated evaluations. Databricks published a benchmark showing GLM models had competitive price/performance, leading to internal rollout. Stripe found Opus 4.7 didn't improve quality over 4.6 while increasing cost, so they declined to make it available. Databricks saw similar regressions comparing Opus 5.0 to 4.8.
Harness and Model Flexibility
To retain model flexibility, companies use either a multi-harness approach or a meta-harness. Asking users to switch harnesses (e.g., Claude Code, Codex, Cursor) creates switching costs and can lock in a model family. A meta-harness, like Databricks' Omnigent, provides a common UI while dispatching to underlying harnesses, reducing switching costs.
Cost Lever #2: Dynamic Request and Task Routing
Automatic routing can squeeze efficiency. Three categories:
- Request Level Routing: A stateful proxy routes each inference request to the lowest-cost model that can answer. Must account for prompt caching. Examples: Cursor Router, OpenRouter's AutoRouter, Ramp's Router, Databricks' Smart Routing.
- Task Level Routing (Meta Harness): A client-side dispatcher sends whole tasks to harnesses based on complexity. Simple task like "rename component X to Y" goes to a cheap model; complex task like "explore design considerations to reduce latency" goes to a frontier model.
- Escalation/Delegation Patterns: Pair a cheap model with an expensive one. Claude's Advisor Tool: cheap model runs and escalates when needed. Cognition's Devin Fusion: expensive model main loop, outsources to cheap model.
Databricks' AI Gateway Smart Router reduces average task cost by over 30% while matching quality of the most expensive model.
Cost Lever #3: Visibility, Tripwires, and Budgets
Hard budgets are a last resort. Cutting off access hurts productivity, and high spenders often are the most productive. Instead, companies use:
- Visibility: Near-instant feedback on spend, with tips on cheaper models.
- Spend Gates: Self-clearing warnings at thresholds, then require approval. Databricks finds self-clearing gates prevent accidental spend.
- Downshifting: If a gate is hit, reduce model tier rather than suspend access.
- Suspension: Full suspension is temporary and starts a conversation.
Cost Lever #4: Reducing Token Overhead
User input is a tiny fraction of the context fed to the model. Techniques to reduce context bloat:
- Coerce more frequent context compaction.
- Use harnesses that are more token-efficient.
- Audit tools for verbosity.
- Encourage breaking tasks into smaller units.
- Tune prompt caching: cache writes cost money, but cached reads reduce costs. Hand-tuning cache settings can drastically improve cost.
Databricks saw improvements from simple tuning of harness and caching settings.
Open Source Infrastructure
Databricks has open sourced key components: Omnigent (meta-harness) and Unity AI Gateway (AI Gateway). These are freely available.
Actionable Next Steps
- Evaluate new models with internal benchmarks. Don't trust public benchmarks alone.
- Implement a routing layer (e.g., Smart Routing) to cut costs by 30%.
- Give developers real-time spend visibility and spend gates.
- Tune prompt caching and context compaction.
These techniques let you scale AI coding without blowing the budget.


