跳到主要内容

Music Generation

Billing Rules

$0.035 per request. The model is v4.5-all, and this is the only available model.

Basic Configuration

Base URL: https://api.foxaihub.com/api/v2

HTTP Headers

{
"api-key": "Your API Key"
}

Submit Task

Endpoint: /music/task

Method: POST

Content-Type: application/json

The HTTP body allows different parameters to support different generation modes.

{
"topic": "a song about spring",
"is_instrumental": true
}

Explanation: The topic field is a description of the song, and is_instrumental controls whether vocals are included.

Response

{
"success": true,
"task_id": "4f3acce5-eb32-46b4-9c96-9cc1e2b2c922"
}

task_id is the unique ID used to track this task.

Query Result

Path: /music/task?ids=

You must query at least 1 task result per request and can query up to 25 task results per request. Different task_id values should be separated by commas.

/task?ids=0196bd6d-57a4-7000-96c6-f74ee7998e5f,0196bd6d-acc0-7000-81ae-a56d8b0631b6

Method: GET

The HTTP response can be categorized into the following results based on the status.

Indicates that the task is still being processed, and the data field does not yet contain valid data.

Development recommendation: Only focus on the streaming, completed, and failed statuses, and set a task timeout.

For example, from submission to receiving the result, a generation task usually takes no more than 6 minutes. Once this time threshold is exceeded, the task can be treated as failed to prevent infinite polling.

Advanced

If you need a webhook, I would also be happy to develop it, which can reduce the implementation workload for users.