Skip to content

Next.js app with fal.ai (images and video): AI launch checklist

Next.js apps call fal.ai (images and video) with your own API key, from server code, so fal.ai (images and video)'s own limits are your safety net. Of the 20 checks before you charge users, Next.js handles 0, partly handles 3, and leaves 17 to you.

Checked 12 Nov 2026 against each platform's docs; every fact links to its source.

How AI calls work in Next.js

Built-in AI
None unless you choose one. You call providers from route handlers or server actions with their SDKs or the AI SDK; Vercel AI Gateway is optional (same budgets, logs and reporting as v0).
Who pays
Each provider directly (or AI Gateway Credits at provider list price with no markup).

Keys and secrets

Where secrets live
Vercel project environment variables (Production / Preview / Development); .env files locally, which create-next-app adds to .gitignore.
Server-side by default?
'By default, environment variables are only available on the server.'
How keys end up in the browser
Prefixing an AI key with NEXT_PUBLIC_, which Next.js inlines into the JavaScript sent to the browser at build time; or committing .env.

The 20 checks, in Next.js

What Next.js does for you, and what to ask it (or your coding agent) to add. Tick them off in the interactive checklist.

Cost and abuse

  • You add it

    A spending cap per user

    Ask Claude Code or Cursor: 'In every route handler or server action that calls the provider, sum the user's cost today from ai_costs and return an error over $2.' If you use AI Gateway, add a project budget as a backstop.

    vercel.com ↗

  • Partly

    Rate limits on every AI endpoint

    Add a Vercel WAF rate-limit rule on your AI routes (all plans; one rule on Hobby) and have the agent add a per-user limit in code backed by Redis or Postgres.

    vercel.com ↗

  • Partly

    AI keys only on the server

    Next.js keeps non-NEXT_PUBLIC_ variables on the server and inlines NEXT_PUBLIC_ ones into the browser bundle, so have the agent grep for NEXT_PUBLIC_ on any AI key and keep every provider call in route handlers or server actions.

    nextjs.org ↗

  • You add it

    Retries capped, with a timeout

    Have the agent set an explicit retry cap (2) and a timeout on every SDK call and remove client-side retries.

    vercel.com ↗

  • You add it

    A budget alert at each AI provider

    Set a hard limit at each provider (OpenAI 'Enforce a hard limit', Anthropic spend limits, Gemini project spend cap, OpenRouter key limit, fal alerts); Vercel Spend Management only covers Vercel's own metered usage.

    vercel.com ↗

Charging for AI use

  • You add it

    Every AI call charged or deliberately free

    Have the agent list every provider call site, including background jobs and moderation, and mark each as charged or free on purpose.

    nextjs.org ↗

  • You add it

    Credits deducted on the server, after success

    Have the agent deduct credits in the same database transaction that saves the result, inside the route handler, with no client-writable balance.

    nextjs.org ↗

  • You add it

    Failed AI calls refunded

    Have the agent refund reserved credits with a reason on provider errors, timeouts, refusals and empty or invalid outputs.

    nextjs.org ↗

  • You add it

    One charge per request, even on a double click

    Have the agent add a client-generated request id with a unique constraint and return the saved result on repeats.

    nextjs.org ↗

A record of every AI result

  • You add it

    Each AI result stored with its feature, model, prompt version and settings

    Have the agent create ai_results with feature, model id reported by the provider, prompt version, params, input, user_id and provider request id (AI Gateway's logs help but aren't tied to your users).

    vercel.com ↗

  • You add it

    Retries and corrections saved next to the original, never over it

    Have the agent store retries and edits as new versioned rows linked to the original.

    nextjs.org ↗

  • You add it

    What users do next with each AI result, recorded on the server

    Have the agent add an ai_events table and a server action called from the existing Retry, Edit, Copy and Export buttons.

    nextjs.org ↗

What worked, for whom, at what cost

  • You add it

    Worked first time, per feature, model and prompt version

    Have the agent add an admin page with worked-first-time per feature, model and prompt version.

    nextjs.org ↗

  • You add it

    A cost record for every AI step

    Have the agent save an ai_costs row per call from the provider's usage field and one price table (or AI Gateway Generation Lookup).

    vercel.com ↗

  • You add it

    Wasted AI spend and real cost per result, per feature

    Have the agent build the wasted-spend and cost-per-working-result query from ai_costs and ai_events.

    nextjs.org ↗

  • You add it

    Who the AI fails for

    Have the agent save input traits on each result and split worked-first-time by them.

    nextjs.org ↗

