Databricks Field Guide

Generative AI · Chapter 18

Databricks Foundation Model APIs and Unity Gateway

Reviewed by TechFabric engineers. How we write this guide →

Databricks Foundation Model APIs are hosted language and embedding models you call from a Databricks workspace with nothing to deploy. GPT, Claude, Gemini, Llama, Qwen and several open models are billed per token or on provisioned throughput, and as of October 2026 each one is a model service in system.ai (for example system.ai.gpt-oss-120b), reached through Unity Gateway, the governance layer for model and MCP calls that used to be called Unity AI Gateway.

Renting the model is the easy part. This chapter covers which of the four ways of getting a model fits a workload, what the tokens cost, how SQL and application code call them, and why we'd route every call through the gateway from the first prototype, so an organisation ends up with one governed way of calling models instead of forty ungoverned ones.

The short version

Several vendors now sell language models of similar quality at similar prices, and on Databricks most of them (OpenAI's GPT models, Anthropic's Claude, Google's Gemini, and open models such as Llama and Qwen) are available pay-per-token with nothing to provision. Choosing between them is a smaller decision than it feels. The decision that matters is where the calls go through. A team that gives every application its own vendor key ends up with no record of which system sent which customer's data where, no way to cap spend before the invoice, and no answer for an auditor asking what a model was told last March. Databricks' gateway, now called Unity Gateway, is one doorway for every model and MCP call, governed in Unity Catalog, so access, limits, guardrails, spend and logging are properties of the platform instead of promises made by each team.

Four ways to get a model, and when we'd use each #

Option What you pay for When we'd use it The trap
Pay-per-token Tokens in and out Every new use case, development, bursty internal tools None at the start; the shared pool can rate-limit a big batch job
Priority pay-per-token Tokens, at the priority tier, with service_tier set to "priority" Latency-sensitive real-time paths that don't justify reserved capacity Paying priority rates on traffic that could wait
Provisioned throughput, on demand or reserved for 1 or 3 months Dedicated capacity, whether used or not A steady floor of traffic, latency guarantees, fine-tuned or custom weights, extra security requirements Capacity reserved for a load that never arrives
External models The vendor's own bill, through a provider service A model the team already contracted for, brought inside the boundary Assuming the vendor's controls replace the gateway's

Databricks' documentation recommends pay-per-token to start and provisioned throughput for production. Our position is a step more cautious: start every use case on pay-per-token, measure real traffic for a few weeks, and move to provisioned throughput only when the measured floor justifies it, preferring on-demand capacity until you've seen a full business cycle. A reservation is much easier to buy than to give back.

Fine-tuned and custom models sit under the provisioned throughput row. You register them in Unity Catalog through MLflow and serve them from dedicated capacity, and the reason to do it is a narrow, repetitive task at high volume where a small specialised model beats a large general one on quality and unit cost. Before tuning anything we'd try ai_decide (below) or a smaller pay-per-token model with a better prompt, because both are cheaper to evaluate than a training run.

When a training run is justified, AI Runtime, Databricks' serverless GPU compute, runs it inside the workspace on 1xA10, 1xH100, 8xH100 or 8xB300 nodes (8xB300 is Public Preview on AWS behind a waitlist, per the docs on 21 October 2026), streaming data from Unity Catalog volumes and tables. Only the two 8-GPU shapes do multi-GPU training. Our note on it covers where we'd train on it and the limits we'd plan around.

How much do Databricks Foundation Model APIs cost? #

Pay-per-token prices are listed in DBUs per million tokens on the Foundation Model Serving pricing page, and the dollar figure is that rate times your contract's price per DBU. A few rates as listed on 22 October 2026, with the dollars worked at the $0.07 per DBU the page itself uses as its example:

Model Input, DBU per 1M tokens Output, DBU per 1M tokens At $0.07 per DBU, in and out
Llama 3.3 70B 7.143 21.429 about $0.50 and $1.50
GPT-OSS-120B 2.143 8.571 about $0.15 and $0.60
GTE (embeddings) 1.857 none about $0.13

Provisioned throughput is priced per hour per 50 model units instead, and the priority tier is billed at a higher per-token rate than standard pay-per-token. The arithmetic that matters is per workload. Classifying a million support tickets at about 400 input tokens and a one-word answer each is roughly 400 million input tokens, which comes to about 2,960 DBU on Llama 3.3 70B and about 900 DBU on GPT-OSS-120B. A labelled sample of a few hundred tickets tells you whether the cheaper model is good enough, and that test costs less than a dollar.

The embedding models are databricks-gte-large-en, databricks-bge-large-en and databricks-qwen3-embedding-0-6b (Public Preview), and the last is the one Databricks now recommends for production AI Search indexes. The supported models page has the full list by vendor, with each model's service name and the modes it supports.

The gateway is the argument #

Unity Gateway is built on Unity Catalog. Foundation models are served natively as model services in system.ai, governed with Unity Catalog privileges, and you can create your own model services for other destinations, including external providers. MCP servers are governed the same way. Around those services it gives you rate limits, traffic splitting and fallbacks across model destinations, service policies (built-in, custom or from an outside guardrail vendor) that act on each request and response based on its content and on who is calling, and usage written to system.ai_gateway.usage, with the requester, the service, input and output tokens, latency and status code on every row. One exception changes how we'd build SQL pipelines. Calls from ai_query to system.ai models get usage tracking, and Databricks' two pages disagree about the rest: the ai_query page adds budget integration and the permission check on the model service, while the Unity Gateway reference says only usage tracking applies to ai_query batch inference (both updated mid-October 2026). Both agree that service policies and guardrails, inference and trace tables, rate limits, fallbacks and model services you create yourself don't apply on that path, so a pipeline that counts on gateway PII redaction has none there, and we'd plan as if only usage tracking does. Redact or drop sensitive columns in the query before the model sees them.

The alternative is the one almost every organisation reaches by accident. A product team gets an API key, a second team gets its own, a contractor puts one in a serverless function, and eighteen months later nobody can answer three reasonable questions: which systems send customer data to a model vendor, what did they send, and what would the monthly bill do if one of them entered a retry loop. None of that can be reconstructed later, because the evidence was never collected.

Applications, notebooks
agents and SQL

Unity Gateway

Pay-per-token
models in system.ai

Provisioned
throughput

External providers

MCP services
and tools

Usage table and
trace table

How a model call is governed

Three properties are what we'd point at in a design review. The credential for an external vendor lives in the gateway, not in each application. A rate limit can be lowered centrally during an incident without redeploying anything. And the token counts behind every call land in a system table nobody had to instrument, so cost per team is a query:

SELECT requester,
       service_name,
       sum(input_tokens)  AS input_tokens,
       sum(output_tokens) AS output_tokens,
       count_if(status_code >= 400) AS failed_calls
FROM system.ai_gateway.usage
WHERE event_time >= current_date() - INTERVAL 30 DAYS
GROUP BY ALL
ORDER BY output_tokens DESC;

AI Functions bring the model into the query #

Because endpoints are a platform service, SQL can call one. Classification, extraction, summarisation and translation stop being a separate service with its own queue and become an expression in a pipeline.

pipelines/silver/classify-support-tickets.sqlsql
CREATE OR REPLACE TABLE ops.support.tickets_classified AS
SELECT
  ticket_id,
  received_at,
  body,
  ai_query(
    'system.ai.meta-llama-3-3-70b-instruct',
    'Classify this support ticket as BILLING, TECHNICAL, ACCOUNT or OTHER. ' ||
    'Reply with one word only. Ticket: ' || body,
    modelParameters => named_struct('max_tokens', 5, 'temperature', 0.0)
  ) AS category
FROM ops.support.tickets_raw
WHERE received_at >= current_date() - INTERVAL 1 DAY;

ai_query needs Databricks Runtime 15.4 LTS or above (18.2 or above recommended) and isn't available on classic SQL warehouses (ai_query). For a large backfill we'd also pass failOnError => false, so a failed row comes back with its error message instead of stopping the job.

Two cautions we'd attach. A model call per row is a cost per row, so the WHERE clause is a budget control and an unfiltered rebuild of a large table is an expensive accident. And model output isn't deterministic, so a column produced this way is a derived attribute with a recorded model version behind it, not a fact, which is why the silver and gold separation in Medallion Architecture matters more here, not less.

The body column goes to the model as it is, and none of the gateway's service policies run on this path, so a ticket table that can hold card numbers or health details needs those masked in the SELECT first.

Application code reaches the same model services through an OpenAI-compatible client. Code written against the old /serving-endpoints path changes two things. The base URL becomes /ai-gateway/mlflow/v1, and the model becomes the fully qualified service name instead of the endpoint name (updating clients for Unity Gateway). Governance set on a legacy endpoint doesn't carry over to the model service, and with enforcement on, a disabled pay-per-token endpoint on the old path returns PERMISSION_DENIED. We'd make that change before turning on gateway enforcement, because a client still on the old path skips the new controls while legacy access is on and is refused once it is off:

services/support/summarise.pypython
# pip install openai
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["DATABRICKS_TOKEN"],
    base_url=f"{os.environ['DATABRICKS_HOST']}/ai-gateway/mlflow/v1",
)

