From 30dbcd98c088bf394cc264c55959b88f7a459654 Mon Sep 17 00:00:00 2001 From: SSharma-10 Date: Thu, 30 Apr 2026 18:25:55 +0530 Subject: [PATCH] Update README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index 5fdb4b4f..c51e8dee 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,27 @@ while paginated: paginated = False ``` +#### Async Usage + +For async, import from `pydo.aio` instead of `pydo`. The surface is identical +— same constructor, same operation groups — just `await` the calls. Use +`async with` so the underlying transport closes cleanly. + +```python +import asyncio, os +from pydo.aio import Client + +async def main(): + async with Client(api_key=os.environ["DIGITALOCEAN_TOKEN"]) as client: + resp = await client.chat.completions.create( + model="llama3.3-70b-instruct", + messages=[{"role": "user", "content": "Hello!"}], + ) + print(resp) + +asyncio.run(main()) +``` + #### Retries and Backoff 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)