DEV Community

Jason Wei
Jason Wei

Posted on Fully Autonomous

What an AI Video Client Should Do When a Create Request Times Out

A timeout on a video-generation request leaves the client with an uncomfortable question: did the server create a job before the response disappeared? If creating the job consumes credits, a blind retry may create a second job.

I work on Danceo, an AI dance-video product. This article uses its documented API as an example and describes client-side design choices; it does not claim that every suggested safeguard exists in the service. AI helped draft this post.

The two phases

A client can first call GET /api/v1/templates to obtain an available template ID and GET /api/v1/credits to check the account balance. The creation endpoint is POST /api/v1/videos. It accepts a portrait URL, template ID, subject type and output duration, and returns a job ID, processing status and cost information.

Keep the API key on a trusted backend and pass it as a Bearer token. The API uses listed templates; do not assume that it accepts arbitrary reference-video URLs. Source photos must be authorized and accessible to the service. Danceo prohibits real minors' likenesses.

A successful creation response gives the client a stable handle: save job_id with the correct user's record, then query GET /api/v1/videos/{job_id}. Querying an existing job is a different operation from creating another one.

Three outcomes, not two

For the creation step, model at least these outcomes:

  1. Accepted: the response contains the task identifier. Persist it and begin status checks.
  2. Definitively rejected: the response says the request could not be accepted. Show a useful error and let the user correct the input.
  3. Unknown: a timeout or connection loss prevented the client from learning the result. Avoid treating this as a confirmed rejection.

In the third case, explain the uncertainty and reconcile against whatever task history is available to the user before attempting another creation. Whether an idempotency key is supported must be verified from the current API contract. Do not describe retries as safe merely because the network request failed locally.

Poll with restraint

Danceo's documentation describes a best-effort two-second minimum interval for generation and status requests per account and client IP. If the service returns HTTP 429, respect Retry-After. A client can add bounded backoff and allow the user to return later, rather than continuously polling a forgotten browser tab.

A status lookup can fail independently of the underlying job. Keep a temporary transport error distinct from a confirmed generation failure. Before any chargeable submission, show the user the current cost information and obtain their decision; do not infer the price solely from the account balance.

Review the artifact, not only the status

Completion means a result is available, not that it is ready to publish. A human should check identity, body and hand artifacts, framing, and the rights to the source media. Motion can differ from the reference. Check the current Danceo integration documentation before implementing a client; this article is not an end-to-end test of a paid render.

The useful design principle is to preserve uncertainty instead of hiding it. A clear “we do not yet know whether the task was created” is better than silently charging twice.

Top comments (0)