Replit app with OpenAI: AI launch checklist
Replit apps call OpenAI models through Replit AI Integrations: no OpenAI 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
- 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.
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 OpenAI key later, these are the limits to set at OpenAI:
- Organisation limit
- https://platform.openai.com/settings/organization/limits → Spend → Edit spend limit → Monthly spend limit → turn on 'Enforce a hard limit' → Save.
- Project limit
- https://platform.openai.com/settings/ → (project) Limits → Spend → Edit spend limit → same steps.
- What happens at the limit
- A spend alert only notifies; traffic continues. A hard limit makes requests return 429 with project_spend_limit_exceeded or organization_spend_limit_exceeded. Enforcement isn't instantaneous, so spend can slightly exceed the limit. Separate codes: organization_usage_limit_exceeded (OpenAI-assigned tier limit) and credit_balance_exhausted (prepaid credits gone).
- Note
- Community threads in 2025–2026 report hard caps disappearing and returning; the current official guide documents them.
- Key scoping
- Keys belong to projects; project service-account keys are unique to their project. Key permissions: All, Restricted or Read Only. Per project, owners can choose allowed models and set a rate limit per model under Limits. (From OpenAI help-center snippets; the page returned 403 to the fetcher.)
- Rate limits
- Set at organization and project level, not per user. Tiers: Free ($100/month usage limit, allowed geography), Build ($5 total credit purchases, $500/month), Launch ($100, $5,000/month), Grow ($500, $200,000/month); upgrades automatically. View at Settings → Organization → Limits (platform.openai.com/settings/organization/limits). The current page no longer uses 'Tier 1–5' names.
- Where usage shows
- Usage at https://platform.openai.com/settings/organization/usage, grouped by project and model. Per-API-key grouping is reported by a third-party summary of OpenAI's changelog, but community threads say some accounts only see project/model; not confirmed in official docs.
developers.openai.com ↗developers.openai.com ↗help.openai.com ↗help.openai.com ↗
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 OpenAI?
Replit apps call OpenAI models through Replit AI Integrations: no OpenAI 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 OpenAI 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.'