Skip to content

Cloud API#

With the Cloud API, you can:

Note

Requests to the Cloud API are generally limited to 1 request per second.

Requests to the /instance-operations/launch endpoint are limited to 1 request every 10 seconds.

Launching instances#

You can launch an instance from the command line using the Cloud API:

  1. Generate an API key.
  2. Create a file named request.json that contains the necessary payload. For example:

    {
      "region_name": "us-east-1",
      "instance_type_name": "gpu_1x_a100_sxm4",
      "ssh_key_names": [
        "SSH-KEY"
      ],
      "file_system_names": [],
      "quantity": 1
    }
    
    3. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instance-operations/launch -d @request.json -H "Content-Type: application/json" | jq .
    

Replace API-KEY with your actual API key. Don't remove the trailing colon (:).

Restarting instances#

  1. Generate an API key if you haven't already generated one.
  2. Create a file that contains the necessary payload. For example:

    {
      "instance_ids": [
        "0920582c7ff041399e34823a0be62549"
      ]
    }
    

    !!! tip

    Use the API to obtain the IDs of your instances.

  3. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instance-operations/restart -d @INSTANCE-IDS -H "Content-Type: application/json" | jq .
    

Replace API-KEY with your actual API key. Don't remove the trailing colon (:).

Replace INSTANCE-IDS with the name of the payload file you created in the previous step.

Terminating instances#

  1. Generate an API key if you haven't already generated one.
  2. Create a file that contains the necessary payload. For example:

    {
      "instance_ids": [
        "0920582c7ff041399e34823a0be62549"
      ]
    }
    

    !!! tip

    Use the API to obtain the IDs of your instances.

  3. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instance-operations/terminate -d @INSTANCE-IDS -H "Content-Type: application/json" | jq .
    
    In this command,

    • Replace API-KEY with your actual API key. Don't remove the trailing colon (:).
    • Replace INSTANCE-IDS with the name of the payload file you created in the previous step.

Listing details of running instances#

You can list your running instances from a command line using the Cloud API.

First, generate an API key. Then, run the following command:

curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instances | jq .

In this command, replace API-KEY with your actual API key. Don't remove the trailing colon (:).

Getting details of a specific instance#

You can retrieve the details of an instance from a command line using the Cloud API.

First, generate an API key. Then, run the following command:

curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instances/INSTANCE-ID | jq .

In this command,

  • Replace API-KEY with your actual API key. Don't remove the trailing colon (:).
  • Replace INSTANCE-ID with the ID of the instance you want details about.

Listing instances types offered by Lambda GPU Cloud#

You can list the instances types offered by Lambda GPU Cloud by first generating an API key, then running the following command:

curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/instance-types | jq .

Replace API-KEY with your actual API key. Don’t remove the trailing colon (:).

Managing SSH keys#

You can use the Cloud API to:

Warning

Following these instructions won't add the SSH key to existing instances.

To add SSH keys to existing instances, read our FAQ on using more than one SSH key.

Note

You can add up to 1,024 SSH keys to your account.

Add an existing SSH key to your account#

To add an existing SSH key to your account:

  1. Generate an API key if you don't have one already.
  2. Create a file named ssh-key.json that contains the necessary payload. For example:

    {
      "name": "my-new-key",
      "public_key": "ssh-ed25519 KEY COMMENT"
    }
    
    3. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/ssh-keys -d @ssh-key.json -H "Content-Type: application/json" | jq .
    

In this command, replace API-KEY with your actual API key. Don't remove the trailing colon (:).

Generate a new SSH key pair#

To generate a new SSH key pair:

  1. Generate an API key if you don’t have one already.
  2. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/ssh-keys -d '{ "name": "my-generated-key" }' -H "Content-Type: application/json" | jq -r '.data.private_key' > my-generated-private-key.pem
    

    In this command, replace API-KEY with your actual API key. Don't remove the trailing colon (:). This command saves the private key for your SSH key pair as my-generated-private-key.pem.

  3. Run chmod 400 my-generated-private-key.pem to set the correct file permissions for your private key.

List the SSH keys saved in your account#

To list the SSH keys saved in your account, generate an API key if you don’t already have one. Then, run the following command:

curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/ssh-keys | jq .

In this command, replace API-KEY with your actual API key. Don’t remove the trailing colon (:).

Delete an SSH key from your account#

To delete an SSH key from your account, generate an API key if you don’t already have one. Then, run the following command:

curl -u API-KEY: -X DELETE https://cloud.lambdalabs.com/api/v1/ssh-keys/SSH-KEY-ID

In this command,

  • Replace API-KEY with your actual API key. Don't remove the trailing colon (:).
  • Replace SSH-KEY-ID with the ID of the SSH key you want to delete.

Listing filesystems#

To list your persistent storage filesystems using the Cloud API:

  1. Generate an API key if you don’t already have an API key.
  2. Run the following command:

    curl -u API-KEY: https://cloud.lambdalabs.com/api/v1/file-systems | jq .
    

In this command, replace API-KEY with your actual API key. Don’t remove the trailing colon (:).