Python SDK
The sangho SDK supports Python 3.8+ with
both synchronous and asynchronous (asyncio) interfaces. Compatible with Django,
FastAPI, Flask, and any standard Python project.
Installation
Synchronous usage
In synchronous mode, each call blocks until the response is received. Suited for scripts, Celery tasks, and most Django applications.
Never hardcode your API key in source code. Use os.environ[“SANGHO_SECRET_KEY”] or a library like python-dotenv for local development.
Synchronous usage
Asynchronous usage (asyncio)
For FastAPI and any async Python framework, use AsyncSangho instead of Sangho.
The interface is identical — all methods are await-able
coroutines.
Error handling
All errors inherit from sangho.error.SanghoError. Subclasses
allow each business case to be handled distinctly.
The SDK automatically retries 429 and 5xx errors with exponential backoff. Pass max_retries=0 to the constructor to disable this behavior.