Skip to main content

Python SDK and CLI for Clore.ai GPU marketplace

Project description

clore-ai

PyPI version Python 3.9+ License: MIT

Modern Python SDK and CLI for Clore.ai GPU marketplace.

Rent powerful GPUs for AI/ML workloads with a simple, intuitive interface. Supports both synchronous and asynchronous operations.


🚀 Features

  • Full API Coverage — All Clore.ai endpoints (marketplace, orders, servers, wallets, spot market)
  • Sync & AsyncCloreAI (sync) and AsyncCloreAI (async) clients
  • Rate Limiting — Built-in rate limiter with exponential backoff
  • Rich CLI — Beautiful terminal interface with rich tables
  • Type Safe — Full type hints and Pydantic models
  • SSH Helper — One-command SSH into your instances
  • Production Ready — Error handling, retries, configurable timeouts

📦 Installation

pip install clore-ai

From source

git clone https://gitlab.com/cloreai/clore-ai-sdk.git
cd clore-ai
pip install -e .

🔑 Authentication

Get your API key from Clore.ai dashboard.

Option 1: Environment variable (recommended)

export CLORE_API_KEY=your_api_key_here

Option 2: CLI config

clore config set api_key YOUR_API_KEY

Option 3: Pass directly

from clore_ai import CloreAI

client = CloreAI(api_key="your_key")

🐍 SDK Usage

Basic Example

from clore_ai import CloreAI

# Initialize client
client = CloreAI(api_key="your_key")

# Browse marketplace
servers = client.marketplace(gpu="RTX 4090", max_price_usd=5.0)
for server in servers:
    print(f"{server.id}: {server.gpu_model} - ${server.price_usd_per_hour}/h")

# Create order
order = client.create_order(
    server_id=123,
    image="cloreai/ubuntu22.04-cuda12",
    type="on-demand",
    currency="bitcoin",
    ports={"22": "tcp", "8888": "http"},
    ssh_password="mysecret"
)
print(f"Order created: {order.id} @ {order.pub_cluster}")

# List active orders
orders = client.my_orders()
for order in orders:
    print(f"{order.id}: {order.status} - {order.pub_cluster}")

# Cancel order
client.cancel_order(order_id=38)

Async Example

import asyncio
from clore_ai import AsyncCloreAI

async def main():
    async with AsyncCloreAI(api_key="your_key") as client:
        # Search marketplace
        servers = await client.marketplace(gpu="RTX 4090")
        
        # Create order
        order = await client.create_order(
            server_id=servers[0].id,
            image="cloreai/pytorch",
            type="spot",
            currency="bitcoin",
            spot_price=0.0001
        )
        
        print(f"Created order {order.id}")

asyncio.run(main())

Wallets

wallets = client.wallets()
for wallet in wallets:
    print(f"{wallet.currency}: {wallet.balance:.8f}")

Server Management

# Your hosted servers
my_servers = client.my_servers()

# Server configuration
config = client.server_config("MyGPU")
print(f"Availability: {config.availability}")

# Update settings
client.set_server_settings(
    name="MyGPU",
    availability=True,
    mrl=96,
    on_demand=0.0001,
    spot=0.00000113
)

Spot Market

# View spot offers
offers = client.spot_marketplace(server_id=6)

# Set your spot price
client.set_spot_price(order_id=39, price=0.000003)

🖥️ CLI Usage

Search Marketplace

# All servers
clore search

# Filter by GPU
clore search --gpu "RTX 4090" --max-price 5.0

# Sort and limit
clore search --sort price --limit 10

Manage Orders

# List active orders
clore orders

# Include completed
clore orders --completed

# Create new order
clore deploy 123 \
  --image cloreai/ubuntu22.04-cuda12 \
  --type on-demand \
  --currency bitcoin \
  --ssh-password mysecret \
  --port 22:tcp \
  --port 8888:http

# Cancel order
clore cancel 38

SSH Access

# Auto-connect to order
clore ssh 38

# Custom user
clore ssh 38 --user ubuntu

Wallets & Servers

# View balances
clore wallets

# List your servers
clore servers

# Server configuration
clore server-config "MyGPU"

Spot Market

# View spot offers
clore spot 6

# Set spot price
clore spot-price 39 0.000003

📚 API Reference

CloreAI / AsyncCloreAI

Constructor

CloreAI(
    api_key: str | None = None,
    base_url: str | None = None,
    timeout: float = 30.0,
    max_retries: int = 3
)

Methods

Method Description
wallets() Get wallet balances
marketplace(gpu?, min_gpu_count?, max_price_usd?, ...) Search marketplace
my_servers() List your hosted servers
server_config(name) Get server configuration
my_orders(include_completed?) List your orders
create_order(server_id, image, type, currency, ...) Create new order
cancel_order(order_id, issue?) Cancel order
spot_marketplace(server_id) Get spot market offers
set_spot_price(order_id, price) Update spot price
set_server_settings(name, availability?, mrl?, ...) Update server settings

🔒 Error Handling

from clore_ai import CloreAI
from clore_ai.exceptions import (
    CloreAPIError,
    RateLimitError,
    AuthError,
    InvalidInputError
)

try:
    client = CloreAI(api_key="invalid")
    client.wallets()
except AuthError:
    print("Invalid API key")
except RateLimitError:
    print("Rate limited - retry with backoff")
except CloreAPIError as e:
    print(f"API error: {e} (code {e.code})")

Error Codes

Code Exception Description
0 Success
1 DBError Database error
2 InvalidInputError Invalid input
3 AuthError Authentication failed
4 InvalidEndpointError Invalid endpoint
5 RateLimitError Rate limit exceeded
6 FieldError Error in specific field

🛠️ Development

Setup

git clone https://gitlab.com/cloreai/clore-ai-sdk.git
cd clore-ai
pip install -e ".[dev]"

Run Tests

pytest tests/ -v

Format Code

black src/ tests/
ruff check src/ tests/
mypy src/

📝 License

MIT License - see LICENSE for details.


🔗 Links


🤝 Contributing

Contributions welcome! Please open an issue or PR.

  1. Fork the repo
  2. Create feature branch (git checkout -b feature/amazing)
  3. Commit changes (git commit -am 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing)
  5. Open Pull Request

Made with ❤️ for the Clore.ai community

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

clore_ai-0.1.0.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

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

clore_ai-0.1.0-py3-none-any.whl (14.6 kB view details)

Uploaded Python 3

File details

Details for the file clore_ai-0.1.0.tar.gz.

File metadata

  • Download URL: clore_ai-0.1.0.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for clore_ai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b419fc1fbc28e89e3fdf7dee6de5df379c890557159e1c5e5a5fa8e4140f9cd4
MD5 129ecac687412d6af48f39645f3782f1
BLAKE2b-256 4338407c6b69e2adf22fbd8942d9b104ac6d79950cf09493d0631070d24cd213

See more details on using hashes here.

File details

Details for the file clore_ai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: clore_ai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for clore_ai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc1988e723ea05eb7d4cb62efa58acda6badf714666e440d5f633c6352afa8b
MD5 51e00c0ea726ea12d1047845c9f17c00
BLAKE2b-256 0d3a836a9aec34827fb71ae04332451da758446093936935d3bbf611e94c0941

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