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

# Async Client

> AsyncDreep mirrors the sync client, on asyncio or trio.

`AsyncDreep` has the same methods, arguments and return types as `Dreep`. Every call is
awaited, and `list_all_media()` becomes an async iterator.

```python theme={null}
from pathlib import Path
from dreep import AsyncDreep

async with AsyncDreep() as client:
    asset = await client.upload(Path("hero.jpg"), folder="marketing")

    async for item in client.list_all_media(folder="marketing"):
        print(item.filename, item.size_bytes)
```

It runs on asyncio and on [trio](https://trio.readthedocs.io/), because the underlying
`httpx` client does.

## URL building stays synchronous

[`url()`](https://docs.dreep.cloud/python-sdk/media/build-url) and
[`signed_url()`](https://docs.dreep.cloud/python-sdk/media/signed-url) make no network call, so they are not
coroutines on either client:

```python theme={null}
link = client.url(asset, {"width": 400})          # no await
link = client.signed_url(asset, expires_in=3600)  # no await
```

## Closing

Use the client as an async context manager, or close it yourself:

```python theme={null}
client = AsyncDreep()
try:
    await client.get_usage()
finally:
    await client.aclose()
```

If you pass your own `httpx.AsyncClient`, you keep ownership of it and the SDK leaves it
open:

```python theme={null}
import httpx

async with httpx.AsyncClient(proxy="http://proxy.internal:8080") as http:
    client = AsyncDreep(http_client=http)
    await client.get_usage()
```

## Concurrency

Methods are safe to run concurrently on one client — connections are pooled:

```python theme={null}
import asyncio

async with AsyncDreep() as client:
    assets = await asyncio.gather(
        client.upload(Path("one.jpg")),
        client.upload(Path("two.jpg")),
        client.upload(Path("three.jpg")),
    )
```

Each upload counts separately against your plan, and uploads are never retried
automatically — see [Errors & Retries](https://docs.dreep.cloud/python-sdk/errors.md).


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