Skip to content

How to work with Models using the REST API

Use the /models endpoint to work with models.

MethodDescriptionEndpoint
GETRetrieve a list of models/models
GETRetrieve metadata of a specific model/models/catalog.schema.model
POSTCreate a new model/models
DELETERemove a model/models/catalog.schema.model

The following sections show how to use each of these methods. Examples are demonstrated using Python and the requests library.

Use the GET command at the /models endpoint to retrieve a list of all available volumes on the server. You will need to specify the catalog and schema names.

BASE_URL = "http://localhost:8080/api/2.1/unity-catalog"
ENDPOINT = "/models"
URL = f"{BASE_URL}{ENDPOINT}"
params = {
"catalog_name": "unity",
"schema_name": "default"
}
response = requests.get(URL, params=params)
response.json()

To retrieve metadata about a specific model, use the GET command at the /models/<full-model-name> endpoint. The full name means the 3-level namespace reference in the standard Unity Catalog format: catalog.schema.model.

For example:

BASE_URL = "http://localhost:8080/api/2.1/unity-catalog"
ENDPOINT = "/models/unity.default.model_name"
URL = f"{BASE_URL}{ENDPOINT}"
response = requests.get(URL, headers=headers)
data = response.json()

Use the DELETE command at the /models/<full-model-name> endpoint to delete a specific model. The full name is the 3-level namespace reference to your model: catalog.schema.model. For example:

BASE_URL = "http://localhost:8080/api/2.1/unity-catalog"
ENDPOINT = "/functions/unity.default.lowercase"
URL = f"{BASE_URL}{ENDPOINT}"
response = requests.delete(URL)