APIMODELSAPIMODELS
Документация API

apimodels.app

Docs/Kling Audio API
AU

Kling Audio API

AI audio generation - text-to-audio sound effects, video dubbing, and TTS.

Quick Start

1
Get your API key from the Console
2
Choose a Kling audio model
3
Send POST request to create task
4
Poll GET request for audio result

Authentication

Add Authorization header with Bearer token to all requests:

Authorization: Bearer YOUR_API_KEY

Available Models

ModelAPI NameFeaturesPrice (up to 60% off)
Sound Effectskling-sound-effectsSound effects, 3-10s$0.0440/call
Video-to-Audiokling-video-to-audioVideo dubbing with SFX+BGM, 3-20s video$0.0440/call
TTSkling-ttsText-to-speech, multiple voices$0.0100/call

Pricing (up to 60% off)

ModelPrice
kling-sound-effects$0.0440/call
kling-video-to-audio$0.0440/call
kling-tts$0.0100/call

Endpoints

POST/api/v1/audio/generations

Create a Kling audio generation task. Routes to text-to-audio, video-to-audio, or TTS based on the model parameter.

GET/api/v1/audio/generations?task_id=xxx

Query task status and get audio URL

Request Parameters

Sound Effects (kling-sound-effects)

modelrequiredstring
"kling-sound-effects"
promptrequiredstring
Text description of the sound effect
durationrequiredstring
"3.0" to "10.0" (supports 1 decimal place)
callback_urlstring
Webhook URL for completion notification

Video-to-Audio (kling-video-to-audio)

modelrequiredstring
"kling-video-to-audio"
video_idstring
Kling video ID (within 30 days, 3-20s). One of video_id/video_url required.
video_urlstring
Video URL (MP4/MOV, <=100MB, 3-20s). One of video_id/video_url required.
sound_effect_promptstring
Sound effect prompt
bgm_promptstring
Background music prompt
asmr_modeboolean
Enhance detail sounds
callback_urlstring
Webhook URL for completion notification

Text-to-Speech (kling-tts)

modelrequiredstring
"kling-tts"
textrequiredstring
Text to synthesize (max 1000 chars)
voice_idrequiredstring
Kling voice ID, e.g. "genshin_vindi2". Get all valid IDs (presets + your custom voices) from GET /api/v1/kling/voices. IDs from other systems (e.g. Minimax) do NOT work.
voice_languagerequiredstring
Language code e.g. "zh", "en"
voice_speednumber
0.8-2.0, default 1.0
callback_urlstring
Webhook URL for completion notification

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 process
processingAudio is being generated
completedAudio generation successful
failedAudio generation failed

Error Codes

400Bad Request - Missing or invalid parameters
401Unauthorized - Invalid API key
402Payment Required - Insufficient credits
404Not Found - Task ID not found
500Internal Server Error

Important 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.