> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gengen.farm/llms.txt
> Use this file to discover all available pages before exploring further.

# Errors and callback handling

> How GENGEN maps Kling errors and securely processes Kling task callbacks.

Kling tasks are asynchronous. Create a task, persist its public GENGEN `id`, and poll the
[retrieve endpoint](/api-reference/kling/video-generation/retrieve-task) until the normalized
status is terminal.

## Error compatibility

GENGEN keeps its standard error envelope even when Kling rejects the upstream request:

```json theme={"dark"}
{
  "error_code": "provider.request_failed",
  "error": "Provider request failed",
  "error_params": {
    "provider": "kling",
    "status": 429,
    "upstreamCode": 1302
  }
}
```

Use the HTTP status and GENGEN `error_code` for application logic. `upstreamCode` is diagnostic
and can be used to distinguish the following Kling categories.

| Kling code range | HTTP status | Meaning | Client action |
| - | - | - | - |
| `1000`–`1004` | `401` | Upstream credential validation failed | Do not retry; contact GENGEN support if persistent |
| `1100`–`1102` | `429` | Upstream account or resource package unavailable | Retry later only when instructed |
| `1103` | `403` | Model or resource is not authorized | Do not retry unchanged |
| `1200`–`1201` | `400` | Invalid request parameter | Correct the request |
| `1202`–`1203` | `404` | Method, resource, or model not found | Check model and endpoint documentation |
| `1300`–`1301` | `400` | Policy or content-safety rejection | Change the input |
| `1302`–`1304` | `429` | Rate, concurrency, or network-policy limit | Retry with backoff when appropriate |
| `5000`–`5002` | `500`–`504` | Upstream internal error, unavailable service, or timeout | Retry with exponential backoff |

<Warning>
  Never branch on provider message text. It can change independently of the GENGEN API.
</Warning>

## Callback protocol

GENGEN registers its own callback URL with Kling and verifies every event before updating a task
or settling its wallet hold. Callback verification covers the exact raw body and the
`webhook-id`, `webhook-timestamp`, and `webhook-signature` headers. Events outside a five-minute
timestamp window are rejected, and multiple `v1` signatures are accepted during secret rotation.

This provider callback is an internal GENGEN integration surface; it is not a customer webhook.
Applications should continue polling the public task endpoint. Callback processing and polling
share the same idempotent task ID, so either path can safely observe the terminal result first.

<Note>
  Kling output URLs are retained by the provider for a limited period. Copy successful videos to
  storage you control when you need durable access.
</Note>

## Unsupported task deletion

The current Kling 3.0 task API does not expose cancellation or deletion. Calling the shared
`DELETE /contents/generations/tasks/{id}` route for a Kling task returns
`provider.operation_not_supported`; it does not release an active hold or pretend the remote task
was cancelled.
