Official Python client for the Sonilo API
Project description
sonilo
Official Python client for the Sonilo API. Python ≥ 3.9. Sync and async clients included.
Installation
pip install sonilo
Quickstart
from sonilo import Sonilo
client = Sonilo() # reads SONILO_API_KEY
track = client.text_to_music.generate(
prompt="cinematic orchestral score",
duration=60,
)
track.save("output.mp3")
print(track.title)
Video to music
track = client.video_to_music.generate(video="my_video.mp4", prompt="upbeat")
# or bytes / an open binary file, or a hosted URL:
track = client.video_to_music.generate(video_url="https://example.com/clip.mp4")
Streaming
for event in client.text_to_music.stream(prompt="lofi", duration=30):
if event["type"] == "audio_chunk":
handle(event["data"]) # bytes, as they arrive
Async
from sonilo import AsyncSonilo
async with AsyncSonilo() as client:
track = await client.text_to_music.generate(prompt="lofi", duration=30)
async for event in client.text_to_music.stream(prompt="lofi", duration=30):
...
Segments
Shape the composition with start-only contiguous segments (each ends where the next begins):
client.text_to_music.generate(
prompt="epic trailer",
duration=60,
segments=[
{"start": 0, "prompt": "soft intro", "label": "intro"},
{"start": 20, "prompt": "building tension", "label": "verse"},
{"start": 40, "prompt": "full orchestra", "label": "chorus"},
],
)
Account
client.account.services()
client.account.usage(days=7)
Errors
All errors extend SoniloError: AuthenticationError (401),
PaymentRequiredError (402), RateLimitError (429, .retry_after),
BadRequestError (400/413/422, .detail), APIError (anything else),
and GenerationError for failures mid-stream.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sonilo-0.1.0.tar.gz.
File metadata
- Download URL: sonilo-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a099be3c70c0f65c7c2ff5e142790b65ddb72250977a18c37d6b7e5a3a55afb
|
|
| MD5 |
55ed56c8427acf691ed2fa13c7b533b4
|
|
| BLAKE2b-256 |
f4e17e4b23d1aa394675339a28036ab4732e35a6c0e297c16169f61f2267728d
|
Provenance
The following attestation bundles were made for sonilo-0.1.0.tar.gz:
Publisher:
publish.yml on sonilo-ai/sonilo-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonilo-0.1.0.tar.gz -
Subject digest:
1a099be3c70c0f65c7c2ff5e142790b65ddb72250977a18c37d6b7e5a3a55afb - Sigstore transparency entry: 2135885354
- Sigstore integration time:
-
Permalink:
sonilo-ai/sonilo-python@96e3ea02bb3485de27a3d8a8a88ca16f33866b1b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sonilo-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96e3ea02bb3485de27a3d8a8a88ca16f33866b1b -
Trigger Event:
push
-
Statement type:
File details
Details for the file sonilo-0.1.0-py3-none-any.whl.
File metadata
- Download URL: sonilo-0.1.0-py3-none-any.whl
- Upload date:
- Size: 11.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a53216dd1adcf33566676effbe51ea1408d7687316453d3781515e05393c25c
|
|
| MD5 |
441272e44e2d4b146b62c7a4428614f0
|
|
| BLAKE2b-256 |
1b779b9f2bd0ec55f43f9881ff358fec4ede0b9bc305884c0b830be7203b3115
|
Provenance
The following attestation bundles were made for sonilo-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on sonilo-ai/sonilo-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sonilo-0.1.0-py3-none-any.whl -
Subject digest:
0a53216dd1adcf33566676effbe51ea1408d7687316453d3781515e05393c25c - Sigstore transparency entry: 2135885449
- Sigstore integration time:
-
Permalink:
sonilo-ai/sonilo-python@96e3ea02bb3485de27a3d8a8a88ca16f33866b1b -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sonilo-ai
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@96e3ea02bb3485de27a3d8a8a88ca16f33866b1b -
Trigger Event:
push
-
Statement type: