What you will be able to do
- Choose between pay-per-token, priority pay-per-token, on-demand or reserved provisioned throughput, and external models for a given workload
- List the requirements and steps to create a provisioned throughput endpoint from the UI or the REST API
- Authenticate and send a chat request to a Foundation Model API with the OpenAI-compatible client or the Databricks Python SDK, and read the response
Key concept
Foundation Model API serving mode — The capacity contract behind a Databricks-hosted model: shared, per-token billing (pay-per-token, optionally priority) or dedicated capacity that you size and pay for (provisioned throughput). The query interface is the same either way, so the choice is about latency, guarantees and cost, not code.
1.Pay-per-token, provisioned throughput and external models
Foundation Model APIs let an application call open and proprietary LLMs that Databricks hosts, so you don't have to deploy the model yourself. What you do choose is how capacity is bought. That choice determines whether a request shares capacity with other traffic, whether latency is guaranteed, and whether you pay for tokens or for reserved hardware.
Pay-per-token is where most applications start. Endpoints that serve the pay-per-token models are already configured in every workspace in a supported region. To find them, click AI Gateway in the workspace sidebar, where they appear on the Models tab as system-provided model services. Nothing has to be logged, registered or sized before the first request, and you pay only for the tokens you use. It suits variable or intermittent workloads: a prototype, a proof of concept, or a quick check that an idea works before investing more.
Standard pay-per-token traffic is best-effort, so under load your requests queue alongside everyone else's. When a latency-sensitive, real-time application starts to suffer at peak hours, there's a cheaper fix than buying capacity.
Priority pay-per-token (also called priority mode) is that fix. You set the service_tier request parameter to priority, and Databricks admits the request ahead of standard best-effort pay-per-token traffic. You don't provision or commit to anything. You only pay a higher rate per token on the requests you flag. Databricks recommends priority mode for production workloads that are latency-sensitive but don't need dedicated capacity. Model Serving already runs on serverless compute, so there is no cluster you could attach to skip the queue.
Provisioned throughput gives an endpoint dedicated inference capacity. Databricks recommends it for production workloads, especially those that need high throughput, performance guarantees, fine-tuned models, or extra security. Provisioned throughput endpoints are available with compliance certifications such as HIPAA. They can also serve models that pay-per-token never offers: base models of any size, fine-tuned variants trained on proprietary data, and fully custom weights built on a supported architecture. It comes in two forms. On-demand has no term commitment: you pay for the capacity you allocate and can change or remove it at any time. Reserved locks in capacity for a fixed 1- or 3-month term at a lower per-unit rate, and you pay for the full reservation whether you use it or not.
External models are third-party models hosted outside Databricks, from providers such as OpenAI and Anthropic. They sit behind a Databricks endpoint and use the same unified interface. Provider API keys are stored centrally in one secure location instead of being copied into every application. For batch workloads, a separate mode applies: AI Functions optimized models, used through ai_query.
| Option | How you pay | Wins when |
|---|---|---|
| Pay-per-token | Per token, best-effort capacity | Usage is variable or intermittent, or you are just starting |
| Priority pay-per-token | Higher per-token rate, opt-in per request | Real-time requests need steadier latency under load, without dedicated capacity |
| On-demand provisioned throughput | Allocated capacity, no term commitment | You need dedicated capacity or a fine-tuned model and want to resize freely |
| Reserved provisioned throughput | Full reservation for a fixed term, regardless of usage | Business-critical apps or agents with predictable, sustained load |
Checkpoint 1 of 7· Match them up
Match each Foundation Model API serving option to how its capacity is bought and billed
Tap a term, then the definition that fits it.
Both pay-per-token options bill per token without dedicated capacity, and priority is opt-in per request. Both provisioned throughput options buy dedicated capacity. On-demand can be resized freely, and reserved commits you to paying for a fixed term.
“Reserve dedicated capacity for a fixed term and pay for the full reservation, regardless of usage.”Source: docs.databricks.com
Checkpoint 2 of 7· Exam question
Which statement accurately describes pay-per-token Foundation Model APIs endpoints on Databricks?
Correct answer: A — They are already deployed for supported foundation models, with charges metered by the tokens each request uses
- A. Correct: these endpoints come already deployed for supported foundation models, so there is nothing to set up before querying. Cost follows the tokens processed, not reserved capacity.
- B. Logging a fine-tuned or custom model into Unity Catalog before serving it is the provisioned throughput workflow. Per-token endpoints expose preconfigured base models that can be queried without any model registration.
- C. Choosing a number of model units in advance describes provisioned throughput, which reserves dedicated capacity. Per-token endpoints bill by usage and need no capacity sizing before they accept requests.
- D. These endpoints can be queried from the workspace UI, for example in the AI Playground and the Serving page. They are also reachable through the OpenAI-compatible client, Python SDK, MLflow Deployments SDK and REST API, so REST-only access is inaccurate.
Checkpoint 3 of 7· Exam question
A customer support application built on a pay-per-token Foundation Model API endpoint is experiencing inconsistent response times during peak hours because its requests are treated as best-effort and queue behind other workspace traffic. The team wants lower latency for these interactive requests without moving to provisioned throughput. Which change addresses this?
Correct answer: A — Set the service_tier request parameter to priority so requests are admitted ahead of standard best-effort pay-per-token traffic at a higher per-token rate.
- A. Correct. Setting the
service_tierrequest parameter topriorityadmits requests ahead of standard best-effort pay-per-token traffic, reducing latency for interactive applications at a higher per-token rate. This directly addresses the queueing behind other workspace traffic without requiring provisioned throughput. - B. Incorrect. Increasing the model's context window allows larger prompts in a single request, but it does not change how requests are admitted or prioritized in the serving queue. It would not resolve inconsistent response times caused by best-effort queueing during peak hours.
- C. Incorrect. Foundation Model API endpoints are served on managed serverless infrastructure and are not attached to user-managed all-purpose clusters. Routing customer-support requests to a dedicated all-purpose cluster would not bypass the serverless request queue for these endpoints.
- D. Incorrect. Inference tables log request and response data to Delta storage for monitoring and auditing, but they do not cache responses or serve repeated queries from cached inference results. They therefore would not reduce latency for new incoming customer-support requests.
2.Creating a provisioned throughput endpoint
A provisioned throughput endpoint has three prerequisites: a Databricks API token to authenticate requests, serverless compute, and a workspace in a region that supports provisioned throughput. You also need a model whose architecture provisioned throughput supports. Capacity is sold in increments that differ by model, measured either as tokens-per-second throughput bands or as model units.
Databricks recommends starting from the foundation models that come pre-installed in Unity Catalog, under the system catalog in the ai schema (system.ai). To deploy from Catalog Explorer:
- Navigate to
system.aiin Catalog Explorer and click the model's name. - On the model page, click Serve this model. The Create serving endpoint page opens.
- If you are serving your own logged model instead, open the Serving UI, select Create serving endpoint, and pick the model from Unity Catalog in the Entity field. For eligible models, the Provisioned Throughput screen appears.
- In the Up to dropdown, set the maximum tokens per second. These endpoints scale automatically, and Modify shows the minimum they can scale down to.
A common failure is picking the wrong Llama variant. When you deploy a Meta Llama model from system.ai, you have to choose the Instruct version, because base versions of Meta Llama are not supported for deployment from Unity Catalog. Governance can also catch teams out. If your organization uses Unity Catalog permissions to restrict access to foundation models, existing provisioned throughput endpoints for models that are now disallowed are not removed automatically. Someone has to delete them by hand.
With the REST API, first ask the platform what the model can do. GET api/2.0/serving-endpoints/get-model-optimization-info/{registered_model_name}/{version} returns whether the model is optimizable and its chunk size, for example a throughput_chunk_size of 980. Request capacity in multiples of that chunk. What you send next depends on how the model measures capacity. Throughput-band models take min_provisioned_throughput and max_provisioned_throughput and are posted to /api/2.0/serving-endpoints. Model-unit models take provisioned_model_units and are posted to /api/2.0/serving-endpoints/pt.
data = {
"name": endpoint_name,
"config": {
"served_entities": [
{
"entity_name": model_name,
"entity_version": model_version,
"provisioned_model_units": desired_model_units,
}
]
},
}
response = requests.post(
url=f"{API_ROOT}/api/2.0/serving-endpoints/pt", json=data, headers=headers
)The model can't be served with provisioned throughput. The documented script raises "Model is not eligible for provisioned throughput" at this point. You either need a model with a supported architecture or a different serving option.
Checkpoint 4 of 7· Check yourself
A team wants a provisioned throughput endpoint for a Meta Llama model from system.ai in Catalog Explorer. They earlier read that provisioned throughput supports base models of all sizes. Which variant should they pick?
Provisioned throughput does support base models in general. But when you deploy Meta Llama from system.ai in Unity Catalog, only the Instruct versions are supported, so the base version can't be served this way.
“Base versions of the Meta Llama models are not supported for deployment from Unity Catalog.”Source: docs.databricks.com
Checkpoint 5 of 7· Fill the gap
This request goes to /api/2.0/serving-endpoints/pt for a model that measures capacity in model units. Which field sets its capacity?
data = {
"name": endpoint_name,
"config": {
"served_entities": [
{
"entity_name": model_name,
"entity_version": model_version,
" ? ": desired_model_units,
}
]
},
}
response = requests.post(
url=f"{API_ROOT}/api/2.0/serving-endpoints/pt", json=data, headers=headers
)Model-unit models take provisioned_model_units and are posted to /api/2.0/serving-endpoints/pt. The min_provisioned_throughput and max_provisioned_throughput fields belong to throughput-band models, which are posted to /api/2.0/serving-endpoints. model_unit_chunk_size is a value returned by the optimization-info call, not a request field.
Source: docs.databricks.com3.Querying a Foundation Model API from application code
Every serving option is queried through the same interface. Model Serving exposes one OpenAI-compatible API for Databricks-hosted models and external models alike. Moving an application from a pay-per-token model to a provisioned endpoint, or to an external provider, mostly means changing the model string. Because of this, Databricks recommends the OpenAI client SDK or API for anything beyond trying a model out in the UI. Tooling already built on the OpenAI library keeps working.
The other clients send the same request. The REST API posts to /serving-endpoints/{name}/invocations. The MLflow Deployments SDK calls predict(). The Databricks Python SDK is a layer over the REST API that handles details such as authentication for you, and it is preinstalled on Databricks Runtime 13.3 LTS and above. ai_query covers the SQL case.
Authentication follows the environment. In production, Databricks recommends machine-to-machine OAuth tokens. For testing and development, use a personal access token that belongs to a service principal rather than a workspace user. Inside Databricks, the databricks-openai package (pip install -U databricks-openai) gives you a DatabricksOpenAI client with authorization already configured. From outside the workspace, use the plain openai client, passing your Databricks token as api_key and the workspace's /ai-gateway/mlflow/v1 URL as base_url.
from databricks_openai import DatabricksOpenAI
client = DatabricksOpenAI()
response = client.chat.completions.create(
model="system.ai.claude-sonnet-4-5",
messages=[
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "What is a mixture of experts model?",
}
],
max_tokens=256
)The model argument names what you are calling. In this example it is a model service name, system.ai.claude-sonnet-4-5. If you query a model serving endpoint instead, such as a provisioned throughput endpoint you created, put the endpoint name there.
The model's task type sets the shape of the request. Foundation model task types (chat, embeddings, vision, reasoning) each have their own format, and the OpenAI client handles chat, embeddings and completions models. A chat request carries a messages list of role/content pairs, plus optional max_tokens and temperature. The OpenAI Responses API (path /serving-endpoints/responses) uses a different shape: an input list and max_output_tokens. If you send a chat-shaped body to the wrong API, the request fails.
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import ChatMessage, ChatMessageRole
w = WorkspaceClient()
response = w.serving_endpoints.query(
name="system.ai.claude-sonnet-4-5",
messages=[
ChatMessage(
role=ChatMessageRole.SYSTEM, content="You are a helpful assistant."
),
ChatMessage(
role=ChatMessageRole.USER, content="What is a mixture of experts model?"
),
],
max_tokens=128,
)
print(f"RESPONSE:\n{response.choices[0].message.content}")A chat completion response is an object of type chat.completion. The generated answer is at choices[0].message.content, and finish_reason tells you why generation stopped. The usage block reports prompt_tokens, completion_tokens and total_tokens. On pay-per-token, those counts are what you are billed for.
Checkpoint 6 of 7· Check yourself
Before go-live, a reviewer asks how a production LLM application should authenticate its requests to a Foundation Model API endpoint. Which approach follows Databricks' recommendation?
Databricks recommends machine-to-machine OAuth tokens for production. A service principal's personal access token is the recommendation for testing and development only, and a user's token is not recommended for either. Outside the workspace, you use the plain openai client and pass a Databricks token as api_key.
“As a security best practice for production scenarios, Databricks recommends that you use machine-to-machine OAuth tokens for authentication during production.”Source: docs.databricks.com
Checkpoint 7 of 7· Exam question
A developer wants to minimize code changes while switching their application between a Databricks-hosted Foundation Model APIs endpoint and a third-party hosted LLM, and also wants to reuse existing tooling built around a widely adopted client library. Which client interface does Databricks recommend for querying Foundation Model APIs endpoints in this scenario?
Correct answer: A — Use the OpenAI Python client, setting its base URL to the workspace's /serving-endpoints path and passing a Databricks token
- A. The OpenAI client is the interface Databricks recommends for Foundation Model APIs. Serving endpoints accept the OpenAI chat completions format, so the client only needs a different base URL and token. The same code and tooling then work against a third-party LLM.
- B. The Databricks SDK can query a serving endpoint, but it uses a Databricks-specific call and message types. It cannot send the same request to a third-party LLM, so switching providers means rewriting code. It also does not plug into tooling built around the widely adopted client library.
- C. The MLflow Deployments client can call Databricks endpoints, but it is an MLflow-specific API with its own call pattern. Existing tooling built on the common client library cannot reuse it, and switching to a third-party LLM needs a different client. Databricks does not recommend it for this scenario.
- D. ai_query is a real SQL function for calling serving endpoints, but it runs as SQL through a warehouse and is tied to Databricks. It is not a client library that an application can point at a third-party LLM unchanged, so it does not minimize code changes or reuse the existing tooling.
Practise it for real
Send a chat request to a pay-per-token Foundation Model API from a Databricks notebook and inspect the response.
1.Run pip install -U databricks-openai in the notebook, then dbutils.library.restartPython().
Why: The package provides an OpenAI client with Databricks authorization already configured.
You should see: The package installs and the Python process restarts.
2.Create client = DatabricksOpenAI() and call client.chat.completions.create with model="system.ai.claude-sonnet-4-5", a system message, a user message and max_tokens=256.
Why: The model service name goes in the model argument, and a chat model expects a messages list.
You should see: A chat completion object is returned without a credentials error.
3.Print response.choices[0].message.content and response.usage.
Why: These hold the answer and the token counts that pay-per-token billing is based on.
You should see: The answer text, plus prompt_tokens, completion_tokens and total_tokens.
4.Run the same query with the Databricks Python SDK: WorkspaceClient().serving_endpoints.query(name=..., messages=[ChatMessage(...)]).
Why: This shows that a different client sends the same request format.
You should see: A comparable answer at response.choices[0].message.content.
Stuck? Get a nudge
If you see an authentication error outside a notebook, switch to the plain openai client and pass your token as api_key and your workspace's /ai-gateway/mlflow/v1 URL as base_url.
Sources
(6)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“When you send a request with the service_tier parameter set to "priority", Databricks admits the request ahead of standard best-effort pay-per-token traffic”
↩︎ Pay-per-token, provisioned throughput and external models“This mode is recommended for all production workloads, especially those that require high throughput, performance guarantees, fine-tuned models”
↩︎ Pay-per-token, provisioned throughput and external models“Provisioned throughput endpoints are available with compliance certifications like HIPAA.”
↩︎ Pay-per-token, provisioned throughput and external models“Fine-tuned variants of base models, such as models that are fine-tuned on proprietary data.”
↩︎ Pay-per-token, provisioned throughput and external models“AI Functions optimized models: This mode is recommended for batch inference workloads.”
↩︎ Pay-per-token, provisioned throughput and external models“Serverless compute (for provisioned throughput models).”
↩︎ Creating a provisioned throughput endpoint“Databricks recommends using the OpenAI client SDK or API for extended interactions with compatible models and the UI for trying out the feature.”
↩︎ Querying a Foundation Model API from application code“These models are hosted by Databricks and you can quickly and easily build applications that use them without maintaining your own model deployment.”
↩︎ Key concept“Preconfigured endpoints that serve the pay-per-token models are accessible in your Databricks workspace.”
↩︎ Exam trap 1“Priority mode is opt-in per request, requires no commitment, and is billed at a higher per-token rate.”
↩︎ Prediction - 2.https://docs.databricks.com/aws/en/machine-learning/model-serving/foundation-model-overviewOfficial docs
“Reserve dedicated capacity for a fixed term and pay for the full reservation, regardless of usage.”
↩︎ Pay-per-token, provisioned throughput and external models - 3.
“On-demand provisioned throughput has no term commitment. You pay for the capacity you allocate and can change or remove it at any time.”
↩︎ Pay-per-token, provisioned throughput and external models“Databricks recommends using the foundation models that are pre-installed in Unity Catalog.”
↩︎ Creating a provisioned throughput endpoint“Provisioned throughput endpoints automatically scale, so you can select Modify to view the minimum tokens per second your endpoint can scale down to.”
↩︎ Creating a provisioned throughput endpoint“If your organization uses foundation model Unity Catalog permissions to restrict model access, provisioned throughput endpoints for disallowed models must be deleted manually.”
↩︎ Creating a provisioned throughput endpoint“For these models, you specify the provisioned_model_units field in your request and send the POST request to the /api/2.0/serving-endpoints/pt endpoint.”
↩︎ Creating a provisioned throughput endpoint“For these models, you must specify the min_provisioned_throughput and max_provisioned_throughput fields in your request.”
↩︎ Creating a provisioned throughput endpoint“To identify the suitable range for your needs, Databricks recommends using the model optimization information API within the platform.”
↩︎ Creating a provisioned throughput endpoint“If you do not need dedicated capacity, Databricks recommends Priority pay-per-token for Foundation Model APIs.”
↩︎ Exam trap 2“Base versions of the Meta Llama models are not supported for deployment from Unity Catalog.”
↩︎ Exam trap 3“Base versions of the Meta Llama models are not supported for deployment from Unity Catalog.”
↩︎ Checkpoint - 4.
“External models are third-party models hosted outside of Databricks.”
↩︎ Pay-per-token, provisioned throughput and external models“By storing API keys in one secure location, organizations can enhance their security posture”
↩︎ Pay-per-token, provisioned throughput and external models - 5.https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-modelsOfficial docs
“Model Serving uses a unified OpenAI-compatible API and SDK for querying them.”
↩︎ Querying a Foundation Model API from application code“For testing and development, Databricks recommends using a personal access token belonging to service principals instead of workspace users.”
↩︎ Querying a Foundation Model API from application code“Supported for chat, embeddings, and completions models made available by Foundation Model APIs or external models.”
↩︎ Querying a Foundation Model API from application code“As a security best practice for production scenarios, Databricks recommends that you use machine-to-machine OAuth tokens for authentication during production.”
↩︎ Exam trap 4“As a security best practice for production scenarios, Databricks recommends that you use machine-to-machine OAuth tokens for authentication during production.”
↩︎ Checkpoint - 6.
“If you use model serving endpoints instead of model services, replace the model service name with an endpoint name.”
↩︎ Querying a Foundation Model API from application code“To query foundation models outside of your workspace, you must use the OpenAI client directly.”
↩︎ Querying a Foundation Model API from application code“The URL path for this API is /serving-endpoints/responses.”
↩︎ Querying a Foundation Model API from application code