Skip to content

Replit app with OpenRouter: AI launch checklist

Replit apps call OpenRouter models through Replit AI Integrations: no OpenRouter account or key, and usage is billed through Replit AI Integrations. 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

  • Replit partly handles it

    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.'

    docs.replit.com ↗

  • 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.'

    docs.replit.com ↗

  • Replit partly handles it

    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.'

    docs.replit.com ↗

  • 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.'

    docs.replit.com ↗

  • Replit partly handles it

    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.

    docs.replit.com ↗

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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

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.

    docs.replit.com ↗

  • Replit partly handles it

    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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

  • 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.

    docs.replit.com ↗

Spending limits in Replit

Spending caps
Usage limits beyond monthly credits: Settings → Usage → Account usage → Manage limits (Core) or Usage page → Account usage → Manage limits (orgs); blocks usage-based services until next cycle. A 'service shutdown limit' suspends services. Org budgets in $500 increments; per-member limits on Enterprise. Whether AI Integrations usage counts: not stated. Org admins can disable Replit-managed AI integrations in Advanced settings.
Rate limiting
not found.
Cost per user
Usage page (replit.com/usage) filters by date, resource, project, workspace, group or member, near real time; AI Integrations usage broken down per app. Nothing per end user.
Logs of AI calls
Deployment Logs tab with real-time output and filters (errors only, search, date); retention stated as 7 days on one page and 30 days on another. AI Integrations docs describe no request logs.
Server functions
Autoscale, Reserved VM and Scheduled Deployments (cron-style, with run history in a Schedule tab; timeouts configurable).
Database
PostgreSQL added by Agent; production databases run PostgreSQL 16/17 on Neon; Agent can't modify the production database, and schema changes from development are applied at publish.

If you switch to your own OpenRouter key later, these are the limits to set at OpenRouter:

Per-key limit
Key dialog → 'Key limit' → 'Credit limit', reset interval and 'Include BYOK usage in limit' (toggle appears only with BYOK keys configured). API: PATCH https://openrouter.ai/api/v1/keys/{key_hash} with limit (USD), limit_reset (daily, weekly, monthly; unset = lifetime; resets at midnight UTC) and include_byok_in_limit (default false).
When a key hits its limit
Conflicting docs: the capping guide says requests fail with 403 'Key limit exceeded'; the limits reference says over-limit requests return 402 with limit_source openrouter_key_limit (or openrouter_guardrail_budget / openrouter_workspace_budget). Test before relying on either.
Workspace and guardrails
Workspace budget: one pooled cap for all members and keys. Guardrail budgets: per member or per key, daily/weekly/monthly; 'the first limit reached blocks the request'; the lower of key limit and member guardrail wins.
Account balance
Prepaid credits; an 'in-flight spending budget' (a fraction of balance) can fail paid requests with 402 even when balance is positive; a negative balance can error even free models.
Alerts and top-up
Low-balance alerts and auto top-up: not found in the pages read.
Key scoping
Per-key credit limits and per-key guardrails (model, provider, ZDR and data-region policy). Keys are owned by a member or a workspace; spend is attributed to the key's creator, so per-person enforcement needs one key per person. Management API key can create keys (POST /api/v1/keys).
Rate limits
Free model variants (':free'): 20 RPM; 50 requests/day if under 10 credits ever purchased, 1,000/day at 10+. Paid models: 'no platform-level request cap' (upstream provider limits still apply). Key-management endpoints 10,000 requests/day. Cloudflare DDoS protection blocks dramatic excess.
Where usage shows
Activity page filters by API key, model, provider and user; export CSV or PDF grouped by Model, API Key or Creator. GET /api/v1/activity (management key, last 30 days) filters by api_key_hash. GET https://openrouter.ai/api/v1/key returns usage, usage_daily, usage_weekly, usage_monthly, limit_remaining and applicable budgets for the calling key.

openrouter.ai ↗openrouter.ai ↗openrouter.ai ↗openrouter.ai ↗

Mistakes Replit apps make at launch

  1. 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.

    fortune.com ↗docs.replit.com ↗

  2. 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.

    vibeappscanner.com ↗vibe-eval.com ↗docs.replit.com ↗

  3. 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).

    docs.replit.com ↗docs.replit.com ↗blog.vibecoder.me ↗

Questions

How do AI calls work in a Replit app with OpenRouter?

Replit apps call OpenRouter models through Replit AI Integrations: no OpenRouter account or key, and usage is billed through Replit AI Integrations.

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 OpenRouter 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.'

More checklists