Switching safely

  • Partly

    Prompts in version control, with version labels

    The app is already a git repo; have the agent move inline prompts into prompts/*.ts with version labels saved on each result.

  • You add it

    Model and prompt switchable by a flag

    Have the agent read model id and prompt version from a Vercel environment variable or database setting per feature, with a user-id-hashed split.

    nextjs.org ↗

  • You add it

    Real past requests to replay before a change

    Have the agent write a script that replays 50 anonymised past requests through any model and prompt version and saves results and cost.

  • You add it

    A plan for model shutdowns

    Have the agent centralise model ids in one config and write MODELS.md with each provider's retirement dates.

fal.ai (images and video) limits to set before launch

Billing model
Prepaid credits drawn down per use; each model has its own unit (per image or megapixel, per second of video or flat per video, per request or per GPU-second). Only successful outputs are billed; 5xx errors and queue wait aren't.
Where secrets live
Billing dashboard https://fal.ai/dashboard/billing (overall spend, invoices, payment history). Org admins (enterprise organizations) can set spending alerts; the menu location isn't stated.
Per-key or project cap
not found.
Auto top-up
not found.
Key scoping
Create keys at https://fal.ai/dashboard/keys with permission presets (API, SERVERLESS, DEPLOY, COMPUTE, BILLING, READONLY, FULL; legacy ADMIN and API scopes). A key can be limited to a list of models in the 'Allowed models' tab (set at creation, can't be changed) and can expire after 1 hour to 1 year. Keys are managed per team. Per-key spend limits: not found. Guidance on keeping FAL_KEY out of the browser: not on the key page read.
Rate limits
Concurrency, not requests per second: new accounts get 2 concurrent requests, rising automatically with paid invoices over the last four weeks up to 40 self-serve; more via sales. Requests are queued, not rejected; raw HTTP gets 429 concurrent_requests_limit with X-Fal-needs-retry: 1. Some high-demand models have extra limits. View at https://fal.ai/dashboard/usage-billing/concurrency.
Where usage shows
Billing dashboard for overall spend; per-model cost breakdowns and request-level detail via the usage and analytics Platform APIs or billing reports; pricing API GET https://api.fal.ai/v1/models/pricing?endpoint_id=... . Team members can see request metadata (endpoint, status, timing, cost); API-key submissions aren't tied to an individual member.

fal.ai ↗fal.ai ↗fal.ai ↗fal.ai ↗

Mistakes Next.js apps make at launch

  1. AI key prefixed with NEXT_PUBLIC_.

    Next.js inlines NEXT_PUBLIC_ values into JavaScript sent to the browser; Vercel reported over 17k v0 deployments blocked in July 2025 for exposed secrets and NEXT_PUBLIC_ misuse.

    nextjs.org ↗vercel.com ↗

  2. An unauthenticated or forgotten AI route.

    Vercel Community thread (2026): unexpected Anthropic and OpenAI usage traced to a likely leftover dev route; keys had to be rotated.

    community.vercel.com ↗

  3. Relying on an alert instead of a hard stop.

    OpenAI spend alerts don't stop traffic unless 'Enforce a hard limit' is on; Vercel Spend Management checks every few minutes and doesn't cap provider bills.

    developers.openai.com ↗vercel.com ↗

Questions

How do AI calls work in a Next.js app with fal.ai (images and video)?

Next.js apps call fal.ai (images and video) with your own API key, from server code, so fal.ai (images and video)'s own limits are your safety net.

Can Next.js cap AI spending per user?

You add it. Ask Claude Code or Cursor: 'In every route handler or server action that calls the provider, sum the user's cost today from ai_costs and return an error over $2.' If you use AI Gateway, add a project budget as a backstop.

Where should the fal.ai (images and video) key live in Next.js?

Partly. Next.js keeps non-NEXT_PUBLIC_ variables on the server and inlines NEXT_PUBLIC_ ones into the browser bundle, so have the agent grep for NEXT_PUBLIC_ on any AI key and keep every provider call in route handlers or server actions.

How do I stop one user running up my fal.ai (images and video) bill?

Add a per-user daily cap in your own code, checked before every AI call. Then set a limit at fal.ai (images and video) as a backstop: Billing dashboard https://fal.ai/dashboard/billing (overall spend, invoices, payment history). Org admins (enterprise organizations) can set spending alerts; the menu location isn't stated.

More checklists