Skip to main content

Control spending

Control what your team spends on coding agents in Unity Gateway. Set budgets, choose models that balance cost and capability, and use Smart Routing to optimize model selection.

Set budgets

Create a monthly budget with Unity Gateway as the resource type. Choose thresholds for your team:

Threshold

What it controls

Shared

Total spend across users in the budget scope.

Per-user

Spend for each individual user.

Per-user override

A higher allowance for specific users or groups.

Threshold

What it controls

Shared

Total spend across users in the budget scope.

Per-user

Spend for each individual user.

Per-user override

A higher allowance for specific users or groups.

For each shared or per-user threshold, choose Send alert, Block usage, or both. Alerts notify the configured recipients. Blocking prevents further gateway requests until the budget resets or an admin increases the threshold.

If your team uses external model providers, enable the External Model Spend in Budgets preview and select Include external model usage. Estimated external spend then counts toward the same thresholds.

Budget enforcement uses near real-time estimates. Requests already in progress can complete, so final spend can exceed the threshold. External estimates can also differ from the provider's invoice.

For setup and coverage details, see Manage budgets for Unity Gateway.

Set model defaults and smart defaults

Edit these settings in your coding agent configuration. Merge the fields below into the existing configuration, then save to publish your changes.

Set a default model

Choose the model each agent starts with for everyday work. For Claude Code, add the following inside its config object under enabled_agents:

JSON
{
"default_models": {
"default_model": "system.ai.claude-sonnet-4-6"
}
}

This sets Claude Sonnet 4.6 as Claude Code's default. Choose a model supported by the agent and ensure developers have access to it. ug uses this default when no smart-default recommendation or explicit model choice applies.

For Claude Code, you can also map its Opus, Sonnet, Haiku, and Fable model families to specific models:

JSON
{
"default_models": {
"default_model": "system.ai.claude-sonnet-4-6",
"default_opus_model": "system.ai.claude-opus-4-8",
"default_sonnet_model": "system.ai.claude-sonnet-4-6",
"default_haiku_model": "system.ai.claude-haiku-4-5",
"default_fable_model": "system.ai.claude-fable-5"
}
}

Specify only the family mappings you want to override. If models uses a model provider service, use model IDs from that provider service. Otherwise, use full Unity Catalog model service names. With a static model_services list, every default must also appear in that list.

Adjust recommendations as spending increases

Beta

Smart defaults are in Beta. An account admin must enable the Enhanced Unity Gateway preview from the account console Previews page. See Manage Databricks previews.

To recommend a different agent and model as spending increases, add smart_defaults at the top level of your existing coding 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"
}
]
}
}

Replace the budget ID with your budget's budget_configuration_id. The value 0.8 means 80% of the applicable budget threshold. At that point, this example recommends Claude Code with Claude Haiku 4.5. Include the recommended agent in enabled_agents and grant developers access to the model. If that agent uses a static model_services list, include the recommended model in the list. For multiple tiers, the highest threshold reached determines the recommendation.

Running ug launches the recommended agent and model. An agent-specific command keeps the chosen agent and applies a model recommendation only if it targets that agent. An explicit --model overrides the recommendation.

Smart defaults affect new launches; they do not switch active sessions or restrict model access. Use budget blocking to stop further requests and Unity Catalog permissions to restrict access.

Use open models

Databricks supports running open source (OSS) models, such as glm-5-2, with coding agents through Unity Gateway. OSS models can cut per-token cost substantially for routine coding tasks. Set an OSS model as an agent's default in your configuration, or have developers select one at launch.

For launch examples and manual setup, see Select models. To see which agents support open models, see Supported coding agents.

Understand Smart Routing

Smart Routing automatically selects the lowest-cost model capable of handling each task, so developers do not need to choose a model for every request. It works with Claude Code and Codex and can select a different model from the team's default or smart-default recommendation.

To enable Smart Routing by default, add smart_routing inside each supported agent's existing config object:

JSON
{
"smart_routing": {
"enabled": true
}
}

Publish the configuration. When developers launch with ug claude or ug codex, the CLI applies Smart Routing automatically. To stop enabling Smart Routing by default, set enabled to false and publish the update.

For developer setup and behavior, see Select models or use Smart Routing.

Smart Routing limitations

  • Smart Routing supports only a static models.model_services list whose entries begin with system.ai.. You cannot enable Smart Routing with a model_provider_service, a unity_catalog_location, a custom model, an external provider, or a model service outside system.ai.
  • Workspace admins must grant developers access to every candidate model.
  • The Unity Gateway CLI routes among models within a harness. Routing across harnesses requires Omnigent v0.8.0 or later.
  • Native Claude Code and Codex sessions that do not use the Unity Gateway CLI do not support Smart Routing through Unity Gateway.

Review spending

Review usage and spend to adjust your budgets and model choices. See Monitor coding agent activity.

Additional resources