Langsung ke konten utama
POST
/
v1
/
music
/
generations
curl --request POST \
  --url https://api.apimart.ai/v1/music/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flowmusic",
    "title": "My Song",
    "sound_prompt": "upbeat pop music with piano",
    "bpm": "120",
    "length": 60
  }'
import requests

url = "https://api.apimart.ai/v1/music/generations"

payload = {
    "model": "flowmusic",
    "title": "My Song",
    "sound_prompt": "upbeat pop music with piano",
    "bpm": "120",
    "length": 60
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/music/generations";

const payload = {
  model: "flowmusic",
  title: "My Song",
  sound_prompt: "upbeat pop music with piano",
  bpm: "120",
  length: 60
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
    }
  ]
}
{
  "error": {
    "message": "sound_prompt and lyrics cannot both be empty",
    "type": "invalid_request",
    "param": "",
    "code": "invalid_request"
  }
}
{
  "error": {
    "message": "Saldo tidak mencukupi",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "Kapasitas grup saat ini penuh, silakan coba lagi nanti",
    "type": "rate_limit_error",
    "param": "",
    "code": "rate_limit_error"
  }
}
curl --request POST \
  --url https://api.apimart.ai/v1/music/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "flowmusic",
    "title": "My Song",
    "sound_prompt": "upbeat pop music with piano",
    "bpm": "120",
    "length": 60
  }'
import requests

url = "https://api.apimart.ai/v1/music/generations"

payload = {
    "model": "flowmusic",
    "title": "My Song",
    "sound_prompt": "upbeat pop music with piano",
    "bpm": "120",
    "length": 60
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/music/generations";

const payload = {
  model: "flowmusic",
  title: "My Song",
  sound_prompt: "upbeat pop music with piano",
  bpm: "120",
  length: 60
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01K8AYYM6R03TGZ3Q2P0TZVNPX"
    }
  ]
}
{
  "error": {
    "message": "sound_prompt and lyrics cannot both be empty",
    "type": "invalid_request",
    "param": "",
    "code": "invalid_request"
  }
}
{
  "error": {
    "message": "Saldo tidak mencukupi",
    "type": "invalid_request",
    "param": "",
    "code": "quota_not_enough"
  }
}
{
  "error": {
    "message": "Kapasitas grup saat ini penuh, silakan coba lagi nanti",
    "type": "rate_limit_error",
    "param": "",
    "code": "rate_limit_error"
  }
}

Autentikasi

Authorization
string
wajib
Semua endpoint memerlukan autentikasi menggunakan Bearer TokenMendapatkan API Key:Kunjungi halaman pengelolaan API Key untuk mendapatkan API Key AndaTambahkan ke header permintaan saat digunakan:
Authorization: Bearer YOUR_API_KEY

Parameter Permintaan

model
string
wajib
Nama model, selalu isi "flowmusic" (tidak peka huruf besar/kecil)
sound_prompt
string
Prompt deskripsi gaya musik atau suaraContoh: "upbeat pop music with piano"
sound_prompt dan lyrics tidak boleh kosong keduanya (isi minimal salah satu). Setiap permintaan hanya menghasilkan satu lagu.
lyrics
string
Teks lirik, dapat diperoleh terlebih dahulu melalui endpoint Membuat Lirik lalu diisikan kembaliContoh: "[Verse 1]\nSekelam apa pun malam, fajar kan tiba\n..."
title
string
Judul musik yang dihasilkan
bpm
string
BPM (ketukan per menit), harus ≥ 1Contoh: "120"
length
integer
Durasi hasil (detik)Rentang yang didukung: 1 ~ 240 detik
seed
string
Seed acak, digunakan untuk mereproduksi hasil
Mengirim nilai seed yang sama pada permintaan yang sama akan menghasilkan hasil yang serupa, tetapi tidak dijamin sepenuhnya identik.

Respons

code
integer
Kode status respons, bernilai 200 jika berhasil
data
array
Array data yang dikembalikan

Skenario Penggunaan

Skenario 1: Membuat musik hanya dengan prompt gaya

{
  "model": "flowmusic",
  "title": "My Song",
  "sound_prompt": "upbeat pop music with piano",
  "bpm": "120",
  "length": 60
}

Skenario 2: Lirik + gaya menjadi lagu

{
  "model": "flowmusic",
  "title": "Ketekunan",
  "lyrics": "[Verse 1]\nSekelam apa pun malam, fajar kan tiba\n...",
  "sound_prompt": "energetic rock with electric guitar",
  "length": 120
}
Memeriksa hasil tugasPembuatan musik adalah tugas asinkron; setelah diajukan, task_id akan dikembalikan. Gunakan endpoint Mendapatkan Status Tugas untuk memeriksa progres dan hasil pembuatan.

Contoh Hasil Tugas Selesai

Contoh respons kueri (GET /v1/music/tasks/{task_id}):
{
  "code": 200,
  "data": {
    "id": "task_01KWXVB61E28THHFBSYXWA4FAJ",
    "status": "completed",
    "progress": 100,
    "created": 1783413184,
    "completed": 1783413236,
    "actual_time": 52,
    "cost": 0.048,
    "credits_cost": 0.48,
    "result": {
      "music": [
        {
          "clip_id": "a41aade4-993e-4d28-b56f-d97e7ef7167c",
          "title": "Regression Song",
          "duration_seconds": "181.70666667",
          "create_time": "2026-07-07T08:33:32.854073Z",
          "lyrics": "[Verse 1]\nWaking up to the morning light,\n...",
          "lyrics_id": "c302d603-81b6-552f-8122-e512928d6aa1",
          "lyrics_timing_markers": [[10, 12], [212, 36]],
          "audio_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.m4a",
          "wav_url": "https://cdn.apimart.ai/audio/flowmusic_a41aade4.wav",
          "image_url": "https://cdn.apimart.ai/image/flowmusic_a41aade4_cover.jpg"
        }
      ]
    }
  }
}