# Databricks Unity Gateway for coding agents: controlling the AI bill

> Databricks says a gateway cut its AI coding bill. How we would put Claude Code and Codex behind Unity Gateway budgets, smart defaults and routing.

By Raja Vemuri, 23 October 2026. Databricks Field Guide, TechFabric. Canonical: https://databricks.techfabric.com/notes/the-ai-bill-is-coming/

An engineering team that hands out Claude Code or Codex on provider keys gets the productivity first and the invoice a month later, and the invoice rarely says which team or which model ran it up. These tools are priced on consumption, so one developer with a loop on the most expensive model has no ceiling. In [an interview Databricks published on 22 October 2026](https://www.databricks.com/blog/ai-bill-coming), Patrick, who runs Databricks' AI products, says the company's own coding spend grew until it threatened to reverse the efficiency gains, that a control layer between developers and models started as the internal fix, and that unit costs are now down by as much as 90% in some cases. That gateway became Unity Gateway, the product formerly called Unity AI Gateway ([renames](https://databricks.techfabric.com/guide/renames/)), and the controls it documents for coding agents are what we'd set up before anyone tunes a model.

## Routing developers through the gateway first

The [coding agent tutorial](https://docs.databricks.com/aws/en/ai-gateway/govern-coding-agent-models) has developers launch their agent with the open-source `ug` CLI, so every request goes to a Unity Gateway model service on their Databricks credentials with no provider API key on the laptop. Access is an `EXECUTE` grant on the model service, rate limits can be set per user, and each call lands in `system.ai_gateway.usage`. We'd do this step first and on its own, because spend by team and by model is a query once the traffic is in one table, as [Foundation Models](https://databricks.techfabric.com/guide/foundation-models/) shows for application calls.

One gap shapes the rollout.

The [supported agents matrix](https://docs.databricks.com/aws/en/ai-gateway/coding-agent-supported-agents) says `ug cursor` configures MCP access only and leaves Cursor's models running through the Cursor account, so a team that sets Cursor up that way keeps its model spend outside the gateway's budgets and usage table. We'd count those seats separately until that changes.

## A ladder of friction instead of one hard cap

The interview's strongest argument is against cutting people off. Patrick says the developers who hit a hard cap are often the best users, and some move to a personal account where nobody can see their spend. Databricks' [control spending page](https://docs.databricks.com/aws/en/ai-gateway/coding-agent-costs) gives the pieces for a ladder. A [Unity Gateway budget](https://docs.databricks.com/aws/en/ai-gateway/budgets) takes per-user thresholds that alert, block or both, with up to 20 per-user overrides for people who need more. Between alert and block sit smart defaults, in Beta behind an account-level preview, which recommend a cheaper agent and model once a user passes a share of the budget, set like this in the agent configuration.

```json
{
  "smart_defaults": {
    "budget_id": "<budget-configuration-uuid>",
    "tiers": [
      {
        "spending_percentage": 0.8,
        "recommended_agent": "CODING_AGENT_CLAUDE_CODE",
        "recommended_model": "system.ai.claude-haiku-4-5"
      }
    ]
  }
}
```

We'd read that tier for what it is. Smart defaults change new launches only, never an active session, and they don't restrict model access, so they're a nudge. Blocking is what stops requests, and Databricks says it's enforced approximately and lets in-flight requests finish. The approval step Patrick describes between warning and downshift isn't among the documented actions, so a team that wants one runs it as a process on the alert email.

```mermaid How a coding agent request meets a Unity Gateway budget
flowchart LR
  A["Claude Code or Codex launched with ug"] --> B["Unity Gateway model service"]
  B --> C{"Developer spend this month"}
  C -->|"under 80 percent"| D["Team default model"]
  C -->|"past 80 percent"| E["Cheaper model recommended at next launch"]
  C -->|"past 100 percent"| F["Blocked until reset or a raised threshold"]
  B -.-> G["system.ai_gateway.usage"]
```

## The default model is the bigger lever

Patrick says moving traffic to cheaper models as they ship saved Databricks 50% or more on its own, and the gateway makes that one change in a coding agent configuration's `default_models` setting. He's also clear that public benchmarks predict little. On Databricks' own codebase the same model in a different harness differed by more than 2x in cost, and tuning harness and caching settings saved close to 50%. Token overhead is the same budget problem [Context and Retrieval](https://databricks.techfabric.com/guide/context-and-retrieval/) describes for RAG prompts, so we'd test a candidate default on a sample of the team's own merged pull requests before switching anyone.

[Smart Routing](https://docs.databricks.com/aws/en/ai-gateway/smart-routing), in Beta, picks a model per session, and the interview says it cuts average task cost by more than 30%. It works with Claude Code and Codex launched through `ug`, and it chooses only among `system.ai` model services, never an external provider or a custom model. A team whose standard is a frontier model on its own provider account gets visibility from the gateway today, budgets once an admin turns on the Beta option to include external model usage, and routing only once it accepts Databricks-hosted models.

> **Our position**: We'd put every coding agent behind Unity Gateway before setting any limit, then run per-user alerts, a smart-default tier at 80% and a per-user block with overrides for the heaviest users, and keep a shared hard cap for the account as a backstop. The bigger saving is the team default model, which we'd change only after testing the candidate on the team's own code.
