AI audio generation - text-to-audio sound effects, video dubbing, and TTS.
Add Authorization header with Bearer token to all requests:
Authorization: Bearer YOUR_API_KEY
| Model | API Name | Features | Price (85% off) |
|---|---|---|---|
| Sound Effects | kling-sound-effects | Sound effects, 3-10s | $0.0295/call |
| Video-to-Audio | kling-video-to-audio | Video dubbing with SFX+BGM, 3-20s video | $0.0027/call |
| TTS | kling-tts | Text-to-speech, multiple voices | $0.0006/call |
| Model | Price |
|---|---|
kling-sound-effects | $0.0295/call |
kling-video-to-audio | $0.0027/call |
kling-tts | $0.0006/call |
/api/v1/audio/generationsCreate a Kling audio generation task. Routes to text-to-audio, video-to-audio, or TTS based on the model parameter.
/api/v1/audio/generations?task_id=xxxQuery task status and get audio URL
curl -X POST https://apimodels.app/api/v1/audio/generations \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-sound-effects",
"prompt": "Strong wind blowing through a forest with rustling leaves",
"duration": "5.0"
}'{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending",
"model": "kling-audio/kling-sound-effects"
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"model": "kling-audio/kling-sound-effects",
"resultUrls": ["https://...audio.mp3"],
"createTime": 1705123450000,
"completeTime": 1705123500000
}
}{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"model": "kling-audio/kling-sound-effects",
"failMsg": "Content policy violation"
}
}Pass callback_url in the create request. When the task reaches the completed or failed terminal state, our server sends a single HTTP POST to that URL with Content-Type: application/json (no signing header). Delivery is retried up to 3 times (exponential backoff 1s/2s/4s, 10s per attempt); if still unsuccessful, a background job keeps retrying for up to 30 minutes until your endpoint returns 2xx.
POST {your callback_url}
Content-Type: application/json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"model": "kling-audio/kling-sound-effects",
"state": "completed" | "failed",
"param": "<JSON string>", // request params, JSON.parse once
"resultJson": "<JSON string> | null", // result object, JSON.parse once
"failCode": null | "string",
"failMsg": null | "string",
"costTime": 12345, // duration in ms
"completeTime": 1705123500000, // ms epoch
"createTime": 1705123450000 // ms epoch
}
}Note: data.param and data.resultJson are both JSON strings — call JSON.parse once on each.
{
"resultUrls": ["https://r2.apimodels.app/audio/xxx.mp3"],
"audioDuration": 12.5 // optional, seconds
}resultUrls is an R2-hosted audio URL array (length 1 in success). audioDuration may be present (seconds). When state=failed, resultJson is typically null or {"resultUrls":[]}.
app.post('/webhook/kling-audio', express.json(), (req, res) => {
const { taskId, state, resultJson, failMsg } = req.body.data
if (state === 'completed') {
const r = JSON.parse(resultJson)
console.log('audio ready', taskId, r.resultUrls[0], r.audioDuration)
} else {
console.warn('audio failed', taskId, failMsg)
}
res.status(200).end() // must be 2xx, otherwise we retry
})pendingTask queued, waiting to processprocessingAudio is being generatedcompletedAudio generation successfulfailedAudio generation failed400Bad Request - Missing or invalid parameters401Unauthorized - Invalid API key402Payment Required - Insufficient credits404Not Found - Task ID not found500Internal Server Error