python

python sdk

https://pypi.org/project/ix-sdk/

asyncio all the way down. the generated classes, methods, exceptions and docstrings come from the same rust contract as the other sdks.

the package is ix-sdk (import ix_sdk), python 3.13 or newer. it ships py.typed and generated .pyi stubs, so pyright and mypy see the same methods and records the native module exports.

boot a machine

set IX_TOKEN first, or run ix login. Client() reads that token and the normal ix config file.

region is optional: an omitted one uses IX_REGION, then us-west-1.

import asyncio

import ix_sdk


async def main() -> None:
    client = ix_sdk.Client()
    # no target: a new machine boots the base template.
    machine = await client.machines().create(ix_sdk.CreateMachineOptions(name="sdk-example"))
    try:
        result = await machine.exec_checked(["uname", "-a"])
        print(result.stdout.strip())
    finally:
        await machine.delete()


if __name__ == "__main__":
    asyncio.run(main())

machine.write_file(path, text) and machine.read_file(path) move text files. machine.snapshot() captures the machine. machine.wait_snapshot_ready(snapshot_id, timeout_ms) waits for the Rust-owned readiness state machine before a restore. streams use async for, and generated errors are normal exception subclasses such as Unauthorized, RateLimited, and CommandFailed.

records are typed Python objects with documented read-only properties and a readable repr, and every record is dict-like: dict(machine), {**machine}, and machine["status"] all work. the sdk does not depend on pandas, but a list of records is already a frame:

frame = pandas.DataFrame(await client.machines().list())