Replit app with fal.ai (images and video): AI launch checklist
Replit 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, Replit handles 0, partly handles 4, and leaves 16 to you.
Checked 12 Nov 2026 against each platform's docs; every fact links to its source.
How AI calls work in Replit
- Built-in AI
- Yes: Replit AI Integrations, managed access to OpenAI (GPT text and reasoning, gpt-image-2, gpt-audio, gpt-4o-transcribe), Anthropic (e.g. claude-opus-5, claude-sonnet-5), Google Gemini (e.g. gemini-3.5-flash), Grok, and OpenRouter (200+ models). Text, image and audio output; no video. fal is not included.
- How calls run
- Agent uses Replit-managed credentials when it builds; Replit handles provider auth. Env var names, base URL and whether calls must be server-side: not stated in the docs.
- How to turn it on
- Agent asks to 'Approve' (Replit-managed) or 'Dismiss' (use your own key). Starter plan: disabled (own key only). Core: available. Pro and Enterprise: disabled by default; an org admin enables it in organization settings.
- Who pays
- Managed usage is billed at the provider's public API price and deducted from Replit credits; usage appears on the usage page per app. Your own key is billed by the provider. No markup mentioned.
Keys and secrets
- Where secrets live
- Secrets tool (tools pane → Setup), encrypted and exposed to the app as environment variables; account-level secrets in Account Settings → Account Secrets; published apps have separate Production app secrets under Publishing → Adjust settings. Non-sensitive values go in Configurations, which can differ per environment.
- Server-side by default?
- Replit's secrets docs don't say. Multiplayer collaborators can see values; non-owner org members see names only but 'can access their values by printing the environment variables'.
- How keys end up in the browser
- Agent-generated code reading a key in a Vite/React frontend (VITE_ variables are bundled into the browser) or embedding it in client JS; reported by scanner vendors, not by Replit docs.
The 20 checks, in Replit
What Replit does for you, and what to ask it (or your coding agent) to add. Tick them off in the interactive checklist.
Cost and abuse
- Partly
A spending cap per user
Manage limits blocks usage-based services account-wide (the docs don't say whether AI Integrations is included), so ask Agent: 'Add an ai_usage table in Postgres and, in the server route, check the user's cost today before each AI call and return a daily-limit error over $2.'
- You add it
Rate limits on every AI endpoint
Replit documents no per-user rate limiting, so ask Agent: 'Add rate-limiting middleware to every route that calls AI, keyed by user id or IP, stored in Postgres, returning 429 after 10 calls a minute.'
- Partly
AI keys only on the server
Replit-managed AI Integrations need no key and your own keys live in the Secrets tool, but the docs don't cover frontend exposure, so ask Agent: 'Confirm no AI key or VITE_ variable is read by client code and every AI call goes through a server route.'
- You add it
Retries capped, with a timeout
Ask Agent: 'Wrap every AI call in the server with a 30-second timeout and at most 2 retries on 429 and 5xx, and remove retries in the frontend.'
- Partly
A budget alert at each AI provider
For Replit-managed AI the backstop is Replit's usage limit and service shutdown limit (Manage limits); with your own key set the limit at the provider.
Charging for AI use
- You add it
Every AI call charged or deliberately free
Ask Agent to list every route and scheduled job that calls AI Integrations or another provider and mark each as charged or free on purpose.
- You add it
Credits deducted on the server, after success
Ask Agent: 'Create user_credits in Postgres and deduct in the same transaction as inserting ai_results inside the server route; the client never sends an amount.' Schema changes reach production when you publish.
- You add it
Failed AI calls refunded
Ask Agent to refund reserved credits with a logged reason when an AI call errors, times out, is refused, or returns empty or invalid output.
- You add it
One charge per request, even on a double click
Ask Agent to send a request id from the client, add a unique constraint on ai_results.request_id, return the saved result on a repeat, and disable the button while it runs.
A record of every AI result
- You add it
Each AI result stored with its feature, model, prompt version and settings
Replit shows AI spend per app, not per call, so ask Agent to create ai_results with feature, model, prompt_version, params, input, user_id and provider request id, written by the server.
- You add it
Retries and corrections saved next to the original, never over it
Ask Agent to store retries and edits as new ai_results rows with parent_id and version, never updating the original.
- You add it
What users do next with each AI result, recorded on the server
Ask Agent to add an ai_events table and a POST /api/ai-events route called from the Retry, Edit, Copy and Export buttons.
What worked, for whom, at what cost
- You add it
Worked first time, per feature, model and prompt version
Ask Agent for an admin page showing worked-first-time by feature, model and prompt version for 7 and 30 days.
- You add it
A cost record for every AI step
Ask Agent to compute each call's cost from the response's usage at the provider's public API price (what Replit charges for managed usage) and save an ai_costs row, retries included.
- You add it
Wasted AI spend and real cost per result, per feature
Ask Agent for an admin query joining ai_costs and ai_events for total, wasted and cost-per-working-result, per feature and model.
- You add it
Who the AI fails for
Ask Agent to save language, length band, input kind, plan and new-user flag with each result and show worked-first-time per trait.
Switching safely
- You add it
Prompts in version control, with version labels
Ask Agent to move prompts into a server/prompts/ folder with version labels saved on each result.
- Partly
Model and prompt switchable by a flag
Put the model id and prompt version in the Secrets tool's Configurations (separate published-app and testing values) or a settings table that the server reads per request; whether a configuration change applies without republishing: not found.
- You add it
Real past requests to replay before a change
Ask Agent for a script that replays 50 anonymised past requests through a chosen model (any AI Integrations model works without new keys) and saves results and cost next to the originals.
- You add it
A plan for model shutdowns
Ask Agent to list every model id (e.g. claude-sonnet-5, gemini-3.5-flash) used in the app, move them to one config, and write MODELS.md.
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.
Mistakes Replit apps make at launch
Letting the agent act on production data.
July 2025: during SaaStr founder Jason Lemkin's experiment, Replit's agent deleted a production database during a code freeze; Replit's CEO called it 'unacceptable' and Replit separated development and production databases. Replit docs now say Agent can't modify the production database.
AI key reaching client JavaScript even though it's stored in Secrets.
Scanner vendors report Agent-generated code embedding keys in client-side JS or VITE_ variables, and keys persisting in forks and history; Replit's secrets docs don't address frontend exposure.
Assuming AI usage is capped or visible per user.
AI Integrations bills Replit credits per app; the spend docs don't say whether AI Integrations usage counts toward usage limits, and there is no per-end-user or per-call view. A third-party post describes a $607 Replit bill from runaway AI costs (not verified).
Questions
How do AI calls work in a Replit app with fal.ai (images and video)?
Replit 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 Replit cap AI spending per user?
Partly. Manage limits blocks usage-based services account-wide (the docs don't say whether AI Integrations is included), so ask Agent: 'Add an ai_usage table in Postgres and, in the server route, check the user's cost today before each AI call and return a daily-limit error over $2.'
Where should the fal.ai (images and video) key live in Replit?
Partly. Replit-managed AI Integrations need no key and your own keys live in the Secrets tool, but the docs don't cover frontend exposure, so ask Agent: 'Confirm no AI key or VITE_ variable is read by client code and every AI call goes through a server route.'
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.