Skip to content

Generate music

Generate a song from a prompt: `custom=false` is inspiration mode (`prompt` used as an inspiration prompt), `=true` is custom mode (`prompt` used as lyrics).

All documentation
POST/v1/music/generations
  • Async task: submitting returns a task_id; poll GET /v1/music/tasks/:task_id for the result

Warning

custom controls how text fields are interpreted. With custom=true (custom mode), prompt contains lyrics, and title, style, negative_tags, auto_lyrics, and persona_id apply. With custom=false (inspiration mode), prompt contains an inspiration description and those custom-mode fields are ignored. style_weight, weirdness_constraint, audio_weight, and vocal_gender are validated and applied in both modes.

Note

This endpoint has slightly different field names: style is used, instead of tags.

cURL (Custom mode)
curl -X POST https://openrouterapi.ru/v1/music/generations \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  --data '{
    "model": "suno",
    "version": "v6",
    "custom": true,
    "instrumental": false,
    "prompt": "[Verse]\nNeon-lit streets on a rainy night",
    "title": "Midnight Drive",
    "style": "synthwave, female vocal, cinematic",
    "negative_tags": "metal, screaming",
    "auto_lyrics": false,
    "vocal_gender": "Female",
    "style_weight": 0.6,
    "weirdness_constraint": 0.3,
    "audio_weight": 0.5
  }'

Request examples

curl -X POST https://openrouterapi.ru/v1/music/generations \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  --data '{
    "model": "suno",
    "custom": false,
    "version": "v6",
    "prompt": "Late-night city lo-fi piano with the sound of rain"
  }'

Authorizations

Authorizationstringrequired

All endpoints require authentication using a Bearer Token

Get an API Key:

Visit the API Key management page to get your API Key

Add the following to the request headers when using it:

text
Authorization: Bearer YOUR_API_KEY

Body

modelstringdefault: suno

Audio model. Currently pass suno (defaults to suno if omitted).

custombooleandefault: false

false=inspiration mode; true=custom mode (prompt used as lyrics). Defaults to false.

instrumentalbooleandefault: false

true=instrumental only, no vocals. Defaults to false.

versionstring

Public version: v6 / v6-wild / v6-mini. At least one must be provided with custom_model_id; omit this field when using a custom model.

custom_model_idstring

The complete UUID of the created custom model task. Mutually exclusive with version and persona_id; this field is provided to be charged based on the price tier of the custom model.

promptstring

inspiration prompt / lyrics. custom=false must be filled and no more than 3000 characters; custom=true and instrumental=false must be filled and no more than 5000 characters; custom pure music can be omitted.

titlestring

Title for custom mode, up to 80 characters. Ignored when custom=false (inspiration mode).

stylestring

Style tag (custom mode), no more than 1000 characters. Ignored when custom=false (inspiration mode).

negative_tagsstring

Negative style tags (styles you don't want). Only takes effect when custom=true.

auto_lyricsboolean

true=rewrite the provided lyrics creatively. Only takes effect when custom=true.

persona_idstring

Persona Style ID. Only applies when custom=true is used and mutually exclusive with custom_model_id.

vocal_genderstring

Vocal gender: Male / Female (m / f / male / female are also accepted and normalized by the backend). Works in both modes.

style_weightnumber

Style weight, 0.00–1.00. Validated and effective in both modes.

weirdness_constraintnumber

creative score, 0.00–1.00. Both modes will validate and take effect.

audio_weightnumber

Audio weight, 0.00–1.00. Validated and effective in both modes.

varietystring

Style variation: off / normal / high / extra / max. Optional; there is no fixed default.

max_modebooleandefault: false

Whether to enable Max mode. Enable it requires custom=true and charges at twice the normal price.

audio_formatstring

Output audio format: mp3 / m4a / wav. If omitted, the service chooses the default.

durationinteger

target generation duration, range 10-360 seconds. Only available when set as custom=true; actual finished product duration will be based on task results.

Note

Get Result: This is an asynchronous task. After submission, you will receive task_id and then poll GET /v1/music/tasks/{task_id} every 3–5 seconds until status becomes completed or failed (music generation usually takes 30–120 seconds; while generation is in progress, status may be pending or processing, and progress is an integer from 0 to 100 and is not guaranteed to change at fixed intervals). Once completed, read audio_url from data.result.music[] (there are also image_url / video_url / title / duration etc.). In case of failure, data.error.message provides the reason and the deducted amount will be automatically refunded.

Response

codeinteger

Response status code

dataarray

Returned data array

Attributes

statusstring

Task status

  • submitted - Submitted
task_idstring

Unique task identifier (used to poll GET /v1/music/tasks/{task_id} for the result)

Responses

{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8SGYNNNVBQTXNR4MM964S7K"
    }
  ]
}

Found a problem in these docs? Email support@openrouterapi.ru.