calesthio/OpenMontage · error · KlingAPIError
Kling TTS create response missing data.task_id: {data}
Error message
Kling TTS create response missing data.task_id: {data} What it means
Raised as KlingAPIError when the POST /v1/audio/tts response's data object has no task_id. The client considers a create without task_id unrecoverable because both the synchronous path (task_result.audios) and the polling path key off it. The full response body is embedded for diagnosis.
Source
Thrown at tools/audio/kling_tts.py:245
@staticmethod
def _create_and_collect_audios(
client: KlingClient,
request: dict[str, Any],
inputs: dict[str, Any],
) -> tuple[str, list[dict[str, Any]]]:
"""Create a TTS task and return audio outputs.
Official TTS may return a completed task and task_result.audios[]
directly from POST /v1/audio/tts. Older/async behavior still requires
polling GET /v1/audio/tts/{task_id}, so support both shapes.
"""
if hasattr(client, "post"):
data = client.post(request["path"], request["payload"])
payload = data.get("data") or {}
task_id = payload.get("task_id")
if not task_id:
raise KlingAPIError(f"Kling TTS create response missing data.task_id: {data}")
task_result = payload.get("task_result") or {}
outputs = task_result.get("audios")
if outputs is not None:
if not isinstance(outputs, list):
raise KlingAPIError("Kling TTS result path data.task_result.audios is not a list")
return str(task_id), outputs
status = payload.get("task_status") or payload.get("status")
if status == "failed":
message = payload.get("task_status_msg") or payload.get("message") or "Kling TTS task failed"
raise KlingAPIError(str(message), code=payload.get("task_status"), response=data)
return str(task_id), client.poll_classic(
request["path"],
str(task_id),
"audios",
timeout_seconds=int(inputs.get("timeout_seconds", 300)),View on GitHub (pinned to 95e1c3d0ab)
Solutions
- Read the embedded response body — it usually contains the real upstream code/message
- Verify KLING_API_KEY/KLING_ACCESS_KEY entitlements include audio TTS
- Retry once for transient soft failures
- If the envelope changed, update the extraction path in _execute_with_client
Defensive patterns
Strategy: try-catch
Try / catch
try:
result = kling_tts_tool.execute(inputs)
except KlingAPIError as e:
if "missing data.task_id" in str(e):
logger.error("kling create envelope unexpected: %s", getattr(e, "response", None))
raise
raise Prevention
- Verify KLING API credentials are entitled for /v1/audio/tts
- Log full create responses during integration to catch envelope drift early
- Centralize Kling calls so one retry/diagnostic path covers all tools
When it happens
Trigger: API returns an error envelope that still passed the client's status checks (code treated as success), an envelope version change moving task_id elsewhere, or data: null on a soft auth/account failure.
Common situations: Kling API version bump changing the response shape; account not entitled for TTS returning an unusual body; gateway response replaced by a different JSON structure.
Related errors
- Kling TTS result path data.task_result.audios is not a list
- Kling TTS response item contained no downloadable URL: {item
- Kling Classic create response missing data.task_id: {data}
- Doubao submit succeeded but did not return data.task_id
- Doubao task completed but did not return data.audio_url
AI-assisted analysis of calesthio/OpenMontage@95e1c3d0ab (2026-08-15).
Data as JSON: /api/errors/5ccbe7d8b00254fb.
Report an issue: GitHub.