Official Mirelo API SDK
Project description
mirelo
Official Python SDK for the Mirelo API v2.
Supports both synchronous and async usage via httpx.
Installation
pip install mirelo
Quick start — sync
from mirelo import MireloClient, Video, MireloError
with MireloClient("sk-your-key") as client:
# From a public URL — no upload required
video = Video.from_url("https://example.com/clip.mp4")
# From raw bytes — e.g. file you read yourself
# with open("clip.mp4", "rb") as f:
# video = Video.from_bytes(f.read(), content_type="video/mp4")
req = client.video_to_sfx(video, duration_ms=5000)
try:
# Check cost first
cost = req.preflight()
print(f"{cost.credits} credits, ~{cost.estimated_ms}ms")
# Submit a background job (recommended)
job = req.submit_job()
# Single status check
status = job.status()
print(status.status) # "processing" | "succeeded" | "errored"
# Or poll until done
result = job.wait(poll_interval_ms=1000)
print(result.result_urls)
except MireloError as e:
print(f"{e.code} ({e.http_status}): {e.message}")
Quick start — async
import asyncio
from mirelo import AsyncMireloClient, Video, MireloError
async def main():
async with AsyncMireloClient("sk-your-key") as client:
video = Video.from_url("https://example.com/clip.mp4")
req = client.video_to_sfx(video, duration_ms=5000)
try:
job = await req.submit_job()
result = await job.wait()
print(result.result_urls)
except MireloError as e:
print(f"{e.code}: {e.message}")
asyncio.run(main())
Client options
MireloClient(
"sk-your-key",
host="api.mirelo.ai", # default
timeout_ms=600_000, # default: 10 minutes, applied to every request
retries=3, # default: 0 (disabled); only retries non-4xx errors
backoff_ms=1_000, # base for exponential backoff: backoff_ms * 2^attempt
)
AsyncMireloClient accepts the same options.
Methods
client.me()
Returns account information including available credits.
me = client.me()
print(me.credits_available, me.overage_enabled)
client.text_to_sfx(prompt, *, duration_ms, num_samples)
Generate sound effects from a text prompt.
req = client.text_to_sfx(
"dramatic thunderclap",
duration_ms=4_000, # optional, default 10000
num_samples=2, # optional, default 1 (max 4)
)
client.video_to_sfx(video, *, duration_ms, ...)
Generate sound effects from a video.
req = client.video_to_sfx(
video,
duration_ms=5_000, # required
start_offset_ms=1_000, # optional
num_samples=1, # optional
output="audio", # optional: "audio" (default) | "video"
)
GenerationRequest
Every generation method returns a GenerationRequest with three terminal methods:
.preflight()
Check credit cost and estimated time without consuming credits.
cost = req.preflight()
print(cost.credits, cost.estimated_ms)
.submit_job()
Submit a background job and return a Job for polling. This is the recommended approach — not affected by HTTP proxy timeouts.
job = req.submit_job()
.sync_i_accept_http_timeout_risk()
Call the synchronous endpoint, which blocks until generation completes. The deliberately alarming name is intentional: any proxy or load balancer with a timeout shorter than the generation time will cut this off. Use submit_job() instead.
result = req.sync_i_accept_http_timeout_risk()
Job / AsyncJob
job = req.submit_job()
# Single status check — returns JobProcessing | JobSucceeded | JobErrored
status = job.status()
if status.status == "processing":
print(f"{status.progress_percent}% complete")
# Poll until done (raises MireloError if errored or timed out)
result = job.wait(poll_interval_ms=500) # default 500ms
print(result.result_urls)
Video
# From a public URL — no upload required
video = Video.from_url("https://example.com/clip.mp4")
# From raw bytes — read the file yourself with any API
with open("clip.mp4", "rb") as f:
video = Video.from_bytes(f.read(), content_type="video/mp4")
When from_bytes is used, the SDK automatically:
- Calls
POST /v2/assetsto get a presigned upload URL - Uploads the bytes via
PUT - Caches the
asset_idon theVideoinstance for subsequent reuse
Error handling
All errors raise MireloError:
try:
result = req.sync_i_accept_http_timeout_risk()
except MireloError as e:
e.code # e.g. "insufficient_credits", "invalid_video", "timeout"
e.http_status # e.g. 402, 422, 408
e.message # human-readable description
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 mirelo_sdk-1.0.0.tar.gz.
File metadata
- Download URL: mirelo_sdk-1.0.0.tar.gz
- Upload date:
- Size: 9.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b26cfaa4885166ec88bcd19c3b965bc51f010b15d380c8397e9997d774b57e08
|
|
| MD5 |
7d3980c2816308c214ebf9b85cf838a1
|
|
| BLAKE2b-256 |
44be4f45db43c3affb3330ab20b4268720cafd448bc7323ce71755775f2bd635
|
File details
Details for the file mirelo_sdk-1.0.0-py3-none-any.whl.
File metadata
- Download URL: mirelo_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cae65bed36f48aed0b64a071542b6d2ff8ef6fb0edfae9d379b11a9bf07b7da1
|
|
| MD5 |
671fbbfd6ef039084c4ee40ca78d03ca
|
|
| BLAKE2b-256 |
0a51d7d90cde28b3a7422784ed18bb740b48d31fc58e3ac816e86c9a4f3bb6a7
|