Platinum Python SDK — client for hardware-isolated sandbox microVMs.
Project description
platinum-sdk (Python)
Python client for Platinum — hardware-isolated sandbox microVMs (one Cloud Hypervisor VM per sandbox, sub-second boots via a warm pool).
Not on PyPI yet. Until the first publish, install from source:
pip install -e packages/sdk-py(the import name isplatinum).
Quickstart
from platinum import Platinum
dn = Platinum(token="pt_live_...", api_url="https://api.platinum.dev")
# or: PT_TOKEN / PT_API_URL env vars
sbx = dn.sandboxes.create(template="pt-base", wait_for_running=True)
r = sbx.exec(["uname", "-a"]).check() # .check() raises on non-zero exit
print(r.stdout)
sbx.delete()
Expose a port at create time (URL comes back in the same response):
sbx = dn.sandboxes.create(
template="pt-base",
expose=[{"port": 8000, "public": True}],
wait_for_running=True,
)
print(sbx.exposed_url(8000))
Configuration
| Arg / env | Default | Meaning |
|---|---|---|
token / PT_TOKEN |
— (required) | API key pt_live_…, org-scoped bearer token |
api_url / PT_API_URL |
http://127.0.0.1:3000 |
Control-plane URL |
timeout |
60.0 |
Per-request timeout (seconds) |
Python ≥ 3.9. Synchronous only (httpx). No automatic retries — a 429 or a failed create is surfaced to you, never silently retried. Server-side use only; never ship an API key into client-side code.
Surface (at parity with the TypeScript SDK)
The two SDKs expose the same operations — enforced in CI by verify/sdk-parity.sh.
| Area | Methods |
|---|---|
| Sandboxes | sandboxes.create(...) · get · list · rename · delete |
| Lifecycle | pause · resume · fork · snapshot · archive · rename · backup · wait_running · refresh |
| Run | exec(argv) · sh(script) · run_code(code, lang) |
| Networking | expose(port) · unexpose(port) · exposed_url(port) |
| Files (vsock) | files.read · write · delete · list · stat · mkdir |
| Share (virtio-fs) | share.info · list · stat · get · put · mkdir · delete |
| Platform | templates.list() · regions.list() · health.check() · me() |
| Results | ExecResult(stdout, stderr, exit_code) with .check() |
Build images declaratively with the Template builder (parity with the TS Template):
from platinum import Platinum, Template
dn = Platinum()
image = (Template.from_python_image("3.12-slim")
.pip_install(["fastapi", "uvicorn"])
.workdir("/app"))
sbx = dn.sandboxes.create(image=image, wait_for_running=True, wait_timeout_ms=600_000)
Limits worth knowing
execis buffered, not streaming — output arrives after the command exits (default timeout 30 s viatimeout_ms).- The default
pt-basetemplate is busybox-based — no git/pip/node/httpdinside (ncandwgetare available); build a template from a real distro image when you need tooling. - Background processes are reaped when their
execcall returns. To leave a server running, daemonize it:setsid sh -c '<server loop>' >/dev/null 2>&1 < /dev/null &— seeexamples/02_expose_service.py. - Errors raise
PlatinumErrorwith.status(HTTP status;0for non-HTTP failures).
Examples
Runnable scripts in examples/:
pip install -e packages/sdk-py
PT_API_URL=… PT_TOKEN=… python packages/sdk-py/examples/01_create_exec_delete.py
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file platinum_sdk-0.1.0.tar.gz.
File metadata
- Download URL: platinum_sdk-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d21cb922321ffadea71ff9c187a5de6bb30dde8db7196230275272d8f842749d
|
|
| MD5 |
85728d7e0f10fa66405b20fda47c2bfb
|
|
| BLAKE2b-256 |
15d44fd026dad90cc61093d2e29c4081b6c6f03d2cc4b904624825dc9c0e1577
|
Provenance
The following attestation bundles were made for platinum_sdk-0.1.0.tar.gz:
Publisher:
release-sdks.yml on kortix-ai/platinum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
platinum_sdk-0.1.0.tar.gz -
Subject digest:
d21cb922321ffadea71ff9c187a5de6bb30dde8db7196230275272d8f842749d - Sigstore transparency entry: 2145511307
- Sigstore integration time:
-
Permalink:
kortix-ai/platinum@96e7741fe7475d7320cda471ddf54b5da0cd08c8 -
Branch / Tag:
refs/tags/platinum-sdk-py-v0.1.0 - Owner: https://github.com/kortix-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdks.yml@96e7741fe7475d7320cda471ddf54b5da0cd08c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file platinum_sdk-0.1.0-py3-none-any.whl.
File metadata
- Download URL: platinum_sdk-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
42de2d801eace9c4819fb1fb34c1b8237108f66516e0e1e5daf43d7c8b97e1f4
|
|
| MD5 |
e5a3aaa8023b97623ee10677a1cc7e3e
|
|
| BLAKE2b-256 |
9f1005debe833fbcd170885ff1edfaab5f015c4fdc0ba1f38c2d88713fae4327
|
Provenance
The following attestation bundles were made for platinum_sdk-0.1.0-py3-none-any.whl:
Publisher:
release-sdks.yml on kortix-ai/platinum
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
platinum_sdk-0.1.0-py3-none-any.whl -
Subject digest:
42de2d801eace9c4819fb1fb34c1b8237108f66516e0e1e5daf43d7c8b97e1f4 - Sigstore transparency entry: 2145511324
- Sigstore integration time:
-
Permalink:
kortix-ai/platinum@96e7741fe7475d7320cda471ddf54b5da0cd08c8 -
Branch / Tag:
refs/tags/platinum-sdk-py-v0.1.0 - Owner: https://github.com/kortix-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-sdks.yml@96e7741fe7475d7320cda471ddf54b5da0cd08c8 -
Trigger Event:
push
-
Statement type: