doc/api/model_registry.md
{{< details >}}
{{< /details >}}
Use this API to interact with the machine learning model registry.
The :model_version_id attribute in each endpoint accepts either a model version ID or a candidate run ID.
For more information, see Model version and candidate IDs.
Downloads a specified file from a machine learning model package.
GET /api/v4/projects/:id/packages/ml_models/:model_version_id/files/(*path/):file_name
Supported attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
id | integer or string | Yes | The ID or URL-encoded path of the project. |
model_version_id | integer or string | Yes | The model version ID or candidate run ID. See Model version and candidate IDs. |
file_name | string | Yes | The filename. |
path | string | No | The directory path for the file. |
If successful, returns 200 OK and the file contents.
Example request:
curl --header "Authorization: Bearer <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/foo.txt"
Example request with a directory path:
curl --header "Authorization: Bearer <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/my_dir/foo.txt"
Uploads a file to a machine learning model package.
Authorizes a file upload to a machine learning model package.
PUT /api/v4/projects/:id/packages/ml_models/:model_version_id/files/(*path/):file_name/authorize
Supported attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
id | integer or string | Yes | The ID or URL-encoded path of the project. |
model_version_id | integer or string | Yes | The model version ID or candidate run ID. See Model version and candidate IDs. |
file_name | string | Yes | The filename. |
path | string | No | The directory path for the file. |
If successful, returns 200 OK.
Example request:
curl --request PUT \
--header "Authorization: Bearer <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/model.pkl/authorize"
Uploads the file to a machine learning model package.
PUT /api/v4/projects/:id/packages/ml_models/:model_version_id/files/(*path/):file_name
Supported attributes:
| Attribute | Type | Required | Description |
|---|---|---|---|
id | integer or string | Yes | The ID or URL-encoded path of the project. |
model_version_id | integer or string | Yes | The model version ID or candidate run ID. See Model version and candidate IDs. |
file_name | string | Yes | The filename. |
path | string | No | The directory path for the file. |
file | file | Yes | The file to upload. |
If successful, returns 201 Created.
Example request:
curl --request PUT \
--header "Authorization: Bearer <your_access_token>" \
--form "[email protected]" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/model.pkl"
Example request with a directory path:
curl --request PUT \
--header "Authorization: Bearer <your_access_token>" \
--form "[email protected]" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/2/files/my_dir/model.pkl"
The :model_version_id attribute accepts either a model version ID or
a candidate run ID.
To find the model version ID, check the URL of the model version page.
For example, in https://gitlab.example.com/my-namespace/my-project/-/ml/models/1/versions/5,
the model version ID is 5.
curl --header "Authorization: Bearer <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/5/files/model.pkl"
To use a candidate run ID, prepend the internal ID of the candidate
with candidate:. For example, in
https://gitlab.example.com/my-namespace/my-project/-/ml/candidates/5,
the value for :model_version_id is candidate:5.
curl --header "Authorization: Bearer <your_access_token>" \
--url "https://gitlab.example.com/api/v4/projects/1/packages/ml_models/candidate:5/files/model.pkl"