Skip to content

Commit a1010af

Browse files
authored
Update README.md (#645)
1 parent a4ed16c commit a1010af

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,27 @@ while paginated:
9191
paginated = False
9292
```
9393

94+
#### Async Usage
95+
96+
For async, import from `pydo.aio` instead of `pydo`. The surface is identical
97+
— same constructor, same operation groups — just `await` the calls. Use
98+
`async with` so the underlying transport closes cleanly.
99+
100+
```python
101+
import asyncio, os
102+
from pydo.aio import Client
103+
104+
async def main():
105+
async with Client(api_key=os.environ["DIGITALOCEAN_TOKEN"]) as client:
106+
resp = await client.chat.completions.create(
107+
model="llama3.3-70b-instruct",
108+
messages=[{"role": "user", "content": "Hello!"}],
109+
)
110+
print(resp)
111+
112+
asyncio.run(main())
113+
```
114+
94115
#### Retries and Backoff
95116

96117
By default the client uses the same retry policy as the [Azure SDK for Python](https://learn.microsoft.com/en-us/python/api/azure-core/azure.core.pipeline.policies.retrypolicy?view=azure-python)

0 commit comments

Comments
 (0)