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

Uploaded CPython 3.10+macOS 11.0+ ARM64

basilica_sdk-0.4.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.4.0.tar.gz.

File metadata

  • Download URL: basilica_sdk-0.4.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.4.0.tar.gz
Algorithm Hash digest
SHA256 51a3cab1bc69fb7d2dd90eb08ba05fc68baf57726c2fb6b68ffeb863bc807f8e
MD5 00bb1ff045aa18cc70667ef7215f1cef
BLAKE2b-256 c8233c0516257a7517d4e2177616e05692a288cd20b68007d49e2aaa21fa41d4

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for basilica_sdk-0.4.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c440ad821ea64fcfdf94b9136c89a2b877a3523ba24d6e5d0b47afe72bd39dc6
MD5 c0158e30a34dc7c9df8ee4aec920aa1c
BLAKE2b-256 022ca68e779322ef6967fb017e3ff79848f91a5db95576e97e6843f0816eee23

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for basilica_sdk-0.4.0-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 80ecb3023d373d4658a7ac7e1033e40da146410bfce3638dc9468c9d47e8df11
MD5 1533aa45a84ea160aa1358324876b1fb
BLAKE2b-256 cfa830f09e6aca54bcd923198dd104ffb07e023d957063ea7a8bbb68b285e84f

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for basilica_sdk-0.4.0-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3f8b1f0d0556bef30cc93c36ee7169fbffd14bdac21d8793aa39ae8a17f79840
MD5 4c76b5d3fadaf3132a72a8038fed99cf
BLAKE2b-256 fe11698665095ab5eb3b634a752f8663ae3912d44f54262692cc541aae1e9d84

See more details on using hashes here.

Provenance

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