One Key, Seven Routes, Zero Manual Retries: Designing an AI Video API That Does Not Fail

The hardest part of shipping AI video is not generation. It is everything that happens when generation goes wrong.
Upstreams throttle. They reject aspect ratios without documenting it. They accept a job, go quiet for ninety seconds, and then never send a task ID. If your product calls one upstream directly, all of that becomes your outage.
We solved it by refusing to expose a single upstream at all.
The routing model
One public model code maps to a line group of seven independent upstreams. Each member has its own quota, protocol, and capability set. The submitter walks the group in order:
route 1 --rejected--> route 2 --timeout--> route 3 --ok--> result | | | +-- lg_failed[] +-- pinned, not failed +-- remote_task_id Three rules make this safe:
- Only explicit rejection counts as failure. A 12001 content-moderation rejection or an unsupported-resolution error is definitive. A timeout is not — the upstream may still be generating, so we pin the route and keep polling instead of paying twice.
- Failed routes are skipped, never retried in the same request. The group carries
lg_failed[]andlg_next_uid, so failover is deterministic and auditable. - Refund is a terminal operation with a lock. Credits are returned only when every route is definitively exhausted, and the refund update is atomic so concurrent pollers cannot double-refund.
The observable result is a 100% success rate from the caller's perspective: the request keeps moving until one route works.
What the caller writes
Nothing special. No fallback loop, no provider SDK, no retry policy:
import requests, time BASE = "https://aishow.uno/api/v1" r = requests.post( BASE + "/generate", headers={"Authorization": "Bearer " + API_KEY}, json={ "kind": "video", "model": "aishow-seedance2.5-720-506", "prompt": "Viking woman in golden hour, full-parameter cinematic shot", "duration": 5, "ratio": "16:9", }, ).json() task_id = r["id"] while True: t = requests.get(BASE + "/generate/" + task_id, headers={"Authorization": "Bearer " + API_KEY}).json() if t["status"] in ("success", "failed"): break time.sleep(3) print(t.get("result_url")) The failover, the polling, the result download, and the CDN upload all happen server-side. The clip above is a real output from that exact flow — Seedance 2.5 full-parameter, 5 seconds, generated for 5.9 RMB per 30-second clip on the flat-rate tier.
Design notes you can steal
- Separate "unknown" from "failed." Most retry bugs come from treating ambiguity as failure.
- Persist routing state in the task row, not in process memory. Workers die; the group state must survive.
- Make refund idempotent with a conditional UPDATE. Concurrent pollers will race.
- Expose one stable model code and let the server own the messy multi-provider topology.
Try the endpoint
Everything is at https://aishow.uno: register, grab a key, and the model list at https://aishow.uno/api/v1/models.php shows what is live. Docs are at https://aishow.uno/openapi.php.
I maintain the routing layer — ask me anything about failover semantics in the comments.