Эндпоинты API

Расширение музыки

POST/v2/extend

Расширение музыкального API

Расширьте существующие музыкальные треки, добавив в конец новый контент.

POSThttps://udioapi.pro/api/v2/extend

tips

Два режима: наследовать исходные параметры или использовать специальные параметры.

Используйте Feed API с возвращаемым рабочим идентификатором для проверки прогресса.

requestHeaders

namerequireddescription
AuthorizationyesТокен носителя для аутентификации
Content-Typeyesapplication/json

requestBody

Тело запроса поддерживает режим наследования или пользовательский режим.

Режим наследования

Расширить, используя исходные параметры трека

noAdditionalParams

Пользовательский режим

Расширить с помощью пользовательских параметров

paramNameparamTyperequireddescriptionexample
promptstringyesНовый текст или описаниеChange the music style to be calm and lyrical.
stylestringnoМузыкальный стильlyrical
titlestringnoНазвание трекаlyrical song
extensionStartTimenumbernoВремя начала продления в секундах150
tagsstringnoДополнительные тегиwar

commonParams

paramNameparamTyperequireddescriptionexample
origin_task_idstringyesИдентификатор задачи из оригинальной генерации музыкиgen20e094aeaadfe494ea33a5c80ee596083bksv
extend_audio_indexnumberyes0 для первого звука, 1 для второго звука0
custom_modebooleannofalse для режима наследования, true для пользовательского режимаfalse
callback_urlstringnoДополнительный URL-адрес веб-перехватчика для получения результатов в реальном времениhttps://your-domain.com/webhook

responses

json
{
  "code": 200,
  "message": "success",
  "workId": "ext2e31202d4f629447fa75f603ae2470565bksv"
}
json
{
  "code": 400,
  "message": "Please specify which audio to extend. Add \"extend_audio_index\" to your request, using 0 for the first audio or 1 for the second."
}
json
{
  "code": 400,
  "message": "The provided \"origin_task_id\" is invalid or could not be found. Please ensure it corresponds to a successfully completed task associated with your API key."
}
json
{
  "code": 400,
  "message": "The requested audio is not yet completed. Please wait for the task to complete and try again."
}
json
{
  "code": 401,
  "message": "No API key provided in Authorization header"
}
json
{
  "code": 500,
  "message": "Internal Server Error"
}

codeExamples

curl
curl -X POST "https://udioapi.pro/api/v2/extend" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "origin_task_id": "gen20e094aeaadfe494ea33a5c80ee596083bksv",
    "extend_audio_index": 0,
    "custom_mode": false
  }'
curl
curl -X POST "https://udioapi.pro/api/v2/extend" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "origin_task_id": "gen20e094aeaadfe494ea33a5c80ee596083bksv",
    "extend_audio_index": 0,
    "custom_mode": true,
    "prompt": "Change the music style to be calm and lyrical.",
    "style": "lyrical",
    "title": "lyrical song",
    "extensionStartTime": 150,
    "tags": "war"
  }'
javascript
const response = await fetch('https://udioapi.pro/api/v2/extend', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    origin_task_id: 'gen20e094aeaadfe494ea33a5c80ee596083bksv',
    extend_audio_index: 0,
    custom_mode: false
  })
});

const data = await response.json();
console.log(data);
javascript
const response = await fetch('https://udioapi.pro/api/v2/extend', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer YOUR_API_KEY',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    origin_task_id: 'gen20e094aeaadfe494ea33a5c80ee596083bksv',
    extend_audio_index: 0,
    custom_mode: true,
    prompt: 'Change the music style to be calm and lyrical.',
    style: 'lyrical',
    title: 'lyrical song',
    extensionStartTime: 150,
    tags: 'war'
  })
});

const data = await response.json();
console.log(data);
python
import requests

url = "https://udioapi.pro/api/v2/extend"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "origin_task_id": "gen20e094aeaadfe494ea33a5c80ee596083bksv",
    "extend_audio_index": 0,
    "custom_mode": False
}

response = requests.post(url, headers=headers, json=data)
print(response.json())
python
import requests

url = "https://udioapi.pro/api/v2/extend"
headers = {
    "Authorization": "Bearer YOUR_API_KEY",
    "Content-Type": "application/json"
}
data = {
    "origin_task_id": "gen20e094aeaadfe494ea33a5c80ee596083bksv",
    "extend_audio_index": 0,
    "custom_mode": True,
    "prompt": "Change the music style to be calm and lyrical.",
    "style": "lyrical",
    "title": "lyrical song",
    "extensionStartTime": 150,
    "tags": "war"
}

response = requests.post(url, headers=headers, json=data)
print(response.json())