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.6.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.6.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.6.0-cp310-abi3-macosx_11_0_arm64.whl (2.7 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

basilica_sdk-0.6.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.6.0.tar.gz.

File metadata

  • Download URL: basilica_sdk-0.6.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.6.0.tar.gz
Algorithm Hash digest
SHA256 4091668221ee550e0d683accb4cd51ee709c7b733849b6d6741f6e782ec74454
MD5 3b6e831aa5e29af45ee8fcb39f556080
BLAKE2b-256 b9191d099b78a8db6b86cc3cfb20efbc716fbbab1724d192a41dcbc0cc5e0211

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.6.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.6.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.6.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a584c9d32fe043412d036385383c0cea7c1d52a896f485451d28ce63737a7645
MD5 10e2644cf2b5fa0f42cd4741fd746a15
BLAKE2b-256 8721d69856bf3b4c36329c1ca42f6e053f16cb16ff8a878286009323f266bc09

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.6.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.6.0-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.6.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30ee9ea575655a9f570fa1e3419ff6d1ed66ef173dbb0336c12635b311436e3b
MD5 ab117851d916578d52ad8103d54572b2
BLAKE2b-256 588223a17eb0fb421850ca053de25e9bb05ed285ad0c9ecf59d8348cb938292a

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.6.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.6.0-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for basilica_sdk-0.6.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 15b0f2a12ef42f04622d522760ffde901448ec78b1a075ed7f71254f5172612a
MD5 23c9dd7599c3b1062d63c7b9b1b92b8f
BLAKE2b-256 0e60315e3e0c4e4e71f3432f473dba0d422c6fa62941287a9bd89249cb7541c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for basilica_sdk-0.6.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