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.1.tar.gz (23.1 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.1-py3-none-any.whl (17.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: clore_ai-0.1.1.tar.gz
  • Upload date:
  • Size: 23.1 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.1.tar.gz
Algorithm Hash digest
SHA256 3db2bed6c0e692f3bb3bd70729c31a9ef506f8ee1508c8e81ec4646dcc5f5ff9
MD5 6702a1497ed7664b553502a2600c2176
BLAKE2b-256 448e9af4bb3a19d177bb659b9d7cc8f3ab75158c2b90d9f8e8d4890cc54439e6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: clore_ai-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 17.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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d19af502ee3d9d20ba7d281e32ba140fe19bc834fbceea56b4aa78285193d0e6
MD5 6f604127ff3932ad93c18b493e50fbdc
BLAKE2b-256 04c90e22f8b60062d3354a206428a3d0b0b92491ef32af07b11974fcadbd0d98

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