oiyai / docs
Developer tools

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
export OIY_API_KEY="your-console-api-key"

The package is not yet published to PyPI. 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. HTTPS is required except on loopback for development.

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

MethodPurpose
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

OiyError reports API and connection failures. The client does not make uncertain mutations safe to replay with a fresh key: inspect state and retain the original key for identical retries.

On this page