Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sonilo-0.1.0.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sonilo-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

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

Hashes for sonilo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 1a099be3c70c0f65c7c2ff5e142790b65ddb72250977a18c37d6b7e5a3a55afb
MD5 55ed56c8427acf691ed2fa13c7b533b4
BLAKE2b-256 f4e17e4b23d1aa394675339a28036ab4732e35a6c0e297c16169f61f2267728d

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonilo-0.1.0.tar.gz:

Publisher: publish.yml on sonilo-ai/sonilo-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for sonilo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0a53216dd1adcf33566676effbe51ea1408d7687316453d3781515e05393c25c
MD5 441272e44e2d4b146b62c7a4428614f0
BLAKE2b-256 1b779b9f2bd0ec55f43f9881ff358fec4ede0b9bc305884c0b830be7203b3115

See more details on using hashes here.

Provenance

The following attestation bundles were made for sonilo-0.1.0-py3-none-any.whl:

Publisher: publish.yml on sonilo-ai/sonilo-python

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page