Python SDK (clore-ai)
The clore-ai package is the official Python SDK for the Clore.ai GPU marketplace. It wraps the entire REST API into a clean, type-safe interface with built-in rate limiting, automatic retries, and structured error handling — so you can focus on renting GPUs, not on HTTP plumbing.
Installation
pip install clore-aiRequirements: Python 3.9+
The package installs both the Python SDK and the clore CLI.
Authentication
Get your API key from the Clore.ai dashboard → API section.
Option 1: Environment variable (recommended)
export CLORE_API_KEY=your_api_key_hereThe SDK reads CLORE_API_KEY automatically — no code changes needed.
Option 2: CLI config file
clore config set api_key YOUR_API_KEYThis stores the key in ~/.clore/config.json.
Option 3: Pass directly in code
⚠️ Important: The Clore.ai API uses the
authheader for authentication, notAuthorization: Bearer. The SDK handles this automatically.
Quick Start
Sync Client (CloreAI)
CloreAI)Constructor
The client supports context managers for automatic cleanup:
wallets()
wallets()Get your wallet balances and deposit addresses.
Returns: List[Wallet]
name
str
Currency name (e.g. "bitcoin", "CLORE-Blockchain", "USD-Blockchain")
balance
float | None
Current balance
deposit
str | None
Deposit address
withdrawal_fee
float | None
Withdrawal fee
marketplace()
marketplace()Search the GPU marketplace with optional client-side filters.
Parameters:
gpu
str | None
None
Filter by GPU model (case-insensitive substring match)
min_gpu_count
int | None
None
Minimum number of GPUs
min_ram_gb
float | None
None
Minimum RAM in GB
max_price_usd
float | None
None
Maximum price per hour in USD
available_only
bool
True
Only return servers that are available to rent
Returns: List[MarketplaceServer]
Each MarketplaceServer provides convenient properties for the most common fields, plus access to the full nested data:
id
int
Unique server ID
gpu_model
str | None
Primary GPU description (e.g. "1x NVIDIA GeForce RTX 4090")
gpu_count
int
Number of GPUs (from gpu_array)
ram_gb
float | None
RAM in GB
price_usd
float | None
On-demand price in USD
spot_price_usd
float | None
Spot price in USD
available
bool
Whether the server is available (not rented)
location
str | None
Country code from network specs
For advanced use cases, you can access the full nested structure:
specs
ServerSpecs | None
Full hardware specs (specs.gpu, specs.ram, specs.cpu, specs.disk, specs.net, etc.)
price
ServerPrice | None
Full price object (price.usd.on_demand_usd, price.usd.spot, price.on_demand, etc.)
rented
bool | None
Whether the server is currently rented
reliability
float | None
Server reliability score
rating
ServerRating | None
Server rating (rating.avg, rating.cnt)
Note: The
marketplace()endpoint is public — it works without an API key.
my_servers()
my_servers()List servers you are providing to the Clore.ai marketplace.
Returns: List[MyServer]
id
int
Server ID
name
str | None
Server name
gpu_model
str | None
Primary GPU description
ram_gb
float | None
RAM in GB
status
str
Human-readable status: "Online", "Offline", "Disconnected", or "Not Working"
connected
bool | None
Whether the server is connected
online
bool | None
Whether the server is online
visibility
str | None
"public" or "private"
server_config(server_name)
server_config(server_name)Get the configuration of a specific server you host.
Parameters:
server_name
str
Name of the server
Returns: ServerConfig
name
str | None
Server name
gpu_model
str | None
Primary GPU description
mrl
int | None
Minimum rental length in hours
on_demand_price
float | None
First available on-demand USD price
spot_price
float | None
First available spot USD price
specs
ServerSpecs | None
Full hardware specifications
connected
bool | None
Whether the server is connected
visibility
str | None
"public" or "private"
my_orders(include_completed)
my_orders(include_completed)Get your current orders, optionally including completed/expired ones.
Parameters:
include_completed
bool
False
Include completed/expired orders
Returns: List[Order]
id
int
Unique order ID
server_id
int | None
Server ID
type
str
"on-demand" or "spot"
status
str | None
Order status
image
str | None
Docker image
currency
str | None
Payment currency
price
float | None
Order price per day
pub_cluster
str | None
Public hostname/IP for access
tcp_ports
dict | None
TCP port mappings
spot_marketplace(server_id)
spot_marketplace(server_id)View spot market offers for a specific server.
Parameters:
server_id
int
Server ID to check
Returns: SpotMarket
offers
List[SpotOffer] | None
List of spot offers (order_id, price, server_id)
server
SpotServerInfo | None
Server info (min pricing, visibility, online status)
currency_rates_in_usd
Dict[str, float] | None
Currency exchange rates in USD
create_order(...)
create_order(...)Create a new on-demand or spot order. This is how you rent a GPU.
On-demand order
Spot order
Parameters:
server_id
int
Yes
Server ID to rent
image
str
Yes
Docker image (e.g. "cloreai/ubuntu22.04-cuda12")
type
str
Yes
"on-demand" or "spot"
currency
str
Yes
Payment currency (e.g. "bitcoin")
ssh_password
str
No
SSH password (alphanumeric, max 32 chars)
ssh_key
str
No
SSH public key (max 3072 chars)
ports
dict
No
Port mappings, e.g. {"22": "tcp", "8888": "http"}
env
dict
No
Environment variables
jupyter_token
str
No
Jupyter notebook token (max 32 chars)
command
str
No
Shell command to run after container start
spot_price
float
Spot only
Price per day for spot orders
required_price
float
No
Lock in a specific price (on-demand only)
autossh_entrypoint
str
No
Use Clore.ai SSH entrypoint
Returns: Order
Rate limit:
create_orderhas a special 5-second cooldown between calls. The SDK enforces this automatically.
cancel_order(order_id, issue)
cancel_order(order_id, issue)Cancel an active order or spot offer. Optionally report an issue with the server.
Parameters:
order_id
int
Yes
Order ID to cancel
issue
str
No
Cancellation reason / issue report (max 2048 chars)
Returns: Dict[str, Any]
set_server_settings(...)
set_server_settings(...)Update settings for a server you host on the marketplace.
Parameters:
name
str
Yes
Server name
availability
bool
No
Whether the server can be rented
mrl
int
No
Minimum rental length in hours
on_demand
float
No
On-demand price per day
spot
float
No
Minimum spot price per day
Returns: Dict[str, Any]
set_spot_price(order_id, price)
set_spot_price(order_id, price)Update the price on your spot market offer.
Parameters:
order_id
int
Spot order/offer ID
price
float
New price per day
Returns: Dict[str, Any]
Note: You can only lower spot prices once every 600 seconds, and by a limited step size. The API returns
code: 6with details if you exceed these limits.
Async Client (AsyncCloreAI)
AsyncCloreAI)The AsyncCloreAI client provides the same methods as CloreAI, but all return coroutines. Use it when you need concurrent API calls or are working within an async application.
Basic usage
Concurrent operations
Run multiple API calls in parallel with asyncio.gather:
Available methods
AsyncCloreAI supports all the same methods as CloreAI:
await wallets()
Get wallet balances
await marketplace(...)
Search marketplace
await my_servers()
List your hosted servers
await server_config(name)
Get server configuration
await my_orders(...)
List your orders
await spot_marketplace(server_id)
Get spot market offers
await create_order(...)
Create a new order
await cancel_order(...)
Cancel an order
await set_server_settings(...)
Update server settings
await set_spot_price(...)
Update spot price
Error Handling
The SDK provides structured exception classes for every API error code.
Error codes
0
—
Success
1
DBError
Database error
2
InvalidInputError
Invalid input data
3
AuthError
Invalid API token
4
InvalidEndpointError
Invalid endpoint
5
RateLimitError
Rate limit exceeded
6
FieldError
Error in specific field (see error field in response)
All exception classes inherit from CloreAPIError and include:
e.code— numeric error codee.response— full API response dict (when available)
Rate Limiting
The SDK includes a built-in rate limiter that enforces Clore.ai's limits automatically:
Most endpoints
1 request/second
create_order
1 request/5 seconds
When the API returns a rate-limit error (code 5), the SDK applies exponential backoff and retries up to max_retries times (default: 3). You don't need to add time.sleep() between calls.
How it works
Before each request, the rate limiter waits until the minimum interval has elapsed.
create_ordercalls enforce an additional 5-second cooldown.On rate-limit errors, the SDK backs off exponentially: 1s → 2s → 4s → ...
After
max_retriesfailed attempts, aRateLimitErroris raised.
Customize retry behavior
Configuration
Config file
The CLI stores configuration in ~/.clore/config.json:
Resolution order
The SDK resolves the API key in this order:
api_keyargument passed to the constructorCLORE_API_KEYenvironment variableapi_keyfield in~/.clore/config.json
Environment variables
CLORE_API_KEY
API key for authentication
Next Steps
CLI Reference — Use Clore.ai from your terminal
REST API — Raw API documentation for custom integrations
On-Demand vs Spot — Understand pricing models
Available Docker Images — Pre-built images for GPU workloads
Last updated
Was this helpful?