Python SDK
Install from source and protect a running task from idle sleep.
Install
From a preview source checkout:
python -m pip install ./packages/oiy-ai-sdk
oiy --versionThese instructions target SDK 0.3.0, prepared as a local preview. It has not been published to PyPI or uploaded as the new hosted download. Use the source checkout or an explicitly supplied 0.3.0 wheel; older hosted artifacts may expose different interfaces. Supply the key through a secret store or local environment. The API base defaults to the existing control-plane origin; set OIY_API_URL to override it. Use a bare HTTPS origin with no path, credentials, query or fragment; HTTP is accepted only on loopback for development. Account keys use the oiy_ format. The client ignores ambient HTTP proxy settings.
Check your setup
oiy doctorThis reads only the public catalog and authenticated identity endpoint. It does not allocate or wake compute. A missing key can still permit catalog discovery, but returns exit code 1 for incomplete account access. A successful check does not reserve GPU capacity.
Inspect resources
from oiy_ai import Client
client = Client()
account = client.account()
services = client.services()
volumes = client.volumes()Avoid printing account data or keys into shared logs.
Protect work
from oiy_ai import Client
with Client().task("SERVICE_ID", name="Model training"):
train() # Replace with your own workload.The context registers before the task, heartbeats while it runs, and releases on normal completion or an exception. Inside a managed instance the injected service ID and scoped activity credentials can be used with Client().task(name="Model training").
If the process is killed or the final release cannot reach the API, inspect and release stale activity only after confirming the task ended.
Resource methods
| Method | Purpose |
|---|---|
rename_service(id, name, expected_name, idempotency_key=...) | Change the display name without restarting |
service_draft(id) / template_from_service(id, revision, ...) | Prepare duplicate settings or capture a template |
metrics(id, minutes=60) | Read monitoring without changing service activity |
billing(view="summary", from_date=..., to_date=...) | Full-window summary or cursor-paginated ledger |
registries() / save_registry(...) / delete_registry(...) | Account-owned image-pull access |
account() | Account snapshot |
services() | Services from the account snapshot |
create_service(spec, idempotency_key=...) | Create a service |
action(id, action, resources=None, idempotency_key=...) | Start, stop, restart, resize, or delete |
volumes() / volume(id) | List or inspect volumes |
create_volume(spec, idempotency_key=...) | Independent storage |
update_volume(id, revision, name=..., size_gb=..., idempotency_key=...) | Rename or expand |
delete_volume(id, idempotency_key=...) | Delete detached independent storage |
Recover from an uncertain result
OiyError exposes code, request_id, and outcome_unknown. The client retains a mutation request ID even when it generated one for you. If the outcome is unknown, inspect the resource before resubmitting the identical request with that ID. A changed intent needs a new ID. Never use a credential as an ID.
The client does not automatically retry. Redirects are rejected, public catalog calls never include credentials, and errors omit sensitive upstream response bodies. Its 2 MiB JSON transport limit does not override the control API’s smaller request-body limit. Timeout values describe socket operations, not a guaranteed total deadline for an arbitrarily slow response.