supertone on PyPI. Source: supertone-inc/supertone-python.
At a glance
| Package | supertone on PyPI |
| Repo | supertone-inc/supertone-python |
| Languages | Python 3.9+ |
| Auth | Supertone(api_key=...) |
| Sync API | Yes (default) |
| Async API | *_async methods + async with |
| Streaming | iter_bytes() / aiter_bytes() |
| Auto-chunk long text | ✅ 300 chars, parallel up to 3 workers |
| Custom retries | ✅ via retry_config |
| HTTP backend | httpx |
Installation
- pip
- uv
- poetry
Set your API key
The SDK does not auto-read from the environment. Passapi_key explicitly — the convention is to read from SUPERTONE_API_KEY.
Generate speech (sync)
The recommended pattern uses a context manager so the underlying HTTP connection is closed cleanly:Generate speech (async)
Use the_async suffix and async with:
create_speech / create_speech_async, stream_speech / stream_speech_async, list_voices / list_voices_async, and so on.
Stream speech
Streaming returns an iterator (or async iterator) of audio chunks:async for chunk in response.result.aiter_bytes(). Streaming is currently supported on sona_speech_1 only.
Long text auto-chunking
create_speech, create_speech_async, stream_speech, and stream_speech_async automatically split text longer than 300 characters. create_speech runs up to 3 segments in parallel and merges the audio; stream_speech runs segments sequentially and forwards chunks to your iterator.
predict_duration does not auto-chunk — keep that input under 300 characters and sum durations manually for longer scripts.
See Long text for details and tuning.
Common operations
Type-safe enums (optional)
For type safety, the SDK exposes enum constants insupertone.models:
"en", "sona_speech_1") work too — use whichever style you prefer.
Error handling
Errors live insupertone.errors and all extend SupertoneError:
| Error class | HTTP status |
|---|---|
BadRequestErrorResponse | 400 |
UnauthorizedErrorResponse | 401 |
PaymentRequiredErrorResponse | 402 |
ForbiddenErrorResponse | 403 |
NotFoundErrorResponse | 404 |
RequestTimeoutErrorResponse | 408 |
PayloadTooLargeErrorResponse | 413 |
UnsupportedMediaTypeErrorResponse | 415 |
TooManyRequestsErrorResponse | 429 |
InternalServerErrorResponse | 500 |
httpx and don’t inherit from SupertoneError.
Configuration
Related
TypeScript SDK
The equivalent SDK for Node and Bun.
Examples
Recipes for common workflows.