dspy-async
Installation
SKILL.md
Run DSPy Modules Asynchronously
Guide the user through running DSPy modules with async/await for non-blocking execution in web frameworks, concurrent processing, and high-throughput applications.
What is async in DSPy
Every DSPy module supports async execution via aforward() and acall(). These return awaitable coroutines instead of blocking the event loop, making DSPy compatible with async web frameworks (FastAPI, Starlette, aiohttp) and enabling concurrent LM calls with asyncio.gather().
When to use async
| Use async when... | Use sync when... |
|---|---|
| Serving DSPy behind FastAPI/Starlette | Running scripts or notebooks |
| Making concurrent LM calls | Processing one input at a time |
| Building real-time APIs | Running optimization/evaluation |
| Combining with async streaming | Simple CLI tools |
| Integrating with async databases/caches | No event loop in your application |