This tutorial shows how to connect OpenAI to a Replit project using Replit's built-in AI integration, so you can build AI-powered features without leaving your workspace.
Notes:
- The built-in OpenAI integration (Replit-managed) requires a paid Replit plan and bills usage through your Replit credits.
- When the Agent detects an OpenAI dependency, it will display a confirmation prompt showing "OpenAI (Replit managed)." Click Approve to let Replit handle the API credentials automatically.
- See How to Set Environment Variables in Replit for more on Secrets.
- Sign in at replit.com and open the project you want to add OpenAI to, or click + Create Something New to start a fresh one.
- In the Agent prompt field, describe what you want to build and mention OpenAI directly - for example: Build a client briefing tool for NEPS Corp that takes a project name and returns a short AI-generated summary using OpenAI. Click the Arrow button to run.
- The Agent generates your project files and wires up the OpenAI connection. Wait for the build to complete.
- Click Run to launch your app. Test it in the Webview tab - for example, enter "Q3 Budget Review" as the project name and confirm the AI-generated summary appears correctly.
- To swap to your own API key at any time, open the Secrets pane from the Tools menu, add a secret named OPENAI_API_KEY, and paste your OpenAI key as the value. The Agent will use your key instead of Replit-managed credentials going forward.
.gif)
