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 instrumental track generated (
first
stage) - All instrumental tracks generated (
complete
stage) - Instrumental generation 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 - Instrumental generation completed |
400 | Bad Request - Parameter error or invalid source audio |
401 | Unauthorized - Invalid API key |
413 | Content Too Long - Tags 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 instrumental track generatedcomplete
: All instrumental tracks generatedfailed
: Task failed
Task ID, consistent with the taskId returned when you submitted the task
Instrumental generation result information, returned on success
Audio unique identifier (audioId)
Audio file download link with instrumental elements
Original source audio file download link
Streaming audio playback link with instrumental elements
Music cover image link
Prompt used for instrumental generation
AI model name used for instrumental generation
Music title with instrumental elements
Music style tags including instrumental characteristics
Creation time
Audio duration (seconds)
Callback Reception Examples
Here are example codes for receiving callbacks in various popular programming languages:- Node.js
- Python
- PHP
Best Practices
Instrumental Generation Callback Configuration Recommendations
- Use HTTPS: Ensure your callback URL uses HTTPS protocol for secure data transmission
- Verify Source: Verify the legitimacy of the request source in callback processing
- Idempotent Processing: Ensure processing logic is idempotent as the same taskId may receive multiple callbacks
- 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: Handle different callback stages (text, first, complete) with appropriate business logic
- Audio Quality Assessment: Implement audio quality assessment for generated instrumental tracks
- Style Validation: Validate that generated instrumental matches requested style and characteristics
Important Reminders
- Callback URL must be publicly accessible
- Server must respond within 15 seconds, otherwise considered timeout
- After 3 consecutive retry failures, the system will stop sending callbacks
- Ensure stability of callback processing logic to avoid callback failures due to exceptions
- Generated instrumental audio URLs may have time limits, recommend downloading and saving promptly
- Pay attention to source audio quality to ensure optimal instrumental generation results
- Instrumental generation has three stages, each stage will trigger callback notifications
- Consider implementing audio format validation for source files
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 messages
- Verify that the interface path and HTTP method are correct
Content Format Issues
Content Format Issues
- Confirm that the received POST request body is in JSON format
- Check if Content-Type is application/json
- Verify that JSON parsing is correct
Instrumental Processing Issues
Instrumental Processing Issues
- Confirm that instrumental audio URLs are accessible
- Check instrumental audio download permissions and network connectivity
- Verify audio save path and permissions
- Ensure source audio format is supported and valid
- Verify instrumental quality meets your application requirements
Callback Stage Processing
Callback Stage Processing
- Understand the differences and handling methods of the three callback stages
- text stage: Only indicates text generation completed, no audio data
- first stage: First instrumental track completed, contains data for one track
- complete stage: All instrumental tracks completed, contains complete instrumental track list
Audio Quality and Format
Audio Quality and Format
- Implement audio format validation for source files
- Check instrumental audio quality and format compatibility
- Assess if generated instrumental meets style requirements
- Handle different instrumental styles and arrangements appropriately
Alternative Solutions
If you cannot use the callback mechanism, you can also use polling:Poll Query Results
Use the Get Music Generation Details interface to regularly query task status. Recommend querying every 30 seconds.