Sonilo Text to Music API

Sonilo Text to Music composes an instrumental track from a text description. Set the length from 5 seconds to 6 minutes, change style at timed segments, and request several variants in one call.

Music GenerationText to Music

Provider

Sonilo

Billing

Per second

ScalingTensor price

$0.00225 per second of output, multiplied by the number of variants

Playground

Try Sonilo Text to Music

Edit the params, add your API key and run the model here. The result plays on this page when the job completes.

Input

Used for this request only and never stored. Get a key

Running a request charges your wallet: $0.00225 per second of output, multiplied by the number of variants.

Output

preview

Request summary

Endpoint
POST /api/media/generate
Model ID
sonilo/text-to-music
prompt
lofi hiphop beat with warm vinyl texture
duration
20
variants_num
1
output_format
m4a

Need chat models, job lookups or the raw response? Open the full playground.

Pricing

Sonilo Text to Music API pricing

Prices come from the live catalog. There is no subscription; each request is charged to your prepaid wallet.

ScalingTensor price

Per second

Live catalog price

$0.00225

per second of output, multiplied by the number of variants

A 30-second output costs $0.0675.

Compare all model prices

Shared balance

Add credits

Top up

One wallet and one API key for every model in the catalog. Top-ups start at $10 and are paid through Stripe.

Parameters

Input parameters

These parameters belong inside the request body's params object.

Input parameters
nametyperequireddescription
promptstringtrueText prompt describing the music to generate. Max length 2000 characters.
durationintegertrueDesired duration of the output track in seconds. Min 5, max 360.
output_formatstringfalseOptional. `m4a` (default) returns AAC‑encoded audio. `wav` returns 16‑bit PCM WAV instead, transcoded server‑side after generation. `mp3` returns 320 kbps MP3.
segmentsstringfalseOptional 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 `duration`), `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.
variants_numintegerfalseOptional. 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.

When the job completes, GET /api/media/result returns the provider’s result, including the output URL, in data.resultData.

API

Call Sonilo Text to Music from your code

Create a key in the console and call the API from your server using the apiKey header. Save data.jobId and poll GET /api/media/result?jobId=... with the same key; a code of 0 means success.

POST /api/media/generate
curl --request POST 'https://restapi.scalingtensor.com/api/media/generate' \
  --header 'apiKey: YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "model": "sonilo/text-to-music",
  "params": {
    "prompt": "lofi hiphop beat with warm vinyl texture",
    "duration": 20,
    "variants_num": 1,
    "output_format": "m4a"
  }
}'
const response = await fetch("https://restapi.scalingtensor.com/api/media/generate", {
  method: "POST",
  headers: {
    apiKey: process.env.SCALINGTENSOR_API_KEY,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    "model": "sonilo/text-to-music",
    "params": {
      "prompt": "lofi hiphop beat with warm vinyl texture",
      "duration": 20,
      "variants_num": 1,
      "output_format": "m4a"
    }
  }),
});

const result = await response.json();
if (!response.ok || result.code !== 0) {
  throw new Error(result.msg || `Request failed: ${response.status}`);
}
console.log(result.data); // Save data.jobId to query /api/media/result
import os
import requests

payload = {
    "model": "sonilo/text-to-music",
    "params": {
        "prompt": "lofi hiphop beat with warm vinyl texture",
        "duration": 20,
        "variants_num": 1,
        "output_format": "m4a",
    },
}

response = requests.post(
    "https://restapi.scalingtensor.com/api/media/generate",
    headers={"apiKey": os.environ["SCALINGTENSOR_API_KEY"]},
    json=payload,
    timeout=60,
)
result = response.json()
if result["code"] != 0:
    raise RuntimeError(result["msg"])
print(result["data"])  # Save data["jobId"] to query /api/media/result

API documentation · This page as Markdown · Markdown API reference

Related models

Sonilo Text to Music API FAQ

How much does the Sonilo Text to Music API cost?

Sonilo Text to Music costs $0.00225 per second of output, multiplied by the number of variants on ScalingTensor. A 30-second output costs $0.0675. There is no subscription; usage is charged to your prepaid wallet.

How do I call the Sonilo Text to Music API?

Send POST /api/media/generate with "model": "sonilo/text-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 Text to Music accept?

Required: prompt and duration. Optional: output_format, segments and variants_num. The parameter table on this page describes each one.

Do I need a Sonilo account to use Sonilo Text to Music?

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