A client library for accessing Lambda Cloud API
Project description
Lambda Cloud API - CLI
This project is a wrapper around the Lambda Cloud API with some additional Quality-of-Life additions. The documentation of the API can be found here: https://docs-api.lambda.ai/api/cloud
Installation
uv pip install lambda-ai-cloud-api-client
Usage
- Set up an API token and environment.
In your lambda.ai account go to https://cloud.lambda.ai/api-keys/cloud-api and generate a new Cloud AI Key. Set this token as an environment variable in the terminal you've installed this project.
export LAMBDA_CLOUD_API_TOKEN=<your-token>
The project also accepts LAMBDA_CLOUD_TOKEN and LAMBDA_API_TOKEN if you prefer that naming.
Optionally you can set the api base url, LAMBDA_CLOUD_BASE_URL, the default is https://cloud.lambdalabs.com .
- Using the CLI
To save on keystrokes I've named the command lai for lambda.ai. To see all available commands use:
lai --help
Overview of features
Listing all instances
api doc: https://docs-api.lambda.ai/api/cloud#listInstances
lai ls
An overview of all your booting/running/terminating instances.
Details of a single instance
api doc: https://docs-api.lambda.ai/api/cloud#getInstance
lai get <name-or-id>
Starting an instance
api doc: https://docs-api.lambda.ai/api/cloud#launchInstance
Starting an instance with your configuration. You can choose to be exact and pass --instance-type <your-type> or use
filters that narrow to a single instance type.
lai start --instance-type gpu_1x_a10 --name my-instance --ssh-key my-ssh-key
or start the cheapest available instance with some hardware requirement.
lai start --cheapest --available --min-gpus 1 --name my-instance --ssh-key my-ssh-key
See lai start --help for all filters. They can be used all together to find the best instance type.
There's also a --dry-run option to see what would be selected.
Restart an instance / instances
api doc: https://docs-api.lambda.ai/api/cloud#restartInstance
Restart an instance, multiple arguments are allowed.
lai restart <id-or-name.
Stop an instance / instances
api doc: https://docs-api.lambda.ai/api/cloud#terminateInstance
Stop an instance / instances, multiple arguments are allowed. This terminates the instance and removes it from your inventory. You cannot restart/start terminated instances.
lai stop <id-or-name> ...
SSH into an instance
Finds an instance by id or name and then starts an ssh session to it. Handy if you want to stop copy+pasting IP addresses of your started instances. Includes mechanism to wait for the instance to become available if it has just been started.
lai ssh my-instance # or id
Waiting for IP on instance 'my-instance' (8ac73ac801a749099ed3bc2a5508000f)... retrying in 5s
Waiting for SSH on instance 'my-instance' (132.145.199.110)... retrying in 5s
Executing: ssh -o StrictHostKeyChecking=accept-new -o UserKnownHostsFile=/dev/null ubuntu@132.145.199.110
(my-instance) $
Running a command on an instance
Most of the time the workflow of using instances is:
- Start an instance
- Rsync your code to it.
- Run a command, usually with env vars.
- Rsync results back.
- Stop the instance.
If this is your general workflow you'll find the following commands useful. In the most complex case it'll give you access to spot-like instances where you only pay for the amount of time taken on a machine before it is shut down.
- Run a command on an already started instance, including waiting for booting instances.
lai run my-instance -- <command>
- Start an instance, then run the command.
lai run --cheapest --available --ssh-key my-ssh-key -- <command>
- Start an instance, rsync a volume, run the cmd and rsync a volume back.
lai run --cheapest --available --ssh-key my-ssh-key -v <my-dir-or-file>:/home/ubuntu/ -- <command> /home/ubuntu/my-file
- All of the above but delete the instance after done.
lai run --rm --cheapest --available --ssh-key my-ssh-key -v <my-dir-or-file>:/home/ubuntu/ -- <command> /home/ubuntu/my-file
Listing instance types
api doc: https://docs-api.lambda.ai/api/cloud#listInstanceTypes
List all available instance types, with filters to select for --available or --region.
lai types
Listing available boot images
api doc: https://docs-api.lambda.ai/api/cloud#listImages
List all available boot images, with filters to select --arch and --family.
lai images
Listing your saved SSH keys
api doc: https://docs-api.lambda.ai/api/cloud#listSSHKeys
List all available ssh-keys you have saved in lambda.ai
lai keys
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lambda_ai_cloud_api_client-2.3.0.tar.gz.
File metadata
- Download URL: lambda_ai_cloud_api_client-2.3.0.tar.gz
- Upload date:
- Size: 54.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e151e588e1c965bd5884c55960888574fcb19cf2cd16df82b677c9f53635a4e
|
|
| MD5 |
d1ca0a4b01f77b4a53328d00d80851a5
|
|
| BLAKE2b-256 |
217a4bac0f7b0cb9730c6f66ebcda87960fbf0c71a572c25445d6e92d2a20d63
|
Provenance
The following attestation bundles were made for lambda_ai_cloud_api_client-2.3.0.tar.gz:
Publisher:
ci.yml on alexandervaneck/lambda-ai-cloud-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lambda_ai_cloud_api_client-2.3.0.tar.gz -
Subject digest:
3e151e588e1c965bd5884c55960888574fcb19cf2cd16df82b677c9f53635a4e - Sigstore transparency entry: 729819954
- Sigstore integration time:
-
Permalink:
alexandervaneck/lambda-ai-cloud-api-client@029bd28fcc90573fe2254f136a01032ba84a57e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alexandervaneck
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@029bd28fcc90573fe2254f136a01032ba84a57e1 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lambda_ai_cloud_api_client-2.3.0-py3-none-any.whl.
File metadata
- Download URL: lambda_ai_cloud_api_client-2.3.0-py3-none-any.whl
- Upload date:
- Size: 186.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5dd7a595f3c6d52f4309007dc6991190106cf9206c11dcccc3ec364f560c7e57
|
|
| MD5 |
267d77e9823d3fad1565e21162e58e95
|
|
| BLAKE2b-256 |
3a7baf4d62890d67e8887828224eb441f555d2a4ac0192546a22e8cefd55f0a3
|
Provenance
The following attestation bundles were made for lambda_ai_cloud_api_client-2.3.0-py3-none-any.whl:
Publisher:
ci.yml on alexandervaneck/lambda-ai-cloud-api-client
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lambda_ai_cloud_api_client-2.3.0-py3-none-any.whl -
Subject digest:
5dd7a595f3c6d52f4309007dc6991190106cf9206c11dcccc3ec364f560c7e57 - Sigstore transparency entry: 729819969
- Sigstore integration time:
-
Permalink:
alexandervaneck/lambda-ai-cloud-api-client@029bd28fcc90573fe2254f136a01032ba84a57e1 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/alexandervaneck
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@029bd28fcc90573fe2254f136a01032ba84a57e1 -
Trigger Event:
push
-
Statement type: