# Sonilo Video to Music API

> Sonilo Video to Music composes an original soundtrack for a video. It follows the footage's pacing and mood on its own, and optional prompts, timed segments and speech preservation let you steer the result.

- Model ID: `sonilo/video-to-music`
- Provider: Sonilo
- Tasks: Music Generation, Video to Music
- Price: $0.009 per second of source video. A 60-second video costs $0.54.
- Web page: https://scalingtensor.com/models/sonilo/video-to-music

## How to call it

Authenticate with the `apiKey` request header. Submit a job, then poll for the result:

1. `POST https://restapi.scalingtensor.com/api/media/generate` with JSON `{ "model": "<model ID>", "params": { ... } }`. The response `data.jobId` identifies the job.
2. `GET https://restapi.scalingtensor.com/api/media/result?jobId=<jobId>` until the status is `completed` or `failed`.
3. A response `code` of 0 means success; otherwise read `msg`.

```bash
curl --request POST 'https://restapi.scalingtensor.com/api/media/generate' \
  --header 'apiKey: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "model": "sonilo/video-to-music",
  "params": {
    "prompt": "cinematic",
    "segments": [
      {
        "start": 0,
        "prompt": "quiet"
      }
    ],
    "video_url": "https://example.com/your-video.mp4",
    "preserve_speech": true
  }
}'
```

## Input parameters

Parameters go inside the `params` object.

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `video_url` | string | conditional | URL to a video file. Provide either video or video_url, not both. Must be a public http:// or https:// URL; private/internal addresses are rejected. Max file size: default 300MB. Max duration: 6 minutes. |
| `output_format` | string | optional | Optional. m4a (default) returns AAC‑encoded audio. wav returns 16‑bit PCM WAV instead, transcoded server‑side after generation — applies to both audio and, when preserve_speech is used, the mux track (the isolated vocals stem is unaffected). mp3 returns 320 kbps MP3. |
| `prompt` | string | optional | Optional text prompt to guide music generation, up to 2000 characters. For best results, omit this and let the model generate based on video content. |
| `segments` | string | optional | Optional JSON array of timed segment prompts; the music changes style at each boundary. Each item has start (seconds; the first must be 0, starts strictly increasing and at least 5 seconds apart, the last at least 5 seconds before the end of the video), prompt (1‑200 characters), and an optional label that must be exactly one of these values — any other value is rejected with a 422 error, and it defaults to none when omitted: intro, verse, pre‑chorus, chorus, bridge, break, silence, outro, none. 1‑30 items. |
| `preserve_speech` | boolean | optional | Optional boolean, default false. When true, the original speech (dialogue, narration, or voice‑over) is preserved while generating a new soundtrack. The model automatically isolates the speech from the source audio and composes music around it, preventing the original background music from influencing generation. No additional charge — billed the same as preserve_speech=false. |
| `ducking` | boolean | optional | Optional boolean, default false. Pass ducking=true to duck the generated music under the video's speech so dialogue stays intelligible, returned as an extra ducked audio track alongside the clean audio — free of charge. When preserve_speech is used the ducking rides on the isolated vocals stem; otherwise it uses the video's original audio. |
| `ducking` | boolean | optional | Optional boolean, default false. Pass ducking=true to duck the generated music under the video's speech so dialogue stays intelligible, returned as an extra ducked audio track alongside the clean audio — free of charge. When preserve_speech is used the ducking rides on the isolated vocals stem; otherwise it uses the video's original audio. |
| `variants_num` | integer | optional | Optional. How many distinct music variants to generate in one request, 1‑10 (default 1). Each variant is a separate creative direction with its own title, returned as its own entry in audio. Cost scales linearly — variants_num=3 costs three times a single‑variant request. Values above 1 are never covered by the free trial and are always billed. |
| `prompt_influence` | number | optional | Optional number, 0 to 1 (default 0.5). How strongly the generated music follows your prompt: lower values let the video lead, higher values follow the prompt more literally. Free of charge. |
| `stems` | boolean | optional | Optional boolean, default false. Pass stems=true to also split each generated track into four separated instrument tracks — drums, bass, vocals and other — returned as a stems array alongside the clean audio. It splits the generated music, never the video's own audio. The stems normally follow output_format; each stem's content_type reports what was actually delivered. Free of charge, but separation runs after generation and typically adds 2‑6 min to the wait, and gives up after 30 min — a ceiling reached by a retry or a busy queue rather than by track length, so do not size a client timeout off the duration. It never fails the task: if separation fails, audio is unaffected and the response carries stems_error — on its own, or alongside the streams that did separate. |

## FAQ

### How much does the Sonilo Video to Music API cost?

Sonilo Video to Music costs $0.009 per second of source video on ScalingTensor. A 60-second video costs $0.54. There is no subscription; usage is charged to your prepaid wallet.

### How do I call the Sonilo Video to Music API?

Send POST /api/media/generate with "model": "sonilo/video-to-music" and the parameters in a params object, using your apiKey header. The call returns a jobId. Poll GET /api/media/result?jobId=... until the status is completed, then read the output URL from the result.

### Which parameters does Sonilo Video to Music accept?

No parameter is strictly required. Optional: video_url, output_format, prompt, segments, preserve_speech, ducking, variants_num, prompt_influence and stems. The parameter table on this page describes each one.

### Do I need a Sonilo account to use Sonilo Video to Music?

No. You call Sonilo Video to Music with your ScalingTensor API key and pay from your ScalingTensor wallet. The same key works for every other model in the catalog.
