Building a Multi-Model AI Video & Image Studio (Wan 3.0, Veo 3.1, Sora 2 & Seedance 2.5) with FastAPI, SQLite & Stripe A developer built Wan3 Studio, a pay-as-you-go web workspace that routes requests across 11 generative video and image models—including Wan 3.0, Veo 3.1, Sora 2 and Seedance 2.5—from a single Docker container running FastAPI, SQLite in WAL mode and Stripe Checkout on an ARM64 VPS behind Cloudflare Tunnel. To prevent charging users for failed renders, the app runs credit deductions and idempotent refunds inside atomic BEGIN IMMEDIATE transactions, using a refunded flag to guarantee race-free accounting without external locks. The developer also recommends two-stage generation, using image models such as Seedream 5.5 or Flux 2 Pro to produce first frames before video generation, to improve consistency. If you have ever tried building short-form videos, product commercials, or image-to-video prototypes with modern generative video models, you have probably run into the same friction I did: every flagship model lives behind a different monthly subscription. Instead of paying $100+/month across five separate portals, I built Wan3 Studio https://wan-3.dev/ —a lightweight, pay-as-you-go web workspace backed by a single Docker container FastAPI + SQLite WAL + Stripe Checkout that lets creators switch across all 11 flagship video and image models with one non-expiring credit balance. I intentionally kept the stack minimal so the entire production app runs smoothly on a single ARM64 VPS behind Cloudflare Tunnel: httpx async upstream routing + itsdangerous signed HTTP-only session cookies WAL mode with BEGIN IMMEDIATE transactions for race-free credit deduction and idempotent order fulfillment AI video generation is asynchronous and occasionally fails upstream safety filter rejections, provider timeouts, or overloaded queues . Charging users when a render fails is the fastest way to lose trust. To make credit accounting bulletproof in SQLite without external Redis locks, every deduction and refund runs inside an atomic BEGIN IMMEDIATE transaction with an idempotency flag refunded = 0 - 1 : php def deduct credits user id: int, cost: int - tuple bool, int : now = int time.time with get conn as conn: conn.execute "BEGIN IMMEDIATE" row = conn.execute "SELECT credits FROM users WHERE id = ?", user id, .fetchone if not row or row "credits" < cost: conn.execute "ROLLBACK" return False, row "credits" if row else 0 new bal = row "credits" - cost conn.execute "UPDATE users SET credits = ?, updated at = ? WHERE id = ?", new bal, now, user id conn.execute "COMMIT" return True, new bal def refund task credits task id: str - bool: """Idempotently refund 100% of credits if an upstream video render fails.""" now = int time.time with get conn as conn: conn.execute "BEGIN IMMEDIATE" t = conn.execute "SELECT user id, cost credits, refunded FROM tasks WHERE id = ?", task id, .fetchone if not t or t "refunded" or t "cost credits" <= 0: conn.execute "ROLLBACK" return False conn.execute "UPDATE tasks SET refunded = 1, updated at = ? WHERE id = ?", now, task id conn.execute "UPDATE users SET credits = credits + ?, updated at = ? WHERE id = ?", t "cost credits" , now, t "user id" , conn.execute "COMMIT" return True This guarantees two invariants: One pattern that dramatically improves AI video consistency is two-stage generation : | Model | Provider | Best Use Case | |---|---|---| | Wan 3.0 / Wan 3.0 Prime | Alibaba Wan | Smooth camera movement, realistic street & cinematic shots | | Veo 3.1 / Veo 3.1 Fast | Google DeepMind | Commercial product lighting + synchronized native audio | | Sora 2 | OpenAI | Multi-beat narrative storytelling & imaginative physics | | Seedance 2.5 | ByteDance | E-commerce ads, lookbooks, stable human motion | | Vidu Q3 Pro | Vidu | Stylized anime shorts & consistent character animation | | Seedream 5.5 / Flux 2 Pro | ByteDance / BFL | High-resolution first frames & editorial portraits | Happy to answer questions about FastAPI async polling, Stripe webhook verification without heavy SDKs, or video model prompt engineering in the comments