API エンドポイント
セクション置換
セクション置換 API
https://udioapi.pro/api/v2/replace-section作成済みの曲の一部(ノイズの入った数秒や、歌い方を変えたい一行など)を再生成し、その部分を作り直した曲全体を受け取ります。
仕組み
- 完成した曲の中で時間区間を選びます。曲はその区間を中心に再レンダリングされ、フルレングスのトラック(通常 2 バリエーション)として、音楽生成と同じタスクの流れで返されます。
- 新しい部分が自然につながるよう、区間の前後それぞれ約 10 秒も再レンダリングされます。それ以外の部分は、音声の再エンコードを除いてそのまま残ります。
- 区間のルール(クレジット消費前にチェック):10 秒以上、曲の長さの 50% 以下かつ 480 秒以下、infill_end_s は曲の長さを超えないこと。
- lyrics を送らない場合、曲の単語タイムスタンプから区間内で歌われている歌詞が自動で入ります。別の歌詞にしたい場合はご自身で送ってください。
- 元の曲との長さの差が 15 秒を超える結果は破棄されます。結果が 1 つも残らない場合、タスクは FAILED となりクレジットは返金されます。区間の開始または終了を数秒ずらすと通常は解決します。
- 1 リクエストあたり 5 クレジットで、リクエスト受付時に消費されます。検証で拒否されたリクエストと失敗したタスクは自動で返金されます。
- 同じ API キーで /v2/generate または /v2/extend により作成した曲のみ編集できます。アップロードした音声や以前の置換結果はソースとして使用できません。
クイックスタート
{
"origin_task_id": "gen2cd84c4e3ecb94ed6a9137a8f12138ca1bksv",
"audio_id": "24015dc4-1b81-4033-9f41-cf47a3fae958",
"infill_start_s": 70,
"infill_end_s": 85,
"prompt": "Same melody and arrangement, cleaner vocal in this part"
}style、title、full_lyrics は任意です。省略した場合は元の曲の値が使われます。
レスポンス
{
"code": 200,
"message": "success",
"workId": "rep2a15b5bbc14304ca89fcc7b7eae29c8a7bksv",
"data": {
"task_id": "rep2a15b5bbc14304ca89fcc7b7eae29c8a7bksv"
}
}返された workId を 5〜10 秒ごとにポーリングし、ステータスが SUCCESS または FAILED になるまで確認してください。使用する API: タスクステータス API
パラメーター
必須パラメーター
origin_task_id必須string編集したい完成済みの曲の task_id(/v2/generate または /v2/extend が返した値)。
audio_id必須stringそのタスク内の曲の id(response_data[].id)。タスクは通常 2 曲を返すため、編集する曲を選んでください。
infill_start_s必須number区間の開始(秒)。0 以上、小数点以下 2 桁まで。
infill_end_s必須number区間の終了(秒)。infill_start_s より 10 秒以上後で、曲の終わりを超えないこと。
prompt必須string区間をどう変えるか(最大 1000 文字)。例:"Same melody and arrangement, cleaner vocal in this part"。
任意パラメーター
lyrics任意string区間内で歌う歌詞(最大 5000 文字)。既定では区間内で現在歌われている歌詞が使われます。
style任意string結果の音楽スタイル(最大 1000 文字)。既定では元の曲のスタイル。
title任意string結果のタイトル(最大 80 文字)。既定では元のタイトル。
full_lyrics任意string編集後の曲の全歌詞(最大 5000 文字)。既定では元の歌詞。
callback_url任意string最終結果を受け取る公開 URL。内容はタスクステータスの response_data と同じです。設定の有無にかかわらずポーリングできます。
結果
タスクが成功すると、response_data に新しいフルレングスの曲が含まれます。各項目にはそれぞれ id、audio_url、duration があります。元の長さを保ったバリエーションが 1 つだけの場合は、その 1 つだけが返されます。
{
"code": 200,
"message": "success",
"data": {
"type": "SUCCESS",
"request_body": {
"origin_task_id": "gen2cd84c4e3ecb94ed6a9137a8f12138ca1bksv",
"audio_id": "24015dc4-1b81-4033-9f41-cf47a3fae958",
"infill_start_s": 70,
"infill_end_s": 85,
"prompt": "Same melody and arrangement, cleaner vocal in this part"
},
"response_data": [
{
"id": "3a8248e4-07b0-4ceb-92b7-34b7615d2552",
"audio_url": "https://…/3a8248e4-07b0-4ceb-92b7-34b7615d2552.mp3",
"image_url": "https://…/3a8248e4-07b0-4ceb-92b7-34b7615d2552.jpeg",
"status": "complete",
"title": "Harbor Lights",
"duration": 119.6,
"model_name": "chirp-v6-mini"
},
{
"id": "eac654a1-5c07-4b6c-896a-59061d323e11",
"audio_url": "https://…/eac654a1-5c07-4b6c-896a-59061d323e11.mp3",
"image_url": "https://…/eac654a1-5c07-4b6c-896a-59061d323e11.jpeg",
"status": "complete",
"title": "Harbor Lights",
"duration": 120.84,
"model_name": "chirp-v6-mini"
}
]
}
}すべての結果で曲の長さが変わった場合、または区間をレンダリングできなかった場合、タスクは FAILED となりクレジットは返金されます:
{
"code": 200,
"message": "success",
"data": {
"type": "FAILED",
"response_data": [
{
"status": "FAILED",
"fail_message": "Generation failed. Your credits have been refunded. The result changed the song length (119.6s -> 225.36s / 224.6s), so it was discarded. Try moving the section start or end by a few seconds.",
"error_message": "Generation failed. Your credits have been refunded. The result changed the song length (119.6s -> 225.36s / 224.6s), so it was discarded. Try moving the section start or end by a few seconds."
},
{
"status": "FAILED",
"fail_message": "Generation failed. Your credits have been refunded. The result changed the song length (119.6s -> 225.36s / 224.6s), so it was discarded. Try moving the section start or end by a few seconds.",
"error_message": "Generation failed. Your credits have been refunded. The result changed the song length (119.6s -> 225.36s / 224.6s), so it was discarded. Try moving the section start or end by a few seconds."
}
]
}
}コード例
cURL
curl -X POST "https://udioapi.pro/api/v2/replace-section" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"origin_task_id": "gen2cd84c4e3ecb94ed6a9137a8f12138ca1bksv",
"audio_id": "24015dc4-1b81-4033-9f41-cf47a3fae958",
"infill_start_s": 70,
"infill_end_s": 85,
"prompt": "Same melody and arrangement, cleaner vocal in this part"
}'JavaScript
const response = await fetch('https://udioapi.pro/api/v2/replace-section', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"origin_task_id": "gen2cd84c4e3ecb94ed6a9137a8f12138ca1bksv",
"audio_id": "24015dc4-1b81-4033-9f41-cf47a3fae958",
"infill_start_s": 70,
"infill_end_s": 85,
"prompt": "Same melody and arrangement, cleaner vocal in this part"
})
});
const { workId } = await response.json();
// Poll https://udioapi.pro/api/v2/feed?workId=... every 5-10 seconds until SUCCESS or FAILED.Python
import requests
response = requests.post(
"https://udioapi.pro/api/v2/replace-section",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"origin_task_id": "gen2cd84c4e3ecb94ed6a9137a8f12138ca1bksv",
"audio_id": "24015dc4-1b81-4033-9f41-cf47a3fae958",
"infill_start_s": 70,
"infill_end_s": 85,
"prompt": "Same melody and arrangement, cleaner vocal in this part"
},
)
work_id = response.json()["workId"]
# Poll https://udioapi.pro/api/v2/feed?workId=... every 5-10 seconds until SUCCESS or FAILED.エラーレスポンス
{
"code": 400,
"message": "The section must be at least 10 seconds long (requested 9.99s)."
}{
"code": 400,
"message": "The section can cover at most 50% of the song and 480s (max 59.8s for this song, requested 65s)."
}{
"code": 400,
"message": "\"infill_end_s\" must not exceed the song length (119.6s)."
}{
"code": 400,
"message": "The provided \"origin_task_id\" is invalid or could not be found. Use the task_id of a completed song generated with your API key."
}{
"code": 400,
"message": "\"audio_id\" 1234 does not belong to this task. Use one of the song ids returned for \"origin_task_id\"."
}{
"code": 400,
"message": "Only songs generated with this API can be edited: send \"origin_task_id\" and \"audio_id\", without \"upload_url\" or \"model\"."
}{
"code": 402,
"message": "No available credits"
}{
"code": 401,
"message": "Invalid API key"
}