Skip to main content
POST
/
v1
/
ai
/
music-generation
curl --request POST \
  --url https://api.freepik.com/v1/ai/music-generation \
  --header 'Content-Type: application/json' \
  --header 'x-freepik-api-key: <api-key>' \
  --data '
{
  "prompt": "A Blues guitar solo with emotional bends and slides",
  "music_length_seconds": 60
}
'
{
"data": {
"generated": [],
"task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"status": "CREATED"
}
}

Authorizations

x-freepik-api-key
string
header
required

Your Freepik API key. Required for authentication. Learn how to obtain an API key

Body

application/json
prompt
string
required

Text description of the music you want to generate. Be specific about the style, mood, instruments, tempo, and genre for best results.

Tips for effective prompts:

  • Include genre: "jazz", "electronic", "classical", "rock"
  • Describe mood: "upbeat", "melancholic", "energetic", "peaceful"
  • Mention instruments: "piano", "guitar", "drums", "synthesizer"
  • Add tempo hints: "slow", "fast-paced", "moderate groove"
Maximum string length: 2500
Example:

"A Blues guitar solo with emotional bends and slides"

music_length_seconds
integer
required

Duration of the generated music track in seconds.

Duration limits:

  • Minimum: 10 seconds
  • Maximum: 240 seconds (4 minutes)

Common durations:

  • 30 seconds
  • 60 seconds (1 minute)
  • 120 seconds (2 minutes)
  • 240 seconds (4 minutes)
Required range: 10 <= x <= 240
Example:

60

webhook_url
string<uri>

Optional callback URL that will receive asynchronous notifications whenever the task changes status. The payload sent to this URL is the same as the corresponding GET endpoint response, but without the data field.

Example:

"https://www.example.com/webhook"

Response

OK - The task exists and the status is returned

data
object
required
Example:
{
"task_id": "046b6c7f-0b8a-43b9-b35d-6489e6daee91",
"status": "CREATED",
"generated": [
"https://openapi-generator.tech",
"https://openapi-generator.tech"
]
}