# models **Warning: Deprecated**: As of 15 July 2024, Gradient API endpoints are deprecated and no longer available for Paperspace users. ## create Create a model for a URL or Dataset ID #### Examples ## CLI ```bash gradient models create \ --name "New Model" \ --modelType "Tensorflow" \ --datasetRef "dsj1g16f1z67jai" ``` ## cURL ```bash curl -X POST 'https://api.paperspace.io/mlModels/createModelV2' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "name": "New Model", "datasetRef": "dsj1g16f1z67jai", "modelType": "Tensorflow" }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.create( name='New Model', dataset_ref='dsj1g16f1z67jai', model_type='Tensorflow' )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--name` | string | required | Model name | | `--modelType` | string | required | Model type: `Tensorflow`, `ONNX`, `Custom` | | `--datasetRef` | string | required | Dataset ref to associate model with | | `--projectId` | string | optional | ID of a project | | `--modelSummary` | string | optional | Model summary | | `--notes` | string | optional | Additional notes | | `--tag` | string | optional | One or many tags that you want to add | | `--tags` | string | optional | Tags separated by comma | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text Model created with ID: moseiu8dirfro8k ``` ## cURL ```json { "id": "moseiu8dirfro8k", "projectId": null, "updatedByUserId": "ubx9ce8k", "updatedByUserEmail": "david+test@paperspace.com", "accessorHandles": null, "modelType": "Tensorflow", "name": "New Model", "tag": null, "summary": null, "detail": null, "params": null, "url": null, "notes": null, "isDeleted": false, "isPublic": false, "dtCreated": "2022-03-22T01:41:44.850Z", "dtModified": "2022-03-22T01:41:44.850Z", "dtUploaded": null, "dtDeleted": null, "modelPath": null, "deploymentState": null, "tags": null, "datasetId": null, "datasetVersion": null, "datasetRef": "dsj1g16f1z67jai" } ``` ## Python ```text moseiu8dirfro8k ``` ## details Show model details #### Examples ## CLI ```bash gradient models details \ --id "moseiu8dirfro8k" ``` ## cURL ```bash curl -X GET 'https://api.paperspace.io/mlModels/getModelList/' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "filter": { "where": { "and": [ { "id": "moseiu8dirfro8k" } ] } } }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.get( model_id='moseiu8dirfro8k' )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--id` | string | required | Model ID | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text +------------------+-----------------+ | ID | moseiu8dirfro8k | +------------------+-----------------+ | Name | New Model | | Project ID | None | | Model Type | Tensorflow | | URL | None | | Deployment State | None | | Tags | | +------------------+-----------------+ ``` ## cURL ```json { "modelList": [ { "id": "moseiu8dirfro8k", "projectId": null, "updatedByUserId": "ubx9ce8k", "updatedByUserEmail": "da...@paperspace.com", "accessorHandles": null, "modelType": "Tensorflow", "name": "New Model", "tag": null, "summary": null, "detail": null, "params": null, "url": null, "notes": null, "isDeleted": false, "isPublic": false, "dtCreated": "2022-03-22T01:41:44.850Z", "dtModified": "2022-03-22T01:41:44.850Z", "dtUploaded": null, "dtDeleted": null, "modelPath": null, "deploymentState": null, "tags": null, "datasetVersionId": null, "datasetId": null, "datasetVersion": null, "datasetRef": null } ], "total": 5, "displayTotal": 1 } ``` ## Python ```js Model( (id = "moseiu8dirfro8k"), (name = "New Model"), (project_id = None), (cluster_id = None), (tags = []), (model_type = "Tensorflow"), (url = None), (model_path = None), (deployment_state = None), (summary = None), (detail = None), (notes = None), (dataset_ref = None) ); ``` ## list List models with optional filtering #### Examples ## CLI ```bash gradient models list ``` ## cURL ```bash curl -X GET 'https://api.paperspace.io/mlModels/getModelList/' \ -H 'x-api-key: d44808a2785d6a...' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.list()) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--projectId` | string | optional | Filter by project ID | | `--tag` | string | optional | Filter by tag | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text +-----------+-----------------+------------+------------+ | Name | ID | Model Type | Project ID | +-----------+-----------------+------------+------------+ | New Model | moseiu8dirfro8k | Tensorflow | None | +-----------+-----------------+------------+------------+ ``` ## cURL ```json { "modelList": [ { "id": "moseiu8dirfro8k", "projectId": null, "updatedByUserId": "ubx9ce8k", "updatedByUserEmail": "da...@paperspace.com", "accessorHandles": null, "modelType": "Tensorflow", "name": "New Model", "tag": null, "summary": null, "detail": null, "params": null, "url": null, "notes": null, "isDeleted": false, "isPublic": false, "dtCreated": "2022-03-22T01:41:44.850Z", "dtModified": "2022-03-22T01:41:44.850Z", "dtUploaded": null, "dtDeleted": null, "modelPath": null, "deploymentState": null, "tags": null, "datasetVersionId": null, "datasetId": null, "datasetVersion": null, "datasetRef": null } ], "total": 1, "displayTotal": 1 } ``` ## Python ```js [ Model( (id = "moseiu8dirfro8k"), (name = "New Model"), (project_id = None), (cluster_id = None), (tags = []), (model_type = "Tensorflow"), (url = None), (model_path = None), (deployment_state = None), (summary = None), (detail = None), (notes = None), (dataset_ref = None) ), ]; ``` ## download Download model #### Examples ## CLI ```bash gradient models download \ --id "moseiu8dirfro8k" \ --destinationDir "./" ``` ## cURL ```bash curl -X GET 'https://api.paperspace.io/mlModels/listFiles/' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "id": "moseiu8dirfro8k", "links": "True" }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.get_model_files( model_id='moseiu8dirfro8k', links=True )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--id` | string | required | Model ID | | `--destinationDir` | string | required | Destination directory | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text Downloading: data.txt ``` ## cURL ```json [ { file: "data.txt", url: "https://osg-ny2.paperspace.io/tewr3st2z/tewr3st2z/datasets/dsj1g16f1z67jai/versions/xbreynt/data/data.txt?AWSAccessKeyId=6P0NXXIKSB49ZW7ZXESL&Expires=1647944273&Signature=h6MrW%2B2WJuA%2FqE3MyAg9Qxpq4HQ%3D&response-content-disposition=attachment%3Bfilename%3D%22data.txt%22", }, ]; ``` ## Python ```js [ ModelFile( (file = "data.txt"), (url = "https://osg-ny2.paperspace.io/tewr3st2z/tewr3st2z/datasets/dsj1g16f1z67jai/versions/xbreynt/data/data.txt?AWSAccessKeyId=6P0NXXIKSB49ZW7ZXESL&Expires=1647944439&Signature=Ji%2Fsc0tJYuGGMcgxvQFtRnS4Wio%3D&response-content-disposition=attachment%3Bfilename%3D%22data.txt%22"), (size = None) ), ]; ``` ## upload Upload a model file or directory #### Examples ## CLI ```bash gradient models upload fashion-mnist.onnx \ --name "New Model" \ --modelType "ONNX" ``` ## cURL ```text This command is not available via CURL. ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.upload( path='./fashion-mnist.onnx', name='New Model', model_type='ONNX' )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--name` | string | required | Model name | | `--modelType` | string | required | Model type: `Tensorflow`, `ONNX`, `Custom` | | `--projectId` | string | optional | ID of a project | | `--clusterID` | string | optional | ID of a cluster | | `--modelSummary` | string | optional | Model summary | | `--notes` | string | optional | Additional notes | | `--tag` | string | optional | One or many tags that you want to add | | `--tags` | string | optional | Tags separated by comma | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text 100% (408542 of 408542) |#####################################################################################################################| Elapsed Time: 0:00:00 Time: 0:00:00 Model uploaded with ID: moc0ackf1ivmmy ``` ## cURL ``` This command is not available via CURL. ``` ## Python ```text moc0ackf1ivmmy ``` ## delete Delete a model #### Examples ## CLI ```bash gradient models delete \ --id "moseiu8dirfro8k" ``` ## cURL ```bash curl -X POST 'https://api.paperspace.io/mlModels/deleteModel/' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw ' { "id": "moseiu8dirfro8k" }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.delete( model_id='moseiu8dirfro8k' )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--id` | string | required | Model ID | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text Model deleted ``` ## cURL ``` ``` ## Python ```text None ``` ## tags add Add tags to ml model #### Examples ## CLI ```bash gradient models tags add \ --id "moseiu8dirfro8k" \ --tag "import202203" ``` ## cURL ```bash curl -X PUT 'https://api.paperspace.io/entityTags/updateTags' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "entity": "mlModel", "entityId": "moseiu8dirfro8k", "tags": [ "import202203" ] }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.add_tags( entity_id='moseiu8dirfro8k', tags=['import202203'] )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--id` | string | required | Model ID | | `--tag` | string | optional | One or more tags that you want to add to ml model | | `--tags` | string | optional | Separated by comma tags that you want to add to ml model | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text Tags added to ml model ``` ## cURL ```json [ { "tagId": 680, "entity": "mlModel", "entityId": 32023, "dtCreated": "2022-03-22T02:37:43.788Z", "dtDeleted": null, "userId": 750386, "id": 7550, "entity_id": 32023, "tag": { "name": "import202203", "dtCreated": "2022-03-15T01:29:39.877Z", "id": 680 } } ] ``` ## Python ```text None ``` ## tags remove Remove tags from ml model #### Examples ## CLI ```bash gradient models tags remove \ --id "moseiu8dirfro8k" \ --tag "import202203" ``` ## cURL ```bash curl -X PUT 'https://api.paperspace.io/entityTags/updateTags' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "entity": "mlModel", "entityId": "moseiu8dirfro8k", "tags": [] }' ``` ## Python ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.remove_tags( entity_id='moseiu8dirfro8k', tags=['import202203'] )) ``` #### Options | Name | Type | Attributes | Description | |---|---|---|---| | `--id` | string | required | Model ID | | `--tag` | string | optional | One or more tags that you want to add to ml model | | `--tags` | string | optional | Separated by comma tags that you want to add to ml model | | `--apiKey` | string | optional | API key to use this time only | | `--optionsFile` | string | optional | Path to YAML with predefined options | | `--createOptionsFile` | string | optional | Generate template options file | #### Response ## CLI ```text Tags removed from ml model ``` ## cURL ``` [] ``` ## Python ```text None ```