Skip to main content

Python SDK for the Basilica GPU rental network

Project description

Basilica Python SDK

Python bindings for the Basilica GPU rental network SDK.

Installation

From PyPI (Recommended)

pip install basilica-sdk

From Source

# Using uv (recommended)
uv pip install -e crates/basilica-sdk-python

# Or using pip with maturin
pip install maturin
cd crates/basilica-sdk-python
maturin develop

Upgrading

pip install --upgrade basilica-sdk

Quick Start

The SDK provides a simple, intuitive interface for managing GPU rentals. With automatic environment variable detection and sensible defaults, you can get started with minimal configuration.

For complete working examples, see the examples/ directory:

  • quickstart.py - Minimal example to get started quickly
  • start_rental.py - Full rental workflow with SSH setup
  • list_nodes.py - Finding available GPU resources
  • health_check.py - API health monitoring
  • ssh_utils.py - SSH credential handling examples

Features

🚀 Auto-Configuration

  • Automatically detects environment variables:
    • BASILICA_API_URL - API endpoint URL (default: https://api.basilica.ai)
    • BASILICA_API_TOKEN - Your API token for authentication
  • SSH keys auto-detected from ~/.ssh/basilica_ed25519.pub by default
  • Sensible defaults for all parameters

🔐 Enhanced SSH Handling

  • Built-in SSH utilities for credential parsing and command generation
  • Automatic SSH key detection and validation
  • Formatted SSH connection instructions with error handling

🎯 Simplified API

The SDK provides both minimal and customizable approaches to starting rentals. You can use all defaults for quick starts or specify exactly what you need. See the examples directory for detailed usage patterns and API documentation.

Examples

All code examples are available in the examples/ directory. These provide complete, runnable demonstrations of the SDK's capabilities:

Available Examples

  • quickstart.py - Get started with minimal code, demonstrating the simplest way to rent a GPU
  • start_rental.py - Complete rental workflow including custom configuration, SSH setup, and resource management
  • list_nodes.py - Query and filter available GPU nodes based on your requirements
  • health_check.py - Monitor API health and availability
  • ssh_utils.py - Work with SSH credentials, including parsing, formatting, and connection management

Each example is fully documented and can be run directly after installing the SDK. They demonstrate best practices and common patterns for working with the Basilica GPU rental network.

Development

Building from Source

# Clone the repository
git clone https://github.com/basilica/basilica.git
cd basilica/crates/basilica-sdk-python

# Create virtual environment
uv venv
source .venv/bin/activate

# Build and install
uv pip install -e .

# Run tests
pytest tests/

Environment Variables

The SDK automatically detects these environment variables:

  • BASILICA_API_URL: API endpoint (default: https://api.basilica.ai)
  • BASILICA_API_TOKEN: Your API token for authentication

Authentication

To use the SDK, you need to create an API token via the Basilica CLI:

# Create a new API token
basilica tokens create

# The command will output the token - set it as an environment variable
export BASILICA_API_TOKEN="basilica_..."

# Or pass it directly to the client
client = BasilicaClient(api_key="basilica_...")

SSH Key Configuration

By default, SDK looks for keys at ~/.ssh/basilica_ed25519.pub.

To set up SSH keys for Basilica:

# Generate a Basilica-specific ED25519 SSH key
ssh-keygen -t ed25519 -f ~/.ssh/basilica_ed25519

# The public key will be auto-detected by the SDK
ls ~/.ssh/basilica_ed25519.pub

License

MIT OR Apache-2.0

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

basilica_sdk-0.5.0.tar.gz (1.4 MB view details)

Uploaded Source

Built Distributions

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

basilica_sdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

basilica_sdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

basilica_sdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl (2.8 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file basilica_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: basilica_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 1.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for basilica_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 9e9301c0b6bd44d00054edafcafc6a89fafa65d192de274d29377fe7e732d58c
MD5 25b19efaa351af58783c5a1fca177469
BLAKE2b-256 c9203e25323c79a845e922969509eeb5900287b931cd0d963671c61a78e94e3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.5.0.tar.gz:

Publisher: release-python-sdk.yml on one-covenant/basilica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file basilica_sdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 095a0a3dbad308de519bbcae13d72b54d97eb0fbf137b1799ff0fd2a7b341517
MD5 631d85728d5104126bc8b80b8e3db738
BLAKE2b-256 cde580a2bb6e887d572db57cf0e862400cc35a38ae403e298d889a60ce5b6586

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.5.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: release-python-sdk.yml on one-covenant/basilica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file basilica_sdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 08d2d7e336952f9cb582f21fa28ebc67c329637679ae6d109e6b6822912dc848
MD5 98ad702c824de50bc82deae451ccd382
BLAKE2b-256 c1da3c4df50ddec6c31b8ff4624bb15817562f2c6f72db60653b9015484885e3

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.5.0-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: release-python-sdk.yml on one-covenant/basilica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file basilica_sdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 699f991c918aa9cea2a681dcb06fef15d0d30994b761210a722859f80a9e2072
MD5 1b5f9a50e5f016b8dca4b1fd1f5d709a
BLAKE2b-256 fa4235b984fe9829d9a36e2b70314be01933d48db474b4ccf78dbe0198335d9c

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.5.0-cp310-abi3-macosx_10_12_x86_64.whl:

Publisher: release-python-sdk.yml on one-covenant/basilica

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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