Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Code Review: Shaw/live ai pricing (#455)OverviewThis PR introduces a live AI pricing catalog — replacing hardcoded constants with a DB-backed catalog that syncs from external sources (Vercel Gateway, OpenRouter, FAL.ai, ElevenLabs). It adds an admin override endpoint, a public pricing summary endpoint, a cron refresh job, and a new 🔴 Critical Issues1. Failed video generation now refunds 100% of credits ( Previously a failed video attempt was charged - await reservation.reconcile(VIDEO_GENERATION_FALLBACK_COST);
+ await reservation.reconcile(0);2. case "seedance":
throw new Error("Seedance pricing parser is not implemented yet");The 3. All // No try/catch anywhere in this function
const videoCosts = await Promise.all(
SUPPORTED_VIDEO_MODELS.map(async (model) => { ... })
);Wrap each lookup in a 🟡 Medium Issues4. Eight fragile regex parsers for FAL.ai HTML scraping ( Models like throw new Error(`Unable to parse Veo pricing paragraph: ${paragraph}`);There's no fallback to the last known-good database price when a parse fails. The behavior should be: fail gracefully, log a warning, and keep serving the last valid price from the DB rather than blowing up the entire refresh run. 5. const externalCatalogCache = new Map<string, ExternalCacheValue>();This module-level Map is never pruned. In a long-running Node.js instance (Next.js on Vercel Node runtime), entries accumulate indefinitely. Add an eviction step when setting: before inserting, delete entries where 6. ElevenLabs pricing is a hardcoded snapshot, not live
7.
🟢 Positive Observations
Minor Nits
SummaryThe architecture is sound and the live-pricing direction is the right call long-term. The three issues to resolve before merging are: (1) clarify the intended behavior of failed video billing, (2) gate or remove the Seedance model until its parser is implemented, and (3) add error handling to the public |
…456) * fix: implement Seedance 2.0 pricing parser and add models to catalog Implement the seedance pricing parser that was throwing an unimplemented error, crashing the entire pricing refresh cron when Seedance models appeared in the catalog. Parser extracts per-second pricing from fal.ai model pages: - Seedance 2.0: $0.3034/second (720p) - Seedance 2.0 Fast: $0.2419/second (720p) Audio is included in the base price (no audio dimension needed). Also adds both models to SUPPORTED_VIDEO_MODELS in the definitions file. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: document public-only blob access limitation Vercel Blob only supports access: 'public' as of 2026-04. Added TODO comment explaining the limitation and noting that a proper fix requires an auth-gated proxy route to serve blob content with session validation. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: charge ~10% on failed video generation instead of full refund Shaw changed failed video reconciliation from partial charge to full refund (reconcile(0)), creating an abuse vector where users could trigger failures intentionally at zero cost while fal.ai still charges for the compute attempt. Restore partial charge at ~10% of quoted cost for all failure paths: - No video URL in response - Blob upload failure - General generation error Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: add error handling to /api/v1/pricing/summary endpoint Wrap each model cost lookup in try/catch so one failing fal endpoint (or any third-party catalog) won't 500 the entire public unauthenticated route. Failed lookups are filtered out and partial results returned with a warnings array. Categories with zero successful lookups are omitted from the response entirely. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: add is_public column to generations, filter explore gallery listRandomPublicImages() was returning ALL completed images across all users, leaking private generations in the explore/discover section. Added is_public boolean column (default false) via migration 0065. Updated the query to filter by is_public = true so only explicitly opted-in content appears in the explore gallery. Includes a partial index on is_public WHERE true for query performance. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: evict expired entries from third-partyCatalogCache to prevent unbounded growth The module-level third-partyCatalogCache Map was never pruned. While in practice only ~4 keys are used (gateway, openrouter, fal, elevenlabs), expired entries were never removed. Add eviction of expired entries before inserting new ones in getCachedExternalEntries. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: require authentication for image generation, remove anonymous fallback Anonymous users could generate images for free by hitting the endpoint without auth. The authenticateUser() function silently fell back to creating anonymous users who bypassed all credit checks. Now returns 401 if no valid session or API key is provided. Cleaned up all anonymous-specific code paths (isAnonymous checks, anonymous reservation creation for unauthenticated users). Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: add DB fallback when fal.ai HTML pricing parsers fail The 8+ fal.ai pricing parsers scrape HTML with regexes. If fal changes their page structure, the parsers throw and crash the entire fal catalog refresh. Now each model's parse is wrapped in try/catch. On failure, fall back to last known active DB entries for that model. If no DB fallback exists, log an error and return empty (other models still succeed). This prevents one broken model page from taking down pricing for all video models. Co-authored-by: wakesync <shadow@shad0w.xyz> * fix: move steward passthrough after bearerToken declaration bearerToken was referenced before its const declaration (temporal dead zone), causing a ReferenceError that crashed the middleware and redirected to /auth/error on every steward-authenticated request. Co-authored-by: wakesync <shadow@shad0w.xyz> --------- Co-authored-by: wakesync <shadow@shad0w.xyz>
… branch Brings in: - Shaw's live AI pricing catalog (PR #455) - Sol's 8 patches on top via PR #456: - Seedance 2.0 parser implemented + models added - Failed video charges 10% (was 100% refund abuse vector) - /api/v1/pricing/summary error handling - third-partyCatalogCache eviction - HTML parser fallback to DB - is_public column on generations (default false) - Anonymous image gen removed (require auth) - Blob access limitation documented This unblocks production from continuing to charge $0.05 flat on video generation. Co-authored-by: wakesync <shadow@shad0w.xyz>
No description provided.