### Install Paperspace Node.js Client Library with npm Source: https://docs.digitalocean.com/reference/paperspace/core/install Installs the Paperspace Node.js client library. It can be installed globally for system-wide availability or locally within a project. Requires Node.js v8.12.0 or later. ```bash npm install paperspace-node ``` -------------------------------- ### Install Paperspace CLI with npm Source: https://docs.digitalocean.com/reference/paperspace/core/install Installs the Paperspace Node.js CLI globally using npm. Requires Node.js v8.12.0 or later. This command makes the 'paperspace' command available system-wide. ```bash npm install -g paperspace-node ``` -------------------------------- ### Start Notebook API Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks This API endpoint allows you to start a notebook instance. You can specify the notebook ID and the desired machine type. ```APIDOC ## POST /notebooks/v2/startNotebook ### Description Starts a notebook instance with the specified ID and machine type. ### Method POST ### Endpoint https://api.paperspace.io/notebooks/v2/startNotebook ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **notebookId** (string) - Required - The ID of the notebook to start. - **machineType** (string) - Required - The type of virtual machine to use for the notebook (e.g., 'P4000'). - **clusterID** (string) - Optional - The ID of the cluster to use. - **shutdownTimeout** (string) - Optional - The shutdown timeout in hours. - **isPreemptible** (string) - Optional - Specifies if the instance should be preemptible. - **tag** (string) - Optional - A tag to add to the notebook. - **tags** (string) - Optional - Comma-separated tags to add to the notebook. ### Request Example ```json { "notebookId": "ncbf3hcmao", "machineType": "P4000" } ``` ### Response #### Success Response (200) - **name** (string) - The name of the notebook. - **handle** (string) - The handle of the notebook. - **jobHandle** (string) - The job handle associated with the notebook. - **project** (string) - The project the notebook belongs to. - **projectHandle** (string) - The handle of the project. - **state** (string) - The current state of the notebook (e.g., 'Pending', 'Running'). - **token** (string) - An authentication token. - **container** (string) - The container image used for the notebook. - **containerUrl** (string) - The URL of the container image. - **baseContainer** (string) - The base container image. - **baseContainerUrl** (string) - The URL of the base container image. - **vmType** (string) - The type of virtual machine. - **cluster** (string) - The cluster the notebook is running on. - **clusterId** (string) - The ID of the cluster. #### Response Example ```json { "name": "ncbf3hcmao", "handle": "n4lwwzwf6h", "jobHandle": "jjve42jl22ypx7qk", "project": "phoebe-dropout", "projectHandle": "prjpkflqz", "state": "Pending", "token": "75c874129669c3a2cd355f1c618a1cac", "container": "paperspace/nb-pytorch:22.02-py3", "containerUrl": "paperspace/nb-pytorch:22.02-py3", "baseContainer": "paperspace/nb-pytorch:22.02-py3", "baseContainerUrl": "paperspace/nb-pytorch:22.02-py3", "vmType": "P4000", "cluster": "gradient01-ny2", "clusterId": "clg07azjl" } ``` ``` -------------------------------- ### Install Paperspace CLI using curl Source: https://docs.digitalocean.com/reference/paperspace/pspace/install This command downloads and executes the installation script for the Paperspace CLI. It is compatible with macOS, Linux, and Windows with WSL. Ensure you have `curl` installed. ```shell curl -fsSL https://paperspace.com/install.sh | sh ``` -------------------------------- ### Verify Gradient CLI Installation Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Checks the installed version of the Gradient CLI. This command is used to confirm that the installation was successful and to display the current version number, typically in a format like `v2.0.5`. ```bash gradient version ``` -------------------------------- ### Start Notebook using CLI Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Starts a Paperspace notebook instance using the Gradient CLI. Requires a notebook ID and machine type. Optional parameters include cluster ID, shutdown timeout, preemptible status, and tags. The response indicates the started notebook ID and a console URL. ```bash gradient notebooks start \ --id "ncbf3hcmao" \ --machineType "P4000" ``` -------------------------------- ### Install Latest Pre-release Gradient CLI Version Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Installs the latest pre-release version of the Gradient CLI. This command is useful for users who need to test or utilize features that are not yet part of a stable release. The `--pre` flag indicates that pre-release versions should be considered. ```bash pip install -U --pre gradient ``` -------------------------------- ### Start Machine Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/machine Starts a specified machine. ```APIDOC ## POST /machines/{id}/start ### Description Starts a machine identified by its ID. ### Method POST ### Endpoint /machines/{id}/start ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the machine to start. #### Query Parameters - **fields** (string) - Optional - The fields to include in the response. #### Request Body None ### Request Example None ### Response #### Success Response (200) - **id** (string) - The ID of the machine. - **state** (string) - The new state of the machine (should be "running"). #### Response Example ```json { "id": "machine-abcdef123456", "state": "running" } ``` ``` -------------------------------- ### Install Gradient CLI Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Installs the latest version of the Gradient CLI using pip. The `-U` flag ensures that all specified packages are upgraded to their newest available versions. This is the primary command for obtaining the Gradient CLI. ```bash pip install -U gradient ``` -------------------------------- ### Machines API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for machines. ```APIDOC ## Machines API ### Description Provides reference for the Paperspace Core API endpoints related to managing machines. ### Method GET ### Endpoint /machines ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Install virtualenv Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Installs the `virtualenv` package, a tool for creating isolated Python virtual environments. This is a prerequisite for managing project dependencies separately. ```bash pip install virtualenv ``` -------------------------------- ### Users API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for users. ```APIDOC ## Users API ### Description Provides reference for the Paperspace Core API endpoints related to managing users. ### Method GET ### Endpoint /users ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Start Notebook using Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Starts a Paperspace notebook programmatically using the Gradient Python client. This involves initializing the client with an API key and calling the 'start' method with the notebook ID and desired machine type. The function returns the ID of the started notebook. ```python from gradient import NotebooksClient api_key='d44808a2785d6a...' notebooks_client = NotebooksClient(api_key) print(notebooks_client.start( id='ncbf3hcmao', machine_type='P4000' )) ``` -------------------------------- ### Networks API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for networks. ```APIDOC ## Networks API ### Description Provides reference for the Paperspace Core API endpoints related to managing networks. ### Method GET ### Endpoint /networks ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Templates API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for templates. ```APIDOC ## Templates API ### Description Provides reference for the Paperspace Core API endpoints related to managing templates. ### Method GET ### Endpoint /templates ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Install Python Packages with Pip Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/workflows This snippet demonstrates the process of installing Python packages (scipy, requests, Pillow) using pip. It shows the download URLs and successful installation messages. It also includes a warning about an outdated pip version and suggests an upgrade command. ```bash +Workflows wfrjaedc275373ec4d239f3ea1af029dfd60 logs------------------------------------------------------------------------------------------------------------------------------------+ | LINE | MESSAGE | +------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | 1 | Collecting scipy==1.3.3 | | 2 | Downloading https://files.pythonhosted.org/packages/54/18/d7c101d5e93b6c78dc206fcdf7bd04c1f8138a7b1a93578158fa3b132b08/scipy-1.3.3-cp36-cp36m-manylinux1_x86_64.whl (25.2MB) | | 3 | Requirement already satisfied: numpy>=1.13.3 in /usr/local/lib/python3.6/dist-packages (from scipy==1.3.3) (1.16.4) | | 4 | Installing collected packages: scipy | | 5 | Successfully installed scipy-1.3.3 | | 6 | WARNING: You are using pip version 19.1.1, however version 21.3.1 is available. | | 7 | You should consider upgrading via the 'pip install --upgrade pip' command. | | 8 | Collecting requests==2.22.0 | | 9 | Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB) | | 10 | Collecting chardet<3.1.0,>=3.0.2 (from requests==2.22.0) | | 11 | Downloading https://files.pythonhosted.org/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB) | | 12 | Collecting certifi>=2017.4.17 (from requests==2.22.0) | | 13 | Downloading https://files.pythonhosted.org/packages/37/45/946c02767aabb873146011e665728b680884cd8fe70dde973c640e45b775/certifi-2021.10.8-py2.py3-none-any.whl (149kB) | | 14 | Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests==2.22.0) | | 15 | Downloading https://files.pythonhosted.org/packages/56/aa/4ef5aa67a9a62505db124a5cb5262332d1d4153462eb8fd89c9fa41e5d92/urllib3-1.25.11-py2.py3-none-any.whl (127kB) | | 16 | Requirement already satisfied: idna<2.9,>=2.5 in /usr/lib/python3/dist-packages (from requests==2.22.0) (2.6) | | 17 | Installing collected packages: chardet, certifi, urllib3, requests | | 18 | Successfully installed certifi-2021.10.8 chardet-3.0.4 requests-2.22.0 urllib3-1.25.11 | | 19 | WARNING: You are using pip version 19.1.1, however version 21.3.1 is available. | | 20 | You should consider upgrading via the 'pip install --upgrade pip' command. | | 21 | Collecting Pillow==6.2.1 | | 22 | Downloading https://files.pythonhosted.org/packages/10/5c/0e94e689de2476c4c5e644a3bd223a1c1b9e2bdb7c510191750be74fa786/Pillow-6.2.1-cp36-cp36m-manylinux1_x86_64.whl (2.1MB) | | 23 | Installing collected packages: Pillow | ``` -------------------------------- ### Shared Drives API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for shared drives. ```APIDOC ## Shared Drives API ### Description Provides reference for the Paperspace Core API endpoints related to managing shared drives. ### Method GET ### Endpoint /shared_drives ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Start Notebook using cURL Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Initiates a Paperspace notebook start request via cURL. This method requires an API key and sends a JSON payload containing the notebook ID and machine type to the Paperspace API endpoint. The response is a JSON object detailing the notebook's state and configuration. ```bash curl -X POST 'https://api.paperspace.io/notebooks/v2/startNotebook' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "notebookId": "ncbf3hcmao", "machineType": "P4000" }' ``` -------------------------------- ### Resource Delegations API Source: https://docs.digitalocean.com/reference/paperspace/core/commands Paperspace Core API reference guide for resource delegations. ```APIDOC ## Resource Delegations API ### Description Provides reference for the Paperspace Core API endpoints related to managing resource delegations. ### Method GET ### Endpoint /resourceDelegations ### Parameters (No specific parameters listed in the provided text) ### Request Example (Not provided) ### Response #### Success Response (200) (Details not provided) #### Response Example (Not provided) ``` -------------------------------- ### Get startup script Source: https://docs.digitalocean.com/reference/paperspace/api-reference Fetches a single startup script by its ID. ```APIDOC ## GET /v1/startup-scripts/{id} ### Description Fetches a single startup script by ID. ### Method GET ### Endpoint https://api.paperspace.com/v1/startup-scripts/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The ID of the startup script to fetch. ### Response #### Success Response (200) - **id** (string) - The unique identifier for the startup script. - **name** (string) - The name of the startup script. - **description** (string) - A description of the startup script. - **isEnabled** (boolean) - Whether the startup script is currently enabled. - **isRunOnce** (boolean) - Whether the script should only run once on first boot or on every boot. - **assignedMachineIds** (array) - A list of machine IDs to which the script is assigned. - (string) - The ID of an assigned machine. - **dtCreated** (string) - The timestamp when the startup script was created (ISO 8601 format). - **dtDeleted** (string) - The timestamp when the startup script was deleted (ISO 8601 format). #### Response Example ```json { "id": "string", "name": "string", "description": "string", "isEnabled": true, "isRunOnce": true, "assignedMachineIds": [ "string" ], "dtCreated": "2019-08-24T14:15:22Z", "dtDeleted": "2019-08-24T14:15:22Z" } ``` ``` -------------------------------- ### Initialize Paperspace Go Client Source: https://docs.digitalocean.com/reference/paperspace/core/install Shows how to initialize the Paperspace Go client library. The client can be configured using environment variables like PAPERSPACE_APIKEY, PAPERSPACE_BASEURL, and debugging flags. ```go package main import ( paperspace "github.com/Paperspace/paperspace-go" ) func getClient() *paperspace.Client { client := paperspace.NewClient() client.APIKey = p.APIKey return client } // Environment variables: // PAPERSPACE_APIKEY: Paperspace API key // PAPERSPACE_BASEURL: Paperspace API url // PAPERSPACE_DEBUG: Enable debugging // PAPERSPACE_DEBUG_BODY: Enable debug for response body ``` -------------------------------- ### GET /metrics/api/v1/list Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Retrieves time-series metrics for a specific notebook, using a provided start time. ```APIDOC ## GET /metrics/api/v1/list ### Description Retrieves time-series metrics for a specific notebook, using a provided start time. ### Method GET ### Endpoint `https://clg07azjl.paperspacegradient.com/metrics/api/v1/list` ### Parameters #### Query Parameters - **start** (string) - Required - The timestamp from which to collect metrics (e.g., ISO 8601 format). - **interval** (string) - Optional - The interval for the metrics (e.g., '30s'). - **objecttype** (string) - Required - The type of object to get metrics for (e.g., 'notebook'). - **handle** (string) - Required - The ID of the object (e.g., notebook ID). ### Response #### Success Response (200) - **metrics** (array) - An array of metric data points. #### Response Example ```json { "metrics": [ { "timestamp": "2022-03-22T04:32:29.000Z", "cpuPercentage": 10.5, "memoryUsage": 512000000 } ] } ``` ``` -------------------------------- ### Get Paperspace Gradient Notebook Metrics Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Retrieves metrics for a Paperspace Gradient notebook, typically including CPU and RAM usage. This operation may involve two steps: first, getting the notebook details to obtain `dtStarted`, and then querying the metrics API with the `dtStarted` value. The CLI uses `gradient notebooks metrics get`. cURL examples show both steps. ```bash gradient notebooks metrics get \ --id "n4lwwzwf6h" ``` ```bash # First get dtStarted value to use in the next query curl -X GET 'https://api.paperspace.io/notebooks/getNotebook' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "notebookId": "n4lwwzwf6h" }' # Then set start value in this query to dtStarted value from previous query curl -X GET 'https://clg07azjl.paperspacegradient.com/metrics/api/v1/range?charts=cpuPercentage,memoryUsage&start=2022-03-22T04:31:59.000Z&interval=30s&objecttype=notebook&handle=n4lwwzwf6h' \ -H 'x-api-key: d44808a2785d6a...' ``` -------------------------------- ### Initialize Paperspace Node.js Client Source: https://docs.digitalocean.com/reference/paperspace/core/install Demonstrates how to import and initialize the Paperspace Node.js client library. The client can be instantiated with an API key, or it will use the PAPERSPACE_API_KEY environment variable or cached credentials. ```javascript var paperspace_node = require("paperspace-node"); var paperspace = paperspace_node({ apiKey: "1ba4f98e7c0...", // <- paste your api key here }); // Alternatively, without arguments to use environment variables or cached credentials var paperspace = paperspace_node(); // Accessing the version var version = paperspace_node.VERSION; ``` -------------------------------- ### GET /notebooks/getNotebook Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Retrieves notebook information, likely including a start time ('dtStarted') needed for subsequent metric queries. ```APIDOC ## GET /notebooks/getNotebook ### Description Retrieves notebook information, potentially including a start time ('dtStarted') to be used in subsequent metric queries. ### Method GET ### Endpoint `https://api.paperspace.io/notebooks/getNotebook` ### Parameters #### Query Parameters - **notebookId** (string) - Required - The ID of the notebook. ### Request Body ```json { "notebookId": "n4lwwzwf6h" } ``` ### Response #### Success Response (200) - **dtStarted** (string) - The start time of the notebook, often in ISO 8601 format. #### Response Example ```json { "notebookId": "n4lwwzwf6h", "dtStarted": "2022-03-22T04:31:59.000Z" } ``` ``` -------------------------------- ### pspace startup-script list Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script List all startup scripts associated with your team. You can filter and sort the results. ```APIDOC ## pspace startup-script list ### Description List startup scripts in your team. ### Method GET ### Endpoint /pspace/startup-script ### Parameters #### Query Parameters - **--limit** (number, optional) - The number of items to return in the next page. - **--after** (string, optional) - The cursor to fetch the next results from. - **--orderBy** (string, optional) - The field to order items by. One of `dtCreated`. - **--asc** (boolean, optional) - Whether to order items ascending. - **--desc** (boolean, optional) - Whether to order items descending. - **-F, --fields** (string, optional) - The fields to include in the response. - **-n, --name** (string, optional) - Filter by name. ### Request Example ```bash pspace startup-script list -F name -F dtCreated ``` ### Response #### Success Response (200) - **items** (array) - A list of startup scripts - **id** (string) - The ID of the startup script - **name** (string) - The name of the startup script - **dtCreated** (string) - The creation date of the script #### Response Example ```json { "items": [ { "id": "script-12345", "name": "my-startup-script", "dtCreated": "2024-02-15T10:00:00Z" }, { "id": "script-67890", "name": "another-script", "dtCreated": "2024-02-14T09:00:00Z" } ] } ``` ``` -------------------------------- ### Create a startup script using pspace CLI Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script Creates a new startup script. Requires a name and the script content. Optionally, you can specify if the script should run only once. Dependencies include the 'pspace' CLI tool. ```bash pspace startup-script create --name "my-script" --script "echo 'Hello, World!' > /tmp/hello.txt" --run-once ``` -------------------------------- ### Get Workflow Logs using CLI, cURL, and Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/workflows Retrieves logs for a specific workflow run using the CLI, cURL for API requests, and Python. Requires workflow ID and run number. The cURL example shows a two-step process to first get log IDs and then fetch logs using job IDs. ```bash gradient workflows logs \ --id "075615ac-a036-408c-a95e-36e5b18c73aa" \ --run 1 ``` ```curl # First query to get logId values which is used for jobId in subsequent steps curl -X GET 'https://api.paperspace.io/workflows/075615ac-a036-408c-a95e-36e5b18c73aa/runs/1' \ -H 'x-api-key: d44808a2785d6a...' # Subsequent queries to get logs for each job curl -X GET 'https://logs.paperspace.io/jobs/logs?jobId=wfrj67d8451ea1bf49749925755f5e61a46e' \ -H 'x-api-key: d44808a2785d6a...' # Another query curl -X GET 'https://logs.paperspace.io/jobs/logs?jobId=wfrjaedc275373ec4d239f3ea1af029dfd60' \ -H 'x-api-key: d44808a2785d6a...' ``` ```python from gradient import WorkflowsClient api_key = 'd44808a2785d6a...' workflow_client = WorkflowsClient(api_key) print( workflow_client.logs(job_id='wfrj67d8451ea1bf49749925755f5e61a46e'), workflow_client.logs(job_id='wfrjaedc275373ec4d239f3ea1af029dfd60') ) ``` -------------------------------- ### Create Python Virtual Environment Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Creates a new Python virtual environment in the specified directory path. Replace `` with the desired location for your virtual environment. ```bash python3 -m virtualenv ``` -------------------------------- ### Get Dataset Files using CLI Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/datasets This command-line interface (CLI) example demonstrates how to retrieve files associated with a specific dataset. It requires the dataset ID and a target path where the files should be downloaded. This operation is used for accessing data stored within a dataset. ```bash gradient datasets files get \ --id "dsj1g16f1z67jai:0z7o247" \ --target-path "~/downloads" ``` -------------------------------- ### Create startup script Source: https://docs.digitalocean.com/reference/paperspace/api-reference Creates a new startup script. Startup scripts can be configured to run once on first boot or on every boot. ```APIDOC ## Create startup script ### Description Create a startup script. ### Method POST ### Endpoint /v1/startup-scripts ### Parameters #### Request Body - **name** (string) - Required - The name of the startup script. - **script** (string) - Required - The script to run on startup. - **isRunOnce** (boolean) - Optional - Default: false - Whether the script should only run once on first boot or on every boot. ### Request Example ```json { "name": "string", "script": "string", "isRunOnce": false } ``` ### Response #### Success Response (200) - **id** (string) - Description - **name** (string) - Description - **description** (string) - Description - **isEnabled** (boolean) - Description - **isRunOnce** (boolean) - Description - **assignedMachineIds** (array) - Description - **dtCreated** (string) - Description - **dtDeleted** (string) - Description #### Response Example ```json { "id": "string", "name": "string", "description": "string", "isEnabled": true, "isRunOnce": true, "assignedMachineIds": [ "string" ], "dtCreated": "2019-08-24T14:15:22Z", "dtDeleted": "2019-08-24T14:15:22Z" } ``` ``` -------------------------------- ### List Models via CLI, cURL, and Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/models Lists available machine learning models. Supports filtering by project ID or tag. The Python client requires an API key and initializes a ModelsClient. The cURL example demonstrates an API GET request. ```bash gradient models list ``` ```curl curl -X GET 'https://api.paperspace.io/mlModels/getModelList/' \ -H 'x-api-key: d44808a2785d6a...' ``` ```python from gradient import ModelsClient api_key='d44808a2785d6a...' models_client = ModelsClient(api_key) print(models_client.list()) ``` -------------------------------- ### List startup scripts with specific fields using pspace CLI Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script Lists all startup scripts within your team, allowing you to specify which fields to display. This is useful for getting a summarized view of your scripts. Dependencies include the 'pspace' CLI tool. ```bash pspace startup-script list -F name -F dtCreated ``` -------------------------------- ### List Available Machine Types using CLI, cURL, and Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/clusters This snippet shows how to list available machine types for clusters via the Gradient CLI, cURL, and Python. It includes the necessary commands and client setup for each method. The Python example utilizes the MachineTypesClient. ```bash gradient clusters machineTypes list ``` ```bash curl -X GET 'https://api.paperspace.io/vmTypes/getVmTypesByClusters' \ -H 'x-api-key: d44808a2785d6a...' ``` ```python from gradient import MachineTypesClient api_key = 'd44808a2785d6a...' machineTypes_client = MachineTypesClient(api_key) print(machineTypes_client.list()) ``` -------------------------------- ### pspace startup-script create Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script Create a startup script. This script can be configured to run on first boot or on every boot of a machine. ```APIDOC ## pspace startup-script create ### Description Create a startup script. ### Method POST ### Endpoint /pspace/startup-script ### Parameters #### Query Parameters - **-F, --fields** (string, optional) - The fields to include in the response. #### Request Body - **-n, --name** (string, required) - The name of the startup script - **--script** (string, required) - The script to run - **--run-once** (boolean, optional) - Whether to run once or on every boot ### Request Example ```json { "name": "my-startup-script", "script": "echo \"Hello, World!\" > /tmp/hello.txt", "runOnce": true } ``` ### Response #### Success Response (200) - **id** (string) - The ID of the created startup script - **name** (string) - The name of the startup script - **runOnce** (boolean) - Whether the script runs once or on every boot - **dtCreated** (string) - The creation date of the script #### Response Example ```json { "id": "script-12345", "name": "my-startup-script", "runOnce": true, "dtCreated": "2024-02-15T10:00:00Z" } ``` ``` -------------------------------- ### List startup scripts Source: https://docs.digitalocean.com/reference/paperspace/api-reference Fetches a list of all startup scripts, with options for pagination and sorting. ```APIDOC ## List startup scripts ### Description Fetches a list of startup scripts. ### Method GET ### Endpoint /v1/startup-scripts ### Parameters #### Query Parameters - **after** (string) - Optional - Fetch the next page of results after this cursor. - **limit** (integer) - Optional - The number of items to fetch after this page. (1 to 120) - **orderBy** (string) - Optional - Default: "dtCreated" - Order results by one of these fields. Enum: "dtCreated" "name" - **order** (string) - Optional - Default: "desc" - The order to sort the results by. Enum: "asc" "desc" - **name** (string) - Optional ### Response #### Success Response (200) - **hasMore** (boolean) - Description - **nextPage** (string) - Description - **items** (array) - Description - **id** (string) - Description - **name** (string) - Description - **description** (string) - Description - **isEnabled** (boolean) - Description - **isRunOnce** (boolean) - Description - **assignedMachineIds** (array) - Description - **dtCreated** (string) - Description - **dtDeleted** (string) - Description #### Response Example ```json { "hasMore": true, "nextPage": "string", "items": [ { "id": "string", "name": "string", "description": "string", "isEnabled": true, "isRunOnce": true, "assignedMachineIds": [ "string" ], "dtCreated": "2019-08-24T14:15:22Z", "dtDeleted": "2019-08-24T14:15:22Z" } ] } ``` ``` -------------------------------- ### Get Gradient Notebook Details via CLI, cURL, and Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Provides methods to retrieve details of a specific Gradient notebook. It includes examples for CLI commands, cURL requests, and Python code. Requires the notebook's ID as input and returns detailed information about the notebook's configuration and status. ```bash gradient notebooks details \ --id "np8pihaie5" ``` ```curl curl -X GET 'https://api.paperspace.io/notebooks/getNotebook' \ -H 'x-api-key: d44808a2785d6a...' \ -H 'Content-Type: application/json' \ --data-raw '{ "notebookId": "np8pihaie5" }' ``` ```python from gradient import NotebooksClient api_key='d44808a2785d6a...' notebooks_client = NotebooksClient(api_key) print(notebooks_client.get( id='np8pihaie5' )) ``` -------------------------------- ### Initialize New Paperspace App Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/init Creates a new Paperspace app in the current directory using the default template. This is the most basic usage of the 'init' command. ```bash $ pspace init ``` -------------------------------- ### Start Machine Source: https://docs.digitalocean.com/reference/paperspace/core/commands/machines Starts an individual machine. If the machine is already started, this action has no effect. If the machine is off, it will be booted up. This action can only be performed by the owner of the machine. ```APIDOC ## POST /machines/:machineId/start ### Description Starts an individual machine. If the machine is already started, this action is a no-op. If the machine is off, it is booted up. This action can only be performed by the user who owns the machine. ### Method POST ### Endpoint /machines/:machineId/start #### Path Parameters - **machineId** (string) - Required - Id of the machine to start ### Request Example ```json { "apiKey": "edc20a51d9b2145...", "machineId": "psfj3c701" } ``` ### Response #### Success Response (200) - **machine** (object) - The updated machine JSON object #### Response Example ```json { "id": "psazmnxdy", "name": "My Machine 1", "os": null, "ram": null, "cpus": 1, "gpu": null, "storageTotal": null, "storageUsed": null, "machineType": "P4000", "usageRate": "P4000 hourly", "shutdownTimeoutInHours": 168, "shutdownTimeoutForces": false, "performAutoSnapshot": false, "autoSnapshotFrequency": null, "autoSnapshotSaveCount": null, "dynamicPublicIp": false, "agentType": "LinuxHeadless", "dtCreated": "2022-03-14T15:09:51.974Z", "state": "provisioning", "updatesPending": false, "networkId": null, "privateIpAddress": null, "publicIpAddress": null, "region": null, "scriptId": null, "dtLastRun": null, "restorePointSnapshotId": null, "restorePointFrequency": null } ``` ``` -------------------------------- ### Create Gradient Autocomplete Script Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Creates a separate script file (`~/paperspace_complete.sh`) containing the Gradient CLI autocomplete configuration. This script can then be sourced in your shell's configuration files, providing a cleaner way to manage autocompletion. ```bash (_GRADIENT_COMPLETE=source gradient) > ~/paperspace_complete.sh . ~/paperspace_complete.sh ``` -------------------------------- ### Upgrade pspace using install script Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/upgrade This command upgrades the 'pspace' tool when it was originally installed using the provided install script. It directly calls the upgrade functionality within the 'pspace' tool. ```shell pspace upgrade ``` -------------------------------- ### Paperspace CLI Basic Usage Source: https://docs.digitalocean.com/reference/paperspace/pspace/install This shows the basic command structure for the Paperspace CLI. The `pspace` command is followed by a specific command and optional flags to interact with Paperspace services. ```shell pspace [command] [flags] ``` -------------------------------- ### Set Gradient API Key Source: https://docs.digitalocean.com/reference/paperspace/gradient/install Sets the active API key for authenticating with Gradient services. Replace `XXXXXXXXXXXXXXXXXXX` with your actual API key obtained from Paperspace. This command configures the CLI to use the specified key for subsequent operations. ```bash gradient apiKey XXXXXXXXXXXXXXXXXXX ``` -------------------------------- ### GET /notebooks/getNotebook (for metrics) Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Retrieves notebook details, primarily used to get `dtStarted` for subsequent metric queries. ```APIDOC ## GET /notebooks/getNotebook (for metrics) ### Description Retrieves notebook details. This endpoint is often used as a prerequisite to fetch notebook metrics, as it provides the `dtStarted` timestamp necessary for the metrics query. ### Method GET ### Endpoint https://api.paperspace.io/notebooks/getNotebook ### Parameters #### Request Body - **notebookId** (string) - Required - The ID of the notebook. ### Request Example ```json { "notebookId": "n4lwwzwf6h" } ``` ### Response #### Success Response (200) - **dtStarted** (string) - The timestamp when the notebook started. - Other notebook-related fields. #### Response Example ```json { "notebookId": "n4lwwzwf6h", "dtStarted": "2022-03-22T04:31:59.000Z", "state": "Running", ... } ``` ``` -------------------------------- ### POST /notebooks/v2/forkNotebook Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/notebooks Forks an existing notebook, creating a copy. ```APIDOC ## POST /notebooks/v2/forkNotebook ### Description Forks an existing notebook, creating a copy. ### Method POST ### Endpoint https://api.paperspace.io/notebooks/v2/forkNotebook ### Parameters #### Request Body - **notebookId** (string) - Required - The ID of the notebook to fork. - **projectId** (string) - Required - The ID of the project where the forked notebook will be created. ### Request Example ```json { "notebookId": "n4lwwdelz2", "projectId": "prjpkflqz" } ``` ### Response #### Success Response (200) - **name** (string) - The name of the new forked notebook. - **handle** (string) - The unique identifier for the forked notebook. - **projectHandle** (string) - The identifier of the project the notebook belongs to. - **state** (string) - The current state of the notebook (e.g., 'Stopped'). #### Response Example ```json { "name": "New Notebook - Fork", "handle": "n4wzypwu02", "jobHandle": "jhivt2v46bb1ijiw", "project": "phoebe-dropout", "projectHandle": "prjpkflqz", "state": "Stopped", "container": "paperspace/nb-pytorch:22.02-py3", "cluster": "gradient01-ny2", "clusterId": "clg07azjl" } ``` ``` -------------------------------- ### pspace startup-script unassign Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script Unassign a startup script from a machine. ```APIDOC ## pspace startup-script unassign ### Description Unassign a startup script from a machine. ### Method POST ### Endpoint /pspace/startup-script/{id}/unassign ### Parameters #### Path Parameters - **id** (string, required) - The ID of the startup script to unassign #### Query Parameters - **-F, --fields** (string, optional) - The fields to include in the response. #### Request Body - **--machine-id** (string, required) - The ID of the machine to unassign the startup script from ### Request Example ```json { "machineId": "machine-abcde" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of unassignment #### Response Example ```json { "message": "Startup script script-12345 unassigned from machine machine-abcde successfully." } ``` ``` -------------------------------- ### Get Model (GET) Source: https://docs.digitalocean.com/reference/paperspace/api-reference Retrieves details for a specific model by its ID. Requires the model's ID as a path parameter. Returns the full model object including its metadata and creation/modification timestamps. ```json { "id": "string", "name": "string", "dtCreated": "2019-08-24T14:15:22Z", "dtModified": "2019-08-24T14:15:22Z", "isPublic": true, "teamId": "string", "storageProviderId": "string", "description": "string", "projectId": "string" } ``` -------------------------------- ### Assign a startup script to a machine using pspace CLI Source: https://docs.digitalocean.com/reference/paperspace/pspace/commands/startup-script Assigns a specified startup script to a particular machine using their respective IDs. This ensures the script will be executed on the machine. Dependencies include the 'pspace' CLI tool. ```bash pspace startup-script assign --machine-id ``` -------------------------------- ### Get Machine Utilization Data (cURL) Source: https://docs.digitalocean.com/reference/paperspace/core/commands/machines Fetches machine utilization data through a GET request to the Paperspace API. Parameters include the machine ID and the billing month. An API key is required for authentication. ```bash curl -X GET 'https://api.paperspace.io/machines/getUtilization?machineId=psec02yp2&billingMonth=2022-03' \ -H 'X-Api-Key: edc20a51d9b2145...' ``` -------------------------------- ### Get Storage Provider Details using Python Source: https://docs.digitalocean.com/reference/paperspace/gradient/commands/storage-providers Uses the Gradient client library in Python to retrieve the details of a storage provider. The `get` method requires the `storage_provider_id` and an API key for authentication. ```python from gradient import StorageProvidersClient api_key='d44808a2785d6a...' storage_provider_client = StorageProvidersClient(api_key) print(storage_provider_client.get( storage_provider_id='splia57f7o5jqke' )) ```