Skip to main content

Python SDK for Lambda Labs Public API

Project description

Unofficial Lambda Labs Python SDK

A Python library for interacting with the Lambda Labs Public API

Getting Started

  1. Install with pip:
pip install lambdalabs-python
  1. Generate an API key

  2. Set the LAMBDALABS_API_KEY environment variable:

export LAMBDALABS_API_KEY="secret_xxx"
  1. Example for orderung a server:
import os
from lambdalabs import LambdaLabsClient

API_KEY = os.environ['LAMBDALABS_API_KEY']

lambdalabs = LambdaLabsClient(API_KEY)

# Get all instance types
instance_types = lambdalabs.instance_types.get()

# Filter out instance types that are available
available_instance_types = [instance_type for instance_type in instance_types if len(instance_type.regions_with_capacity_available) > 0]
# Sort instance types by price and get the instance type with the lowest price
available_instance_types = sorted(available_instance_types, key=lambda instance_type: instance_type.price_cents_per_hour)

# Print the available instance types sorted by the lowest price
for instance_type in available_instance_types:
    print(instance_type)

# Launch the selected instance, change the parameters accordingly:
# region_name = 'us-tx-1'
# instance_type_name = 'gpu_8x_a100_80gb_sxm4'
# ssh_key_names = ['my-ssh-key']
# file_system_names = []
# quantity = 1
# name = 'lambda-test-1'
lambdalabs.instances.launch(region_name, instance_type_name, ssh_key_names, quantity, name)

Examples

Checkout the /examples directory for more examples on how to use the Python SDK.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lambdalabs-python-0.1.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lambdalabs_python-0.1.2-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file lambdalabs-python-0.1.2.tar.gz.

File metadata

  • Download URL: lambdalabs-python-0.1.2.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.1

File hashes

Hashes for lambdalabs-python-0.1.2.tar.gz
Algorithm Hash digest
SHA256 dc78f9b89fc229e0295c9aa8f7c55537221b529d0e82523bee4d7558f264a5b3
MD5 5b74ca3491a42eb8e9a2ca88c38dd286
BLAKE2b-256 44373ffb9d513c55503c3544ef4541bf825539fd16fbb2628ba4f4b3f7b74a6c

See more details on using hashes here.

File details

Details for the file lambdalabs_python-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for lambdalabs_python-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 50fda3185ae810b6f65e5eff9e0bcb8fc4a3778a518943c96b71f0f34103ea61
MD5 e42fdaa3287a4459168c820d184e0132
BLAKE2b-256 3e2f6957638a3ba17c9b3d57e103127602486549c1e07b4ca98889da6a7a566f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page