Skip to main content
A ready-to-run example is available here!

Concurrent Agents

Run multiple agent tasks in parallel using asyncio.gather():

Ready-to-run Example

This example is available on GitHub: examples/01_standalone_sdk/11_async.py
This example demonstrates usage of a Conversation in an async context (e.g.: From a fastapi server). The conversation is run in a background thread and a callback with results is executed in the main runloop
examples/01_standalone_sdk/11_async.py
You can run the example code as-is.
The model name should follow the LiteLLM convention: provider/model_name (e.g., anthropic/claude-sonnet-4-5-20250929, openai/gpt-4o). The LLM_API_KEY should be the API key for your chosen provider.
ChatGPT Plus/Pro subscribers: You can use LLM.subscription_login() to authenticate with your ChatGPT account and access Codex models without consuming API credits. See the LLM Subscriptions guide for details.

Next Steps