Replit lets you build, deploy, and host applications directly in the browser. You can use OpenRouter with Replit in two ways:
For background on Replit’s managed AI options, see Replit’s AI Integrations documentation.
You’ll need an OpenRouter API key. Create one at openrouter.ai/keys and copy the key (it starts with sk-or-v1-).
By default, when Replit Agent detects that your prompt needs AI functionality, it uses Replit-managed credentials and bills usage to your Replit account. If you’d rather use your own OpenRouter account — for direct billing, a custom rate limit, or access to a wider set of models — you can bring your own API key.
When you submit your initial prompt to create a new app, include that you want to use your own OpenRouter API key. For example:
Build a chat app that uses my own OpenRouter API key.
In the Agent’s response, the provider name will appear without the “(Replit managed)” suffix, which indicates Agent will request your OpenRouter API key. Agent typically builds through the first checkpoint and then prompts you for the key.
When Agent detects that you want to add AI functionality to an existing app, it shows a confirmation prompt asking to use Replit AI Integrations with Replit-managed credentials. To use OpenRouter directly instead:
Agent will store the key as a Secret in your project (typically named OPENROUTER_API_KEY) and wire it into the generated code.
Usage made with your own OpenRouter API key is billed by OpenRouter, not by Replit. You can monitor spend and set per-key limits from the API Keys page.
If you’re writing code in a Replit App yourself (without going through Agent), add your OpenRouter API key as a project Secret so it’s available as an environment variable at runtime.
OPENROUTER_API_KEY.sk-or-v1-...).The secret is now available to your app as process.env.OPENROUTER_API_KEY (Node.js) or os.environ["OPENROUTER_API_KEY"] (Python). Secrets are not exposed in your source files and are scoped per project.
Once the secret is configured, you can call OpenRouter using any OpenAI-compatible SDK by pointing it at https://openrouter.ai/api/v1.
For framework-specific examples (Vercel AI SDK, LangChain, Anthropic SDK, and more), see the Frameworks and Integrations overview.
When you publish a Replit App as a Deployment, the Secrets you configure in your Replit App carry over to the deployed app. Update the OPENROUTER_API_KEY secret in the Deployment’s settings if you want to rotate keys without redeploying code.
For Teams and Enterprise organizations on Replit, your organization admin controls whether Replit AI Integrations is enabled. If it’s disabled — or if you prefer not to use Replit-managed credentials — every member can still bring their own OpenRouter API key using the steps above.