CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 4 · Lesson 34/56

    Serving LLM applications with Databricks Foundation Model APIs

    Identify how to serve an LLM application that leverages Foundation Model APIs

    16 min read
    1.47% of exam
    6 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    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.

    Choosing a serving option for an LLM application
    OptionHow you payWins when
    Pay-per-tokenPer token, best-effort capacityUsage is variable or intermittent, or you are just starting
    Priority pay-per-tokenHigher per-token rate, opt-in per requestReal-time requests need steadier latency under load, without dedicated capacity
    On-demand provisioned throughputAllocated capacity, no term commitmentYou need dedicated capacity or a fine-tuned model and want to resize freely
    Reserved provisioned throughputFull reservation for a fixed term, regardless of usageBusiness-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.

    Checkpoint 2 of 7· Exam question

    Which statement accurately describes pay-per-token Foundation Model APIs endpoints on Databricks?

    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?

    Sources1234

    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:

    1. Navigate to system.ai in Catalog Explorer and click the model's name.
    2. On the model page, click Serve this model. The Create serving endpoint page opens.
    3. 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.
    4. 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.

    Creating a model-unit provisioned throughput endpoint for system.ai.gpt-oss-120bpython
    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
    )

    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?

    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
    )

    Sources13

    3.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.

    A chat request through the preconfigured DatabricksOpenAI clientpython
    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.

    The same chat request through the Databricks Python SDK, reading the answer from the responsepython
    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?

    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?

    Sources516

    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. 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. 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. 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. 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. 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. 2.
      “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. 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. 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. 5.
      “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. 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

    Spotted a mistake, or was something unclear? Tell us.