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 music track generated (
first
stage) - All extended music tracks generated (
complete
stage) - Music extension task failed
- Error occurred during task processing
Callback Method
- HTTP Method: POST
- Content Type: application/json
- Timeout: 15 seconds
Callback Request Format
When the 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 - Music extension completed |
400 | Bad Request - Invalid source audio or parameter error |
401 | Unauthorized - Invalid API key |
413 | Content Too Long - Prompt or style description exceeds limit |
429 | Insufficient Credits - Account credit balance insufficient |
500 | Server Error - Please retry later |
Status message providing detailed status description
Callback type indicating the current callback stage:
text
: Text generation completedfirst
: First extended music track generatedcomplete
: All extended music tracks generatedfailed
: Task failed
Task ID, consistent with the taskId returned when you submitted the task
Music extension result information, returned on success
Audio unique identifier (audioId)
Extended audio file download link
Original extended audio file download link
Streaming audio playback link
Music cover image link
Extension prompt used
AI model name used for extension
Extended music title
Music style tags
Creation time
Extended audio duration (seconds)
Callback Reception Examples
Here are example codes for receiving callbacks in various popular programming languages:- Node.js
- Python
- PHP
Best Practices
Music Extension Callback Configuration
- Source Validation: Verify that the original audio source is valid before processing extension callbacks
- Duration Tracking: Monitor the extended duration to ensure it meets your requirements
- Quality Check: Implement quality checks for the extended audio segments
- Version Control: Keep track of extension iterations and maintain version history
- Fallback Handling: Implement fallback mechanisms if extension fails
- Seamless Integration: Ensure the extended portion integrates smoothly with the original track
Extension-Specific Considerations
- Extension tasks require a valid source audio file
- The
continueAt
parameter determines where the extension begins - Extended tracks maintain the style and characteristics of the original
- Extension quality depends on the source audio quality
- Some complex musical structures may be challenging to extend seamlessly
Troubleshooting
Common issues specific to music extension callbacks:Extension Quality Issues
Extension Quality Issues
- Verify the source audio quality and format
- Check if the
continueAt
parameter is set to an appropriate time point - Ensure the extension prompt matches the original music style
- Consider the musical complexity of the source material
Source Audio Problems
Source Audio Problems
- Confirm the source audio ID is valid and accessible
- Verify the original audio file is not corrupted
- Check if the source audio meets minimum quality requirements
- Ensure the original track has sufficient content for extension
Timing and Synchronization
Timing and Synchronization
- Verify the
continueAt
timestamp is within the valid range - Check for audio synchronization issues in the extended portion
- Monitor for tempo or key changes that might affect extension quality
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.