response = client.chat.completions.create(
    model="system.ai.meta-llama-3-3-70b-instruct",
    messages=[
        {"role": "system", "content": "Summarise the ticket in one sentence. Use only what is given."},
        {"role": "user", "content": os.environ.get("TICKET_BODY", "Card charged twice for the March invoice.")},
    ],
    temperature=0,
    max_tokens=120,
)

summary = response.choices[0].message.content

Decision models and ai_decide #

Look at the classification query above again. It asks a model that writes paragraphs to answer with one word, and pays for that model to do it on every row. On 30 September 2026 Databricks announced a function built for exactly this shape of work: ai_decide, in Beta, powered by a decision model rather than a language model. It doesn't generate text. It takes the row's content and a set of questions, and returns decisions with probabilities attached.

There are three kinds of question, and one call can mix them. A choice question picks one of up to 255 labels you define and returns the probability of every label. A noul question returns the probability, from 0 to 1, that a statement is true. A score question rates the input on an ordered scale of 2 to 10 descriptions and returns a probability-weighted average, so a three-step scale can come back as 1.5. The same ticket table, rewritten:

pipelines/silver/decide-support-tickets.sqlsql
CREATE OR REPLACE TABLE ops.support.tickets_decided AS
SELECT
  ticket_id,
  received_at,
  d:response.answers.team.choice::string                   AS team,
  d:response.answers.needs_escalation.probability::double  AS escalation_p,
  d:error_message::string                                   AS decision_error
