Async Usage
Using Daita Client in async Python applications.
All methods have async equivalents with an _async suffix. Use the client as an async context manager to ensure the underlying HTTP session is properly cleaned up.
python
import asyncio
from daita_client import DaitaClient
async def main():
async with DaitaClient(api_key="your_api_key") as client:
# Execute and wait
result = await client.execute_agent_async(
"my_agent",
data={"query": "summarize this"},
wait=True
)
print(result.result)
# Fire and forget, then poll
result = await client.execute_agent_async("my_agent", data={})
final = await client.wait_for_execution_async(result.execution_id, timeout=60)
print(final.result)
asyncio.run(main())#Available Async Methods
| Sync | Async |
|---|---|
execute_agent() | execute_agent_async() |
execute_workflow() | execute_workflow_async() |
get_execution() | get_execution_async() |
wait_for_execution() | wait_for_execution_async() |
cancel_execution() | cancel_execution_async() |
list_executions() | list_executions_async() |
get_latest_execution() | get_latest_execution_async() |