---
title: Create an endpoint for custom models in Model Serving
description: Create a Model Serving endpoint for a custom model with the MLflow Deployments SDK, the Serving UI, or the REST API, on CPU or GPU compute.
canonical_url: https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints
---

# Create an endpoint for custom models in Model Serving

Databricks Model Serving hosts a registered custom model on an endpoint that you query over REST. This page creates one with the MLflow Deployments SDK, then covers the Serving UI, the REST API, and GPU workload types.

## <a id="requirement" />Requirements

* Your workspace must be in a [supported region](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-limits.md#regions).
* A custom model registered in Unity Catalog (recommended) or in the legacy [Workspace Model Registry](https://docs.databricks.com/aws/en/machine-learning/manage-model-lifecycle/workspace-model-registry.md).
* Permission to create the endpoint. See [Check the permissions an endpoint needs](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#permissions).
* If you use custom libraries or libraries from a private mirror server with your model, see [Add Python libraries to Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/private-libraries-model-serving.md) before you create the model endpoint.

## <a id="notebook-examples" /><a id="example-notebooks" />Try a notebook example

The following notebooks include different models registered in Databricks that you can use to get started with model serving endpoints. For additional examples, see [Tutorial: Deploy and query a custom model](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-intro.md).

To import the model examples into the workspace, follow the directions in [Import a notebook](https://docs.databricks.com/aws/en/notebooks/notebook-export-import.md#import-notebook). After you choose and create a model from one of the examples, [register it in Unity Catalog](https://docs.databricks.com/aws/en/machine-learning/manage-model-lifecycle/index.md), and then follow the [Serving UI steps](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-serving-ui) for model serving.

#### Train and register a scikit-learn model for model serving notebook

[Get notebook](https://docs.databricks.com/notebooks/source/machine-learning/train-register-scikit-model-serving.html)

#### Train and register a HuggingFace model for model serving notebook

[Get notebook](https://docs.databricks.com/notebooks/source/machine-learning/train-register-hugging-face-model-serving.html)

## <a id="create-an-endpoint" /><a id="create" />Create an endpoint

Create the endpoint with one of these methods:

* [Create with the MLflow Deployments SDK](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-mlflow-sdk)
* [Create in the Serving UI](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-serving-ui)
* [Create with the REST API](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-rest-api)

For the Databricks SDK for Python, see [`serving_endpoints.create`](https://databricks-sdk-py.readthedocs.io/en/latest/workspace/serving/serving_endpoints.html) in the SDK reference. For foundation models, including external models, see [Create foundation model serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-foundation-model-endpoints.md).

### <a id="create-mlflow-sdk" />Create with the MLflow Deployments SDK

The [MLflow Deployments SDK](https://mlflow.org/docs/latest/python_api/mlflow.deployments.html) provides create, update, and delete APIs that accept the same parameters as the REST API.

### Install MLflow

In a Databricks notebook, run the following:

```python
%pip install mlflow
```

The command finishes without errors. Outside a notebook, run `pip install mlflow` in a terminal, and set the `DATABRICKS_HOST` and `DATABRICKS_TOKEN` environment variables to your workspace URL and an access token. See [Authorize access to Databricks resources](https://docs.databricks.com/aws/en/dev-tools/auth/index.md).

### Create the endpoint

The example serves version 3 of `catalog.schema.my-ads-model` with custom concurrency, set by `min_provisioned_concurrency` and `max_provisioned_concurrency`. Concurrency values must be multiples of 4. See [Model Serving limits and regions](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-limits.md). Run the following:

```python
import mlflow
from mlflow.deployments import get_deploy_client

mlflow.set_registry_uri("databricks-uc")
client = get_deploy_client("databricks")

endpoint = client.create_endpoint(
    name="unity-catalog-model-endpoint",
    config={
        "served_entities": [
            {
                "name": "ads-entity",
                "entity_name": "catalog.schema.my-ads-model",
                "entity_version": "3",
                "min_provisioned_concurrency": 4,
                "max_provisioned_concurrency": 12,
                "scale_to_zero_enabled": False
            }
        ]
    }
)
```

The call returns the endpoint's details, and `endpoint["name"]` is `unity-catalog-model-endpoint`.

### Wait until the endpoint is ready

Run the following check again until the output is `READY`:

```python
endpoint = client.get_endpoint(endpoint="unity-catalog-model-endpoint")
print(endpoint["state"]["ready"])
```

Until the endpoint is ready, the output is `NOT_READY`, and the Serving UI shows the endpoint as Not ready.

### <a id="create-serving-ui" />Create in the Serving UI

To create an endpoint in the Serving UI, use the steps for your cloud.

For models in Unity Catalog (recommended) or the legacy [Workspace Model Registry](https://docs.databricks.com/aws/en/machine-learning/manage-model-lifecycle/workspace-model-registry.md):

### Open the Serving UI

Select **Serving** in the sidebar to display the Serving UI. Select **Create serving endpoint**.

![Model serving pane in the workspace UI](https://docs.databricks.com/aws/en/images/machine-learning/serving-pane.png)

### Name the endpoint

In the **Name** field provide a name for your endpoint. Endpoint names can't use the `databricks-` prefix. This prefix is reserved for Databricks preconfigured endpoints.

### Configure the served entities

In the **Served entities** section:

1. Select the **Entity** field to open the **Select served entity** form.
2. Select either **My models - Unity Catalog** or **My models - Model Registry** based on where your model is registered. The form dynamically updates based on your selection.
   * Not all models are custom models. Models can be [foundation models](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-foundation-model-endpoints.md) or features for [feature serving](https://docs.databricks.com/aws/en/machine-learning/feature-store/feature-function-serving.md).
3. Select which model and model version you want to serve.
4. Select the percentage of traffic to route to your served model.
5. Select what size compute to use. You can use CPU or GPU computes for your workloads. See [Compute type](https://docs.databricks.com/aws/en/machine-learning/model-serving/custom-models.md#compute-type) for available workload types, including the `CPU_MEDIUM` and `CPU_LARGE` options, which are in [Beta](https://docs.databricks.com/aws/en/release-notes/release-types.md), for models that need more memory than the standard `CPU` type. For GPU code examples, see [GPU workload types](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#gpu).
6. Under **Compute scale-out**, select the size of the compute scale out that corresponds with the number of requests this served model can process at the same time. The value is roughly queries per second (QPS) times model run time. For customer-defined compute settings, see [model serving limits](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-limits.md).
   1. For the `CPU` workload type, **Small** is 4 concurrent requests, **Medium** is 8-16, and **Large** is 16-64. For other workload types, the ranges can differ. The Serving UI shows the sizes available for your workload type.
7. Set whether the endpoint scales to zero when not in use. With scale to zero enabled, each size can scale down to 0. Scale to zero is not recommended for production endpoints, as capacity is not guaranteed when scaled to zero. When an endpoint scales to zero, there is additional latency, also referred to as a cold start, when the endpoint scales back up to serve requests.
8. Under **Advanced configuration**, you can:
   * Rename the served entity to customize how it appears in the endpoint.
   * [Add an instance profile](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md#instance-profile) to connect to AWS resources from your endpoint.
   * Add environment variables to [connect to resources](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md) from your endpoint or [log your feature lookup DataFrame to the endpoint's inference table](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md#features). Logging the feature lookup DataFrame requires MLflow 2.14.0 or above. The served entity also needs **Enable tracing** turned on.
9. (Optional) To add additional served entities to your endpoint, select **Add served entity** and repeat the configuration steps above. To serve multiple models or model versions from a single endpoint and control the traffic split between them, see [serve multiple models](https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-multiple-models-to-serving-endpoint.md).

### Choose route optimization

In the **Route optimization** section, you can enable route optimization for your endpoint. Route optimization is recommended for endpoints with high QPS and throughput requirements. See [Route optimization for Model Serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/route-optimization.md).

### Choose governance features

Select which governance features to enable on your endpoint. See [AI governance with Unity Gateway](https://docs.databricks.com/aws/en/ai-gateway/index.md).

### Select Create

Select **Create**. The endpoint's page opens, and its status shows Not ready.

![Create a model serving endpoint](https://docs.databricks.com/aws/en/images/machine-learning/create-endpoint.png)

You can also:

* [Enable inference tables](https://docs.databricks.com/aws/en/ai-gateway/inference-tables-serving-endpoints.md) to automatically capture incoming requests and outgoing responses to your model serving endpoints.
* If you have inference tables enabled on your endpoint, you can [log your feature lookup DataFrame](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md#features) to the inference table. The served entity also needs **Enable tracing** turned on.

You can also add an instance profile or environment variables to store credentials for model serving. See [Secrets and credentials for Model Serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/store-env-variable-model-serving.md).

### <a id="create-rest-api" />Create with the REST API

You can create endpoints using the REST API. See [Create a new serving endpoint](https://docs.databricks.com/api/workspace/servingendpoints/create) for endpoint configuration parameters.

The following example creates an endpoint that serves the third version of the `my-ads-model` model registered in Unity Catalog. To specify a model from Unity Catalog, provide the full model name including parent catalog and schema, such as `catalog.schema.example-model`. The example uses the same concurrency settings as the MLflow Deployments SDK example above.

Send this request:

```text
POST /api/2.0/serving-endpoints
```

With this JSON body:

```json
{
  "name": "uc-model-endpoint",
  "config": {
    "served_entities": [
      {
        "name": "ads-entity",
        "entity_name": "catalog.schema.my-ads-model",
        "entity_version": "3",
        "min_provisioned_concurrency": 4,
        "max_provisioned_concurrency": 12,
        "scale_to_zero_enabled": false
      }
    ]
  }
}
```

The following is an example response. The endpoint's `config_update` state is `NOT_UPDATING` and the served model is in a `READY` state.

```json
{
  "name": "uc-model-endpoint",
  "creator": "user@example.com",
  "creation_timestamp": 1700089637000,
  "last_updated_timestamp": 1700089760000,
  "state": {
    "ready": "READY",
    "config_update": "NOT_UPDATING"
  },
  "config": {
    "served_entities": [
      {
        "name": "ads-entity",
        "entity_name": "catalog.schema.my-ads-model",
        "entity_version": "3",
        "min_provisioned_concurrency": 4,
        "max_provisioned_concurrency": 12,
        "scale_to_zero_enabled": false,
        "workload_type": "CPU",
        "state": {
          "deployment": "DEPLOYMENT_READY",
          "deployment_state_message": ""
        },
        "creator": "user@example.com",
        "creation_timestamp": 1700089760000
      }
    ],
    "config_version": 1
  },
  "tags": [
    {
      "key": "team",
      "value": "data science"
    }
  ],
  "id": "e3bd3e471d6045d6b75f384279e4b6ab",
  "permission_level": "CAN_MANAGE",
  "route_optimized": false
}
```

### <a id="gpu" />GPU workload types

GPU deployment is compatible with MLflow 2.4.0 and above. Model Serving installs the versions of `cuda` and `cuDNN` that the PyTorch and TensorFlow documentation recommend. See [Troubleshoot Model Serving endpoints](https://docs.databricks.com/aws/en/machine-learning/model-serving/model-serving-debug.md). To serve a model with the same library versions you trained or tested it with, register it from an [AI Runtime](https://docs.databricks.com/aws/en/machine-learning/ai-runtime/index.md) notebook as an [express deployment](https://docs.databricks.com/aws/en/machine-learning/model-serving/express-deployments.md). For LLMs, see [Deploy a custom LLM with Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/serve-custom-llms.md).

To create a GPU endpoint with the MLflow Deployments SDK, set `workload_type` on the served entity to a GPU type from the table below.

```python
import mlflow
from mlflow.deployments import get_deploy_client

mlflow.set_registry_uri("databricks-uc")
client = get_deploy_client("databricks")

endpoint = client.create_endpoint(
    name="gpu-model-endpoint",
    config={
        "served_entities": [{
            "entity_name": "catalog.schema.my-gpu-model",
            "entity_version": "1",
            "workload_type": "GPU_SMALL",
            "workload_size": "Small",
            "scale_to_zero_enabled": False
        }]
    }
)
```

Check the state with the `get_endpoint` call from the wait step, using the name `gpu-model-endpoint`.

To use the REST API, include `workload_type` in the served entity configuration, as in [Create with the REST API](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-rest-api). In the Serving UI, select a GPU type from the **Compute type** dropdown when creating your endpoint, as in [Create in the Serving UI](https://docs.databricks.com/aws/en/machine-learning/model-serving/create-manage-serving-endpoints.md#create-serving-ui).

The available GPU workload types depend on your cloud provider, as summarized in the following table. For every workload type, including types in Beta, see [Compute type](https://docs.databricks.com/aws/en/machine-learning/model-serving/custom-models.md#compute-type).

| GPU workload type | GPU instance | GPU memory |
| ----------------- | ------------ | ---------- |
| `GPU_SMALL`       | 1xT4         | 16GB       |
| `GPU_MEDIUM`      | 1xA10G       | 24GB       |
| `MULTIGPU_MEDIUM` | 4xA10G       | 96GB       |
| `GPU_MEDIUM_8`    | 8xA10G       | 192GB      |

For GPU endpoints, the concurrency value determines the number of replicas allocated to serve your model. The number of replicas equals the concurrency value divided by 4. For example, setting `min_provisioned_concurrency` to 12 provisions 3 replicas.

## <a id="identity-and-access" /><a id="permissions" />Check the permissions an endpoint needs

To create or update a model serving endpoint, both the caller and the endpoint's recorded creator must:

* Be a member of the workspace.
* Hold the `workspace-access` entitlement.

### Creator identity

When you create an endpoint, Databricks records the calling identity as the endpoint's *creator*. This identity, typically a service principal, is used to access Unity Catalog resources on behalf of the endpoint and can't be changed after creation.

If the recorded creator lacks the required Unity Catalog grants or has been removed from the workspace, you must delete the endpoint and recreate it under a service principal that has the required permissions and is a current workspace member.

Configuration and served-entity updates re-evaluate the recorded creator's workspace membership and grants. Updates fail with `PERMISSION_DENIED` if the recorded creator is no longer a workspace member, even when the caller has valid permissions.

### Served entity grants

The recorded creator must hold the following grants on each served entity. Grants validated at endpoint creation or update cause the request to fail with `PERMISSION_DENIED` if missing. Grants required at query time are not validated upfront, so missing grants cause runtime errors when the endpoint serves traffic.

| Resource type       | Required grant                                                                   | When validated              |
| ------------------- | -------------------------------------------------------------------------------- | --------------------------- |
| Unity Catalog model | `USE CATALOG` on the catalog, `USE SCHEMA` on the schema, `EXECUTE` on the model | Endpoint creation or update |

> [!NOTE]
>
> If a Unity Catalog model declares transitive function dependencies, the recorded creator also needs `EXECUTE` on those upstream functions.

### Manage endpoint access

To understand access control options for model serving endpoints, see [Manage permissions on a model serving endpoint](https://docs.databricks.com/aws/en/machine-learning/model-serving/manage-serving-endpoints.md#permissions).

## <a id="modify-a-custom-model-endpoint" /><a id="endpoint-config" />Update an endpoint's configuration

To change an endpoint's served models, compute, or traffic after you create it, see [Update an endpoint's configuration in Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/update-endpoint-configuration.md).

## <a id="scoring-a-model-endpoint" /><a id="score" />Score a model endpoint

To score your model, send requests to the model serving endpoint.

* See [Query serving endpoints for custom models](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-custom-model-endpoints.md).
* See [Use foundation models](https://docs.databricks.com/aws/en/machine-learning/model-serving/score-foundation-models.md).

## Additional resources

| Resource                                                                                                                            | Description                                                                       |
| ----------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------- |
| [Manage endpoints for Model Serving](https://docs.databricks.com/aws/en/machine-learning/model-serving/manage-serving-endpoints.md) | Check an endpoint's status, stop and start it, delete it, or set its permissions. |
| [Databricks real-time serving Python SDK](https://databricks-sdk-py.readthedocs.io/en/latest/dbdataclasses/serving.html#)           | Reference for the serving classes in the Databricks SDK for Python.               |
