Using the Official clore-ai SDK

Note: This chapter previously covered building a custom SDK from scratch. With the release of the official clore-ai package, we recommend using it instead. The custom client approach is still documented in Clore Client Reference.


Why Use the Official SDK?

Feature

Custom CloreClient

Official clore-ai

Rate limiting

Manual time.sleep()

Built-in (1 req/sec + create_order cooldown)

Retries

Manual or tenacity

Automatic exponential backoff

Type safety

Raw dicts

Pydantic models (MarketplaceServer, Order, Wallet, etc.)

Async

Build your own

AsyncCloreAI included

CLI

None

clore search, clore deploy, clore ssh, etc.

Error handling

Generic Exception

Typed hierarchy (AuthError, RateLimitError, etc.)

Install

Copy-paste class

pip install clore-ai


Quick Migration

Before

from clore_client import CloreClient

client = CloreClient(api_key="your-key")
servers = client.get_marketplace()
cheapest = client.find_cheapest(gpu_type="RTX 4090")
order = client.create_order(server_id=cheapest["id"], image="nvidia/cuda:12.1.0-base-ubuntu22.04")
running = client.wait_for_order(order["order_id"])

After

Key differences:

  • No get_ prefixmarketplace() not get_marketplace()

  • Returns typed objectsservers[0].gpu_model not servers[0]["gpu_array"][0]

  • Filtering built-in — pass gpu=, max_price_usd= directly to marketplace()

  • Rate limiting automatic — no need for time.sleep() between calls


Advanced Patterns

Context Manager

Async Client

Structured Error Handling

Server Management (Hosts)

Spot Market

CLI One-Liners


Next Steps

Last updated

Was this helpful?