FROM (
  SELECT ticket_id, received_at, ai_decide(
    body,
    '{
      "team": {"type": "choice", "instructions": "Which team should handle this ticket?",
               "criteria": {"billing": "Payment or invoice issues",
                            "technical": "Product technical problems",
                            "account": "Login, access or account changes",
                            "other": null}},
      "needs_escalation": {"type": "noul", "instructions": "Does this ticket need immediate escalation?"}
    }',
    map('version', '1.0')
  ) AS d
  FROM ops.support.tickets_raw
  WHERE received_at >= current_date() - INTERVAL 1 DAY
);

What changes is more than the function name. The probabilities are data you can threshold, so a ticket at 0.51 for billing can go to a person while one at 0.97 routes itself. A row that fails comes back with a null response and a message in error_message instead of failing the query, so failures are a column you can count. The questions argument must be a constant, so one call applies one rubric to every row, and the input can be the VARIANT that ai_parse_document or ai_extract produced, which lets a parsed document go straight into a decision.

Databricks says the function is faster and cheaper than an LLM on similar tasks. We'd measure that on a day of your own traffic before believing it, as with anything new on the bill. The constraints today are the Beta ones: a workspace admin enables it on the Previews page, it needs Databricks Runtime 15.4 LTS or later, it isn't available on Databricks SQL Classic or in every region, and Databricks may change the underlying model. Pin the version in the call and keep a labelled sample to rerun when it does. Used well, it's the cheap router we'd put in front of ai_query: decide first, and only send the rows that need prose to a language model.

Pin the model by its service name, and watch the retirement dates #

A model name that quietly starts pointing at a newer version changes your outputs, your evaluation scores and sometimes your parsing, on a date you didn't choose. We'd pin the full model service name in production, record it with every inference, and move it as deliberately as any other deployment.

Pinning only helps if the name you pinned still exists. Databricks' supported models page dates each retirement, and on 22 October 2026 it listed databricks-deepseek-v4-pro-0813 and databricks-inkling retiring on 30 October, databricks-deepseek-v4-flash-0731 on 5 November and databricks-deepseek-v4-1-flash on 19 November. The last one is the trap. The undated name retires while the dated databricks-deepseek-v4-1-flash-1017 carries on, so code that pinned the friendlier name breaks first. The usage table tells you who still calls a retiring model before the date does:

SELECT service_name,
       requester,
       count(*)       AS calls,
       max(event_time) AS last_call
FROM system.ai_gateway.usage
WHERE event_time >= current_date() - INTERVAL 14 DAYS
  AND service_name IN ('system.ai.deepseek-v4-pro-0813',
                       'system.ai.inkling',
                       'system.ai.deepseek-v4-flash-0731',
                       'system.ai.deepseek-v4-1-flash')
