> ## Documentation Index
> Fetch the complete documentation index at: https://docs.outerproduct.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Async usage

> Submit Calls and await results in asynchronous Python applications.

Most Python API operations work synchronously and offer an asynchronous form through `.aio`, such as `client.run()` and `client.run.aio()`.

Some methods are async only, such as  `run.calls()` and `call.children()` which should be called with `await`. Methods that stream results use `async for`, such as `volume.list()` and `client.map.aio()`.

Use the async interface if your application already uses `async` and `await`. While your code waits for OuterProduct to submit or finish a Call, Python can continue handling other work such as serving other web requests or waiting for several Calls at the same time.

```python theme={null}
import asyncio

import outerproduct as op


async def main() -> None:
    run: op.Run[int] | op.Call[int] = await client.run.aio(
        fn=sum_batch,
        args=([1, 2, 3],),
        image=image,
    )
    result: int = await run.wait.aio()
    print(result)  # 6


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

`await client.run.aio()` returns a handle after submission. `await run.wait.aio()` waits for the result.

See [Runs, calls, and attempts](https://docs.outerproduct.com/runs-calls-attempts.md#inspecting-calls-and-attempts) for `run.calls()` and `call.children()`, and [Volumes](https://docs.outerproduct.com/volumes.md#reading-and-writing-data) for `volume.list()`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.