Install
pip install powergpu # Python ≥3.10, zero heavy deps
export POWERGPU_API_KEY=pg_live_…Sixty seconds of SDK
import powergpu
client = powergpu.Client() # reads POWERGPU_API_KEY
# the public price sheet — no key needed for this call
for g in client.gpus():
print(g.slug, g.price.on_demand)
# find capacity and deploy
offer = client.offers(gpu="rtx-4090", num_min=1)[0]
inst = client.instances.create(
machine_id=offer.machine_id,
template="pytorch",
disk_gb=60,
type="interruptible",
)
inst.wait("running")
print(inst.hostname, inst.price_hr)
inst.stop() # billing ends this secondDisposable GPUs, guaranteed
The pattern that saves real money: the context manager destroys the instance on exit, including when your code raises.
with client.ephemeral(gpu="a100-sxm4", template="axolotl",
volume="ckpts:/ckpts") as gpu:
gpu.exec("axolotl train qlora.yml") # streams output
gpu.download("/ckpts/adapter", "./out") # billed at $0.01/GB
# ← destroyed here, success or crash — no forgotten $2/hr instancesAsync & fleets
import asyncio, powergpu
async def frame(n: int):
async with powergpu.AsyncClient().ephemeral(
gpu="rtx-4090", template="blender",
volume="scene:/scene:ro") as gpu:
await gpu.exec(f"blender -b /scene/shot.blend -f {n}")
# 8 frames in parallel — per-second billing makes this cost the same
asyncio.run(asyncio.gather(*[frame(n) for n in range(1, 9)]))Errors & retries
- HTTP 429/5xx retry with exponential backoff (configurable, off for POST by default);
- API errors raise powergpu.APIError carrying .code and .message straight from the error table;
- business rules (low balance, machine gone) raise DeployError — catch it, top up, retry.
Typing
Fully typed (py.typed marker): editors autocomplete offers, instances and prices; mypy passes on strict. Dataclasses mirror the JSON of the REST API field for field, so the API reference doubles as the SDK reference.