callBackUrl
parameter to set a callback URL. When the task is completed, the system will automatically push the results to your specified address.
Callback Mechanism Overview
The callback mechanism eliminates the need to poll the API for task status. The system will proactively push task completion results to your server.
Callback Timing
The system will send callback notifications in the following situations:- Text generation completed (
text
stage) - First extended audio track generated (
first
stage) - All extended audio tracks generated (
complete
stage) - Audio extension task failed
- Error occurred during task processing
Callback Method
- HTTP Method: POST
- Content Type: application/json
- Timeout: 15 seconds
Callback Request Format
When a task is completed, the system will send a POST request to yourcallBackUrl
in the following format:
Status Code Description
Callback status code indicating task processing result:
Status Code | Description |
---|---|
200 | Success - Extension completed |
400 | Bad Request - Parameter error or invalid audio file |
401 | Unauthorized - Invalid API key |
413 | Content Too Long - Audio file too large or duration exceeds limit |
429 | Insufficient Credits - Account credit balance insufficient |
500 | Server Error - Please retry later |
Status message providing detailed status description
Callback type indicating current callback stage:
text
: Text generation completefirst
: First extension completecomplete
: All extensions completefailed
: Task failed
Task ID, consistent with the taskId returned when you submitted the task
Extension result information, returned on success
Unique audio identifier (audioId)
Extended audio file download link
Original audio file download link
Streaming audio playback link
Music cover image link
Prompt/lyrics used for extension
AI model name used
Music title
Music style tags
Creation time
Extended audio duration (seconds)
Best Practices
Callback URL Configuration Recommendations
- Use HTTPS: Ensure callback URLs use HTTPS protocol for secure data transmission
- Verify Source: Validate the legitimacy of request sources in callback processing
- Idempotent Processing: The same taskId may receive multiple callbacks, ensure processing logic is idempotent
- Quick Response: Callback processing should return 200 status code quickly to avoid timeout
- Asynchronous Processing: Complex business logic should be processed asynchronously to avoid blocking callback response
- Stage-based Processing: Perform appropriate business processing based on different callback stages
- Audio Comparison: Compare audio duration and quality changes before and after extension
- Upload Validation: Ensure uploaded audio file quality and integrity
Important Reminders
- Callback URL must be a publicly accessible address
- Server must respond within 15 seconds, otherwise considered timeout
- After 3 consecutive retry failures, the system will stop sending callbacks
- Please ensure the stability of callback processing logic to avoid callback failures due to exceptions
- Extended audio URLs may have time limits, recommend downloading and saving promptly
- Uploaded audio files must not exceed 2 minutes, ensure compliance with limits
- Extension function will extend audio length while maintaining original style
- Music extension has three stages, each stage will trigger callback notifications
Troubleshooting
If you don’t receive callback notifications, please check the following:Network Connection Issues
Network Connection Issues
- Confirm that the callback URL is accessible from the public internet
- Check firewall settings to ensure inbound requests are not blocked
- Verify that domain name resolution is correct
Server Response Issues
Server Response Issues
- Ensure the server returns HTTP 200 status code within 15 seconds
- Check server logs for error information
- Verify that the interface path and HTTP method are correct
Extension Parameter Issues
Extension Parameter Issues
- Confirm that the upload URL is valid and accessible
- Check the uploaded audio file format and quality
- Verify that the audio file duration does not exceed the 2-minute limit
- Confirm that extension parameters (continueAt, etc.) are set correctly
Callback Stage Processing
Callback Stage Processing
- Understand the differences and processing methods of the three callback stages
- text stage: Only indicates text generation complete, no audio data
- first stage: First extended music complete, contains data for one track
- complete stage: All extended music complete, contains complete music list
Alternative Solutions
If you cannot use the callback mechanism, you can also use polling:Poll Extension Results
Use the Get Music Generation Details interface to regularly query extension task status. Recommend querying every 30 seconds.