Kling Audio API
AI audio generation - text-to-audio sound effects, video dubbing, and TTS.
Quick Start
Authentication
Add Authorization header with Bearer token to all requests:
Authorization: Bearer YOUR_API_KEY
Available Models
| Model | API Name | Features | Price (up to 60% off) |
|---|---|---|---|
| Sound Effects | kling-sound-effects | Sound effects, 3-10s | $0.0440/call |
| Video-to-Audio | kling-video-to-audio | Video dubbing with SFX+BGM, 3-20s video | $0.0440/call |
| TTS | kling-tts | Text-to-speech, multiple voices | $0.0100/call |
Pricing (up to 60% off)
| Model | Price |
|---|---|
kling-sound-effects | $0.0440/call |
kling-video-to-audio | $0.0440/call |
kling-tts | $0.0100/call |
Endpoints
/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
Request Parameters
Sound Effects (kling-sound-effects)
Video-to-Audio (kling-video-to-audio)
Text-to-Speech (kling-tts)
Code Examples
curl -X POST https://api.apimodels.app/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"
}'Response Format
Create Task Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "pending",
"model": "kling-audio/kling-sound-effects"
}
}Success Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "completed",
"model": "kling-audio/kling-sound-effects",
"resultUrls": ["https://...audio.mp3"],
"createTime": 1705123450000,
"completeTime": 1705123500000
}
}Failed Response
{
"code": 200,
"msg": "success",
"data": {
"taskId": "clxxx...",
"state": "failed",
"model": "kling-audio/kling-sound-effects",
"failMsg": "Content policy violation"
}
}Webhook Callback (callback_url)
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.
Payload Structure
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 | "CONTENT_MODERATION | INVALID_INPUT | INSUFFICIENT_BALANCE | UPSTREAM_BUSY | UPSTREAM_FAILED | TIMEOUT | INTERNAL_ERROR | OTHER",
"failMsg": null | "string",
"retryable": true | false, // present when state=failed: safe to retry/fallback
"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.
Audio task: shape after JSON.parse(data.resultJson)
{
"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":[]}.
Node.js receiver example
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
})Notes
- -A task stops retrying only after a 2xx response — once delivered it is never pushed again.
- -Callbacks are not signed today. Embed a random token in your callback_url path and verify it on receipt.
- -Use a public HTTPS endpoint that responds within 10 seconds (per-attempt timeout).
Task States
pendingTask queued, waiting to processprocessingAudio is being generatedcompletedAudio generation successfulfailedAudio generation failedError Codes
400Bad Request - Missing or invalid parameters401Unauthorized - Invalid API key402Payment Required - Insufficient credits404Not Found - Task ID not found500Internal Server ErrorImportant Notes
- *Audio files are stored for 30 days, download promptly
- *Text-to-audio supports duration from 3.0s to 10.0s
- *Video-to-audio requires video between 3-20 seconds
- *TTS supports max 1000 characters per request
- *For video-to-audio, provide either video_id or video_url
- *Poll every 5-10 seconds to check status
FAQ
What can the Kling audio API do?
Text-to-speech, sound-effect generation, and video-to-audio (generate a soundtrack for a clip) — all on POST /api/v1/audio/generations with one key.