GROUP BY ALL
ORDER BY last_call DESC;

Keep the model name and its settings (temperature, token limit, reasoning effort) as separate values in one configuration file, and make a missing model fail the deploy rather than fall back to whatever answers.

Logging, and the two places it can land #

Payload capture is the least exciting feature in this chapter and the one whose absence hurts most, because evaluating a system in production needs the production traffic, and traffic that wasn't captured can't be recovered. Per-endpoint inference tables still exist. The newer unified trace table, in Beta, captures every request and response across all Unity Gateway services in one Unity Catalog table in OpenTelemetry format, and Databricks recommends it for new deployments. We'd turn it on in the same change that grants read on it, because by default only the metastore admin who created it can read it, and we'd keep the audit log as the compliance record, since trace delivery is best-effort.

With that record you can measure the real distribution of prompt lengths, sample live traffic and score it with a judge, and build an evaluation set from questions users actually asked. MLflow and the Model Lifecycle covers the evaluation machinery, and Agents on Databricks the loop that feeds low-scoring production answers back into an offline set.

Governing model calls across an organisation

Capability Databricks AWS Azure GCP
One doorway for hosted and third-party models Unity Gateway governs both, and MCP services Bedrock covers its own catalogue, external vendors sit outside it Azure OpenAI plus AI Foundry, third-party vendors sit outside Vertex AI and Model Garden, third-party vendors sit outside
Model calls from SQL ai_query and AI Functions in any query or pipeline Redshift and Athena integrations, wired per service Fabric and Synapse integrations, wired per service BigQuery ML remote models
Request and response capture into governed tables Trace table or inference tables in Unity Catalog CloudWatch and S3, then build the table Log Analytics, then build the table Cloud Logging, then build the table
Guardrails Service policies on each request and response Bedrock Guardrails, for Bedrock models Azure AI Content Safety, wired in per app Vertex AI safety filters
Governance shared with the data Same catalog, grants and lineage as tables IAM plus Lake Formation, two models to reconcile Entra plus Purview, two models to reconcile IAM plus Dataplex, two models to reconcile
Spend per caller system.ai_gateway.usage per requester Service quotas plus tagging Quotas per deployment Quotas per project

AWS and Azure each do parts of this well, and Bedrock Guardrails in particular is a mature safety layer we'd recommend to a team committed to Bedrock. The distinction is scope, not quality. Each of those products governs its own vendor's models, so an organisation running Bedrock for one product and Azure OpenAI for another has two control planes and no consolidated record, while the gateway's claim is that the doorway is the same whoever hosts the model.

The parts teams reach later #

Rate limits and fallbacks. We'd set limits per service and per caller, not one global number, because the point is to stop one runaway consumer rather than throttle everybody. Fallbacks send a request to another destination when the first fails, turning an outage into slower or slightly different answers. Configure them deliberately: silently answering from a different model is fine for a summariser and unacceptable for anything whose output is compared over time.

PII before the prompt leaves the boundary. Decide explicitly what may cross to a vendor. Redaction or tokenisation of identifiers before the call, applied in the pipeline or as a gateway service policy rather than in each application, is the difference between a data protection assessment that concludes quickly and one that stalls. Column masks in Unity Catalog are where we'd define what is sensitive once.

MCP through the same gateway. Tool servers reached over the Model Context Protocol are the same governance problem with higher stakes, because a tool call reaches systems of record rather than merely reading text. Routing MCP services through the gateway puts what the model reads and what it invokes under the same authentication, limits and log, which is the precondition for Governed Actions.

New use case

Pay-per-token
foundation model

Measure real traffic
for a few weeks

Steady high volume
or latency sensitive

Vendor model
already contracted

Narrow repetitive task
at high volume

Provisioned throughput
or priority tier

External provider
via the gateway

Fine-tune and host

Choosing how to obtain a model

What we'd tell a team starting today #

Pick one model to begin with instead of spending a week comparing them, because the gap between the leading models is smaller than the gap between a good and a bad retrieval step, and switching later is a configuration change once calls go through the gateway. Route everything through Unity Gateway from the first prototype, since retrofitting it means finding every key issued in the meantime. Turn on trace capture before you have traffic worth capturing, grant read on it the same day, and pin your model names before the first time an output changes without explanation. Grounding those calls in your own data and turning them into something that can act are Context and Retrieval and Agents on Databricks.