CertSafari
    Databricks Certified Machine Learning Associate· Lessons

    Domain 4 · Lesson 47/48

    Query a Model Serving endpoint for realtime inference

    Deploy and query a model for realtime inference

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

    What you will be able to do

    • Explain why a per-request, low-latency prediction calls for a Model Serving endpoint and not a scheduled or streaming scoring job
    • Find the endpoint name and invocation URL a query targets, and confirm the endpoint is READY before you send traffic
    • Authenticate a scoring request with a token and send it as a POST to the endpoint's invocations URL
    • Format request bodies as dataframe_split, dataframe_records, instances or inputs, and read the predictions key in the response
    • Query an endpoint from the Serving UI, REST, the MLflow Deployments SDK and SQL ai_query

    Key concept

    Invocation request — To get a realtime prediction, you send an HTTP POST to the endpoint's own URL, https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations. The request carries a Databricks token and a JSON body under one supported key, such as dataframe_split, and the predictions come back in the same response.

    1.Why per-request predictions need a serving endpoint

    Realtime inference means a caller asks for one prediction and waits for it in the same exchange. A mobile app checking a card transaction for fraud can't wait for a nightly job. It sends the transaction now, and it needs the score back before the payment screen moves on. Databricks Model Serving is built for this case. Every model you serve gets its own REST API, and the service is designed to be highly available and low latency. It runs on serverless compute and scales up or down as demand changes.

    The other ways to score a model all put a scheduler or a trigger between the event and the answer. Loading a model with mlflow.pyfunc.load_model in a scheduled notebook scores rows only when the job runs. So does a pandas UDF in a nightly ETL job. A Lakeflow Spark Declarative Pipeline (formerly Delta Live Tables) scores new rows on a micro-batch trigger and writes them to a table that the app would then have to read. Each of these fits a different latency and throughput need, compared in batch, realtime and streaming serving approaches. None of them returns the answer to the caller in the same HTTP response.

    Some endpoint settings affect latency at query time. With scale to zero enabled, an endpoint shuts down after 30 minutes without traffic. The first request after that has to wait for a cold start, which usually takes 10–20 seconds and sometimes takes minutes, with no SLA on that wait. A fraud check with a sub-100 ms budget should therefore run on an endpoint with scale to zero turned off.

    Checkpoint 1 of 9· Check yourself

    A mobile banking app must send each card transaction for a fraud score and get the score back before the payment screen moves on. The latency budget is under 100 ms. Which setup fits?

    Checkpoint 2 of 9· Exam question

    A fraud-detection model must return a prediction in well under 100ms for each individual transaction as a mobile app submits it, and the app cannot wait for a scheduled job to run. Which deployment approach satisfies this requirement?

    Sources12

    2.What a query targets: endpoint name, served entity and READY state

    A query is addressed to an endpoint by name. The endpoint decides which model version answers. How to build one in the UI, the REST API or the Deployments SDK is covered in creating a Model Serving endpoint. For querying, three facts about it matter. The endpoint's name (for example uc-model-endpoint) becomes the <endpoint-name> part of the invocation URL. Each served entity names its model by entity_name and entity_version. And the endpoint's state tells you whether a request will be answered yet.

    Only two fields decide which registered model version an endpoint serves. entity_name holds the full Unity Catalog path, catalog and schema included, such as main.ml_models.churn_predictor. entity_version pins the version, such as "3". None of the other fields changes which model loads. A traffic_config route with served_model_name and traffic_percentage sets what share of requests each served entity gets, which is covered in splitting traffic between served entities. workload_type, workload_size and scale_to_zero_enabled are compute settings. Workspace-registry stage names such as Production don't identify a Unity Catalog model either, because the endpoint reads the path and version you give it.

    Don't send requests the moment an endpoint is created. After you click Create, the Serving endpoints page shows the endpoint as Not Ready. Deploying a newly registered model version means packaging the model and its environment and provisioning the endpoint, which takes about 10 minutes and can take longer for large models or ones with many dependencies. The endpoint is ready for scoring requests once the endpoint record shows ready as READY and config_update as NOT_UPDATING.

    The state block of a serving endpoint that can accept scoring requestsjson
      "state": {
        "ready": "READY",
        "config_update": "NOT_UPDATING"
      },

    Checkpoint 3 of 9· Fill the gap

    You created an endpoint a few minutes ago and want to know if it will answer scoring requests yet. Which value completes the endpoint-level state block of an endpoint that is ready for traffic?

      "state": {
        "ready": " ? ",
        "config_update": "NOT_UPDATING"
      },

    Checkpoint 4 of 9· Check yourself

    An endpoint must serve version 3 of the Unity Catalog model churn_predictor, which lives in catalog main and schema ml_models. Which served-entity settings make the endpoint load that model?

    Checkpoint 5 of 9· Exam question

    An ML engineer registered a model as main.ml_models.churn_predictor version 3 in Unity Catalog and now needs to deploy exactly that version behind a Model Serving endpoint. Which configuration correctly identifies the model to serve?

    Sources32

    3.The invocation URL and token authentication

    A REST scoring request is a POST to https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations with header Content-Type: application/json and a JSON body. This path is easy to confuse with /api/2.0/serving-endpoints, which is where endpoints are created and configured. Sending input rows there doesn't score anything. Neither does a GET to an MLflow registered-models path or a CSV upload. Scoring requests go only to the /invocations path as JSON.

    Every request through the REST API or the MLflow Deployments SDK needs a Databricks API token. Requests outside the Serving UI also need a DATABRICKS_API_TOKEN. The curl examples send it with basic auth as -u token:$DATABRICKS_API_TOKEN. Other clients put it in an Authorization header as Bearer <token>. Power BI, for example, builds that header with Text.Format("Bearer #{0}", {apiToken}). A username and password in the request body is not an accepted way to authenticate.

    The type of token depends on the environment. For production, use machine-to-machine OAuth tokens. For testing and development, use a personal access token that belongs to a service principal, not one that belongs to a workspace user. Route-optimized endpoints are an exception to this flow. They accept only OAuth tokens, not personal access tokens, and they're queried at their own dedicated URL instead of the standard invocations path.

    The token only gets a request accepted; the model still has to finish in time. If model computation takes longer than 597 seconds, the request times out. A model that's slow on one large request will hit this limit no matter how the call is authenticated.

    Checkpoint 6 of 9· Check yourself

    Your team turned on route optimization for a high-QPS endpoint. A client that sends a personal access token to https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations stops working. What does the client have to change?

    Checkpoint 7 of 9· Exam question

    A backend service outside Databricks needs to send a scoring request to a serving endpoint named churn-endpoint and receive a prediction back over HTTP. Which request correctly queries the endpoint?

    Sources452

    4.Request formats and the predictions response

    Custom models accept input as a JSON-serialized pandas DataFrame, or as tensor input in JSON or Protobuf. The body has one top-level key that names the format. Its value holds the data in that format's layout. The first decision is between the two DataFrame keys.

    dataframe_split is the recommended format. It gives the DataFrame in pandas split orientation: an index array, a columns array with the feature names, and a data array of rows in the same order as columns. dataframe_records sends one object per row, mapping each column name to its value. It's easier to read, but it doesn't guarantee column order. For tensor models such as TensorFlow or PyTorch, there are two choices. instances sends tensors row by row and works only when every input tensor has the same 0-th dimension. inputs sends tensors in columnar form, which covers inputs that don't fit the row layout.

    Top-level request keys for custom model endpoints
    KeyShape of the valueWhen to use it
    dataframe_splitObject with index, columns and data arrays (pandas split orientation)Default for tabular models; keeps column order
    dataframe_recordsList of objects, one per row, column name to valueTabular input where column order doesn't matter
    instancesList of rows, optionally with named tensors per rowTensor models whose input tensors share the same 0-th dimension
    inputsColumnar tensors, one entry per tensor nameTensor models, including inputs that the instances layout can't represent

    The response has the same shape whichever key you send. The model's output is serialized as JSON under a predictions key, with one entry per input row, in order. Your client reads response["predictions"] and matches each value to the row it sent. Models that take generation settings can also accept a params object next to the input. The Serving UI example for a text generation model passes max_new_tokens and temperature this way.

    The response body: model output wrapped in a predictions keyjson
    {
      "predictions": [0, 1, 1, 1, 0]
    }

    Checkpoint 8 of 9· Match them up

    A team is writing clients for several custom model endpoints. Match each top-level request key to the layout and use it fits.

    Tap a term, then the definition that fits it.

    Sources4

    5.Sending the request: Serving UI, REST, Deployments SDK and ai_query

    There are four clients for sending the same request, and each fits a different caller.

    • Serving UI: on the endpoint's page, choose Query endpoint, paste JSON input and click Send Request. If the model was logged with an input example, Show Example loads it. This is the quickest check that a new endpoint works.
    • REST API: a POST to the invocations URL. This is the option for applications outside Databricks, such as the fraud app or a backend service.
    • MLflow Deployments SDK: predict() on a client from get_deploy_client("databricks"). It requires MLflow 2.9 or above and reads the workspace host and token from DATABRICKS_HOST and DATABRICKS_TOKEN.
    • SQL: the ai_query function calls the endpoint from a query, so analysts can score rows without writing any HTTP code.
    REST: score a tensor-input model with curl, authenticating with the API tokenbash
    curl -X POST -u token:$DATABRICKS_API_TOKEN $ENDPOINT_INVOCATION_URL \
        -H 'Content-Type: application/json' \
        -d '{"inputs": [[5.1, 3.5, 1.4, 0.2]]}'
    MLflow Deployments SDK: predict() with a dataframe_split body against an endpoint named test-model-endpointpython
    import os
    import mlflow.deployments
    
    os.environ["DATABRICKS_HOST"] = "https://<workspace_host>.databricks.com"
    os.environ["DATABRICKS_TOKEN"] = "dapi-your-databricks-token"
    
    client = mlflow.deployments.get_deploy_client("databricks")
    
    response = client.predict(
                endpoint="test-model-endpoint",
                inputs={"dataframe_split": {
                        "index": [0, 1],
                        "columns": ["sepal length (cm)", "sepal width (cm)", "petal length (cm)", "petal width (cm)"],
                        "data": [[5.1, 3.5, 1.4, 0.2], [4.9, 3.0, 1.4, 0.2]]
                        }
                    }
              )

    In the SDK call, the endpoint is identified by its name, not by a URL. The SDK builds the invocations URL from DATABRICKS_HOST. The inputs argument is the same JSON body you'd send with curl. With ai_query, the function calls an existing serving endpoint and parses the response it returns. The basic form is ai_query(endpoint, request). It needs Databricks Runtime 15.4 LTS or above and isn't available on Databricks SQL Classic.

    Checkpoint 9 of 9· Fill the gap

    A data scientist wants to score two rows from a notebook against the endpoint test-model-endpoint using the MLflow Deployments SDK instead of curl. Which method completes the call?

    import os
    import mlflow.deployments
    
    os.environ["DATABRICKS_HOST"] = "https://<workspace_host>.databricks.com"
    os.environ["DATABRICKS_TOKEN"] = "dapi-your-databricks-token"
    
    client = mlflow.deployments.get_deploy_client("databricks")
    
    response = client. ? (
                endpoint="test-model-endpoint",
                inputs={"dataframe_split": {
                        "index": [0, 1],
                        "columns": ["sepal length (cm)", "sepal width (cm)", "petal length (cm)", "petal width (cm)"],
                        "data": [[5.1, 3.5, 1.4, 0.2], [4.9, 3.0, 1.4, 0.2]]
                        }
                    }
              )

    Sources46

    Practise it for real

    Send a realtime scoring request to an existing custom model endpoint and read its predictions.

    1. 1.Open Serving in the sidebar, pick your endpoint, and note its name and state.

      Why: The name becomes the <endpoint-name> segment of the invocation URL. Requests only succeed once the endpoint is ready.

      You should see: The endpoint shows as Ready (READY in the API), not Not Ready.

    2. 2.Choose Query endpoint, click Show Example if it's offered, then click Send Request.

      Why: The UI is the quickest way to check the model answers before you write any client code.

      You should see: A JSON response with a predictions key.

    3. 3.Export DATABRICKS_API_TOKEN (preferably a service principal's token) and ENDPOINT_INVOCATION_URL set to https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations.

      Why: Every REST or SDK scoring request has to carry a Databricks API token.

      You should see: Both variables are set in your shell.

    4. 4.Use curl to POST a dataframe_split body to $ENDPOINT_INVOCATION_URL with -u token:$DATABRICKS_API_TOKEN and Content-Type: application/json.

      Why: dataframe_split is the recommended format and keeps column order.

      You should see: {"predictions": [...]} with one entry per row you sent.

    5. 5.Send the same rows with the MLflow Deployments SDK: client.predict(endpoint="<endpoint-name>", inputs={"dataframe_split": ...}).

      Why: The SDK takes the endpoint name instead of the URL, and reads the host and token from DATABRICKS_HOST and DATABRICKS_TOKEN.

      You should see: The same predictions as the curl call.

    Stuck? Get a nudge

    If curl returns an authentication error on an endpoint with route optimization enabled, use an OAuth token and the endpoint's dedicated URL instead.

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Each model you serve is available as a REST API that you can integrate into your web or client application.”
      ↩︎ Why per-request predictions need a serving endpoint
      “Model Serving provides a highly available and low-latency service for deploying models.”
      ↩︎ Why per-request predictions need a serving endpoint
    2. 2.
      “The first request after scaling to zero experiences a "cold start," leading to higher latency.”
      ↩︎ Why per-request predictions need a serving endpoint
      “Scaling up from zero usually takes 10-20 seconds, but can sometimes take minutes. There is no SLA on scale from zero latency.”
      ↩︎ Why per-request predictions need a serving endpoint
      “Deploying a newly registered model version involves packaging the model and its model environment and provisioning the model endpoint itself.”
      ↩︎ What a query targets: endpoint name, served entity and READY state
      “Request timeout: If model computation takes longer than 597 seconds, requests will time out.”
      ↩︎ The invocation URL and token authentication
      “For latency-sensitive applications or endpoints requiring continuous availability, disable scale to zero.”
      ↩︎ Checkpoint
    3. 3.
      “To specify a model from Unity Catalog, provide the full model name including parent catalog and schema such as, catalog.schema.example-model.”
      ↩︎ What a query targets: endpoint name, served entity and READY state
      “The endpoint's config_update state is NOT_UPDATING and the served model is in a READY state.”
      ↩︎ What a query targets: endpoint name, served entity and READY state
      “Click Create. The Serving endpoints page appears with Serving endpoint state shown as Not Ready.”
      ↩︎ Exam trap 4
    4. 4.
      “To send a scoring request through the REST API or MLflow Deployment SDK, you must have a Databricks API token.”
      ↩︎ The invocation URL and token authentication
      “As a security best practice for production scenarios, Databricks recommends that you use machine-to-machine OAuth tokens for authentication during production.”
      ↩︎ The invocation URL and token authentication
      “Text.Format("Bearer #{0}", {apiToken})”
      ↩︎ The invocation URL and token authentication
      “For custom models, Model Serving supports scoring requests in Pandas DataFrame (JSON) or Tensor input (JSON or Protobuf).”
      ↩︎ Request formats and the predictions response
      “(Recommended)dataframe_split format is a JSON-serialized Pandas DataFrame in the split orientation.”
      ↩︎ Request formats and the predictions response
      “Use this format if all the input tensors have the same 0-th dimension.”
      ↩︎ Request formats and the predictions response
      “The response from the endpoint contains the output from your model, serialized with JSON, wrapped in a predictions key.”
      ↩︎ Request formats and the predictions response
      “Select Query endpoint from the Serving endpoint page in your Databricks workspace.”
      ↩︎ Sending the request: Serving UI, REST, Deployments SDK and ai_query
      “For the MLflow Deployment SDK, MLflow 2.9 or above is required.”
      ↩︎ Sending the request: Serving UI, REST, Deployments SDK and ai_query
      “Invoke model inference directly from SQL using the ai_query SQL function.”
      ↩︎ Sending the request: Serving UI, REST, Deployments SDK and ai_query
      “The following example assumes a ENDPOINT_INVOCATION_URL like https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations”
      ↩︎ Key concept
      “The following example assumes a ENDPOINT_INVOCATION_URL like https://<databricks-instance>/serving-endpoints/<endpoint-name>/invocations”
      ↩︎ Exam trap 1
      “Route-optimized endpoints only accept OAuth tokens (not personal access tokens) and must be queried at a dedicated URL.”
      ↩︎ Exam trap 2
      “This format does not guarantee the preservation of column ordering, and the split format is preferred over the records format.”
      ↩︎ Exam trap 3
      “Route-optimized endpoints only accept OAuth tokens (not personal access tokens) and must be queried at a dedicated URL.”
      ↩︎ Checkpoint
      “This format does not guarantee the preservation of column ordering, and the split format is preferred over the records format.”
      ↩︎ Prediction
      “instances is a tensors-based format that accepts tensors in row format. Use this format if all the input tensors have the same 0-th dimension.”
      ↩︎ Checkpoint
    5. 5.
      “If you plan to access your serving endpoint outside of the Databricks Serving UI, you need a DATABRICKS_API_TOKEN.”
      ↩︎ The invocation URL and token authentication
    6. 6.
      “Invokes an existing Databricks Model Serving endpoint and parses and returns its response.”
      ↩︎ Sending the request: Serving UI, REST, Deployments SDK and ai_query
      “This function is not available on Databricks SQL Classic.”
      ↩︎ Sending the request: Serving UI, REST, Deployments SDK and ai_query

    Ready to test yourself?

    Practise the 7 questions on this subdomain.

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