Schedule icon
GenerateMusicFromText icon
Return icon
Switch icon
Log icon
SlackIncomingWebhook icon

Sonilo Generation Health Gate

Gate Sonilo music generation jobs on their terminal status and alert Slack when a job fails or the API cannot be reached.

Categories
BusinessData

A generative media pipeline that silently swallows a failed Sonilo job looks the same as one that succeeded, until a downstream video or podcast assembly step opens an empty audio file. This blueprint submits a canary text-to-music generation on a schedule, waits for Sonilo's own terminal status, and pages Slack the moment a job fails or the API itself cannot be reached, instead of letting a bad generation flow downstream unnoticed.

How it works

  1. generate_music (io.kestra.plugin.sonilo.GenerateMusicFromText) submits music_prompt for generation_duration_seconds in output_format, which forces Sonilo's async mode and internal polling for wav/mp3. allowFailure: true means a connection or authentication failure still lets the flow continue instead of aborting.
  2. classify_generation_status (io.kestra.plugin.core.debug.Return) checks whether outputs.generate_music.status is defined; if not, UNREACHABLE. Otherwise it matches the status against Sonilo's own normalized terminal values (succeeded/completed/success for COMPLETED, failed/canceled/cancelled/error for FAILED), falling back to UNKNOWN for anything else.
  3. route_by_generation_status (io.kestra.plugin.core.flow.Switch) branches on that string: COMPLETED logs a quiet confirmation, FAILED pages Slack with the task id and prompt, UNREACHABLE pages Slack separately, and defaults logs the raw unrecognized status.
  4. log_audit_status records a status line on every run regardless of branch, so the execution history is a continuous generation-health trend.
  5. The errors block pages Slack separately if the flow itself fails outright.
  6. The sonilo_health_gate_schedule trigger polls every 6 hours with explicit input overrides, shipped disabled: true until you add a real API token.

What you get

  • A scheduled canary check for a generative media API with zero custom polling code; the task itself waits for the job.
  • A four-way status output (COMPLETED / FAILED / UNKNOWN / UNREACHABLE) you can chart or gate other flows on.
  • A Slack page naming the exact task id and status behind a failed generation.
  • A separate failure channel for the gate flow itself, plus a standing audit log line per run.

Who it's for

  • Media and content pipeline teams who generate background music or sound effects with Sonilo as one step in a larger automated production flow.
  • Platform teams who want a generation-health signal before wiring Sonilo output into a downstream video, podcast, or ad-creative assembly step.

Why orchestrate this with Kestra

Calling the Sonilo API from a script tells you one job's outcome once. This flow keeps every canary check in the execution history, turns the result into a typed output other flows can depend on, and gives you a Switch branch to grow into real remediation (retrying with a simpler prompt, falling back to a stock audio bed, opening a ticket) without rewriting the check itself.

Prerequisites

  • A Sonilo Platform API token, created at platform.sonilo.com. Sonilo has no cancel endpoint, so a killed task's remote generation can continue and can still be billed; this blueprint uses a short generation_duration_seconds to keep canary runs cheap. No self-hostable open-source Docker image exists for Sonilo, so test this blueprint directly against the live API.
  • A Slack incoming webhook for the failed and unreachable alerts.

Secrets

  • SONILO_API_TOKEN: Sonilo Platform API token, sent as Authorization: Bearer.
  • SLACK_WEBHOOK_URL: Slack incoming webhook used for the failed alert, the unreachable alert, and the flow-failure alert.
  • OSS note: if your Kestra instance reads secrets from environment variables instead of a secrets backend, set SECRET_SONILO_API_TOKEN and SECRET_SLACK_WEBHOOK_URL as base64, for example echo -n "<your-api-token>" | base64 and echo -n "<your-webhook-url>" | base64.

Quick start

  1. Add the SONILO_API_TOKEN and SLACK_WEBHOOK_URL secrets.
  2. Leave music_prompt, generation_duration_seconds, and output_format at their defaults for a cheap canary run, or set your own.
  3. Run the flow once and confirm status reads COMPLETED.
  4. Enable sonilo_health_gate_schedule.

How to extend

  • Download and inspect outputs.generate_music.audioUri (switch fetchType logic or add a follow-up task) to verify the generated file is non-empty, not just that the API reported success.
  • Track generation latency between submission and completion in a KV store to alert on slow-but-successful jobs, not only failures.
  • Fan the canary out across several prompts or output formats with a Loop task to catch format-specific regressions.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.