OpenCompute Python SDK
Minimal OpenAI-compat + Exchange/Ledger OCX SDK — file:// previewable, no build.
Per docs/product.md Consumer SDK + frontend/readme.md CLI first decision.
Install (local dev, no PyPI)
# From repo root — editable install, no build
pip install -e sdk/python
# Or with httpx (optional, urllib fallback for Python 3.9 click match issue)
pip install -e "sdk/python[httpx]"
Usage
from opencompute import OpenCompute
# Exchange API 8001 healthy + Edge 8002 + LiteLLM 4000 + vLLM-mock 8000
client = OpenCompute(api_key="dev-key", base_url="http://localhost:8001", edge_url="http://localhost:8002", llm_url="http://localhost:4000")
# Pledges leaderboard 3 active 210 TFLOPs
pledges = client.pledges.list()
print(pledges["total_active_pledges"], pledges["total_tflops_est"])
# Tier-aware router v1 80/20 Edge+4090 + Vickrey second-price auction winner pays second
job = client.jobs.submit(tier=2, gpu_type="4090", edge_eligible=True, task_type="image.embed", count=1)
print(job["cost_cents"], job["spec"]["auction"]) # winner 29 second 120 settled 120 vickrey True 80/20 True
# Billing ceil min1c monotonic 60c/1M Llama 3.1 8B
settlement = client.billing.settle_usage(job_id=job["id"], model="llama-3.1-8b", prompt_tokens=100, completion_tokens=50)
print(settlement["cost_cents"]) # 1c min
# Topup Stripe real credit update idempotent dedup stripe_webhook_events
topup = client.billing.topup(1000) # cents
print(topup["credit_balance_cents"])
# OpenAI-compat chat via LiteLLM gateway 4000 or Exchange proxy
chat = client.chat.completions.create(model="dev-tiny-opt-125m", messages=[{"role":"user","content":"hi"}])
print(chat["choices"][0]["message"]["content"])
# R2 presigned https://r2.opencompute.dev/artifacts/{job_id}/{filename}?expires=3600&sig=stub HMAC prod boto3
presigned = client.files.presign(job_id=job["id"], filename="model.bin")
print(presigned["presigned_url"])
# Job logs SSE bounded 60s/200 msgs + NATS opencompute.jobs.logs.{job_id}
logs = client.logs.list(job_id=job["id"], limit=100)
print(logs)
for line in client.logs.stream(job_id=job["id"], lines=3):
print(line)
# Edge scorer charging+WiFi only 10% cap cellular deny parity Python/Go
score = client.edge.score(device_id="dev-mac-1", task_type="image.embed", ram_free=5000, battery=80, is_charging=True)
print(score["eligible"], score["score"])
Architecture
src/opencompute/client.py—OpenComputemain client,PledgesClient,JobsClient,LedgerClient,BillingClient,ChatCompletionsClient,FilesClient,LogsClient,EdgeClient— humble, no framework leaking, per Clean Architecture.- Uses urllib stdlib fallback when httpx+click fails on Python 3.9
matchsyntax (same fix asdeployments/ocx_cli.py). - All endpoints live 11/11 healthy:
api-exchange:8001,api-edge:8002,litellm:4000,vllm-llama:8000,prometheus:9090,grafana:3001,nats:4222,temporal:7233,postgres:5432.
Tests
PYTHONPATH=sdk/python/src python -m pytest sdk/python/tests -v
- Unit: client init, jobs submit payload, auction winner 29 second 120 settled 120, billing ceil min1c, leaderboard 3 active 210 TFLOPs
- E2E: live 8001 /health /metrics dynamic ledger 12 pledges 3 avg second_price 120 + presign + SSE
Gold
- Small commits <200 lines, <100 for domain core per AGENTS.md §0 non-negotiable.
- Ruff clean, 11/11 healthy live, 16/16 e2e PASS, make lint PASS.
- No secrets logged, bounded timeouts 5-10s per Release It!.
Metadata
Release files for opencompute-playground 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| opencompute_playground-1.0.0.tar.gz | 10.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| opencompute_playground-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 20.0 kB
Release files / opencompute_playground-1.0.0.tar.gz
| Download URL | opencompute_playground-1.0.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fe2dac7f3c6f98e6391b447ab642d9e9fe4f709a46dcf6875ce4d989a906bf57
|
|
BLAKE2b-256 checksum How to use checksums |
edca50cebb3f12b136b79ca2ae55d50d9b3bc8c74525e7a514886e8a96ebfe70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.
Transparency logRelease files / opencompute_playground-1.0.0-py3-none-any.whl
| Download URL | opencompute_playground-1.0.0-py3-none-any.whl |
|---|---|
| Size | 9.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
07199ee55d7c410401205f4d5f8595e4652fc465ab714f1d9bf4c913beb5618c
|
|
BLAKE2b-256 checksum How to use checksums |
9100bdbf7f8a1695a3cd7ffc07c37d2133d9ba6b47e3099a4bcb80d921427f46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 30, 2026.
Transparency log