ai newsDi., 1. Dez.

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

dev.toSonntag 02:56 · 29.11.2 Min. Lesezeit
Bild: dev.to

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.

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 Enter fullscreen mode Exit fullscreen mode Three rules make this safe:

The observable result is a 100% success rate from the caller's perspective: the request keeps moving until one route works.

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" ) ) Enter fullscreen mode Exit fullscreen mode 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.

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.

Quelle: dev.to (dev.to). Original öffnen