Running Agents locally
Use this page to run an extracted Agents project on your computer. The ReAct loop, function-calling loop, and final interface use the same Vite setup, but they show their results in different places. Update the OpenAI key lookup and legacy model ID before starting the milestone you have.
What you need first
Install a supported LTS version of Node.js. Node 24 is recommended and includes npm; the export is a Vite project, so Node and npm cover all the tooling it needs.
You also need an OpenAI API key with billing and model access enabled. Model access is set per project in the OpenAI dashboard: the project your key belongs to must allow the model you configure below. The key itself goes into a .env file in a later step.
Open and install the project
Open a terminal in the extracted folder containing package.json, then install the packages:
$ cd path-to-your-downloaded-project
$ npm installpackage.json and run npm install there. Every later command on this page happens in that same folder. Keeping one terminal open in that folder saves you from losing track of where you are, which happened to me constantly in my first month. Update the key and model
In index.js, change:
apiKey: process.env.OPENAI_API_KEY,to:
apiKey: import.meta.env.VITE_OPENAI_API_KEY,Vite reads environment values through import.meta.env; the same repair appears in Running Embeddings and Vector Databases locally, which adapts a similar course export.
The course snapshots use legacy model IDs such as gpt-3.5-turbo, gpt-3.5-turbo-1106, and gpt-4-1106-preview. For these course examples, replace the model value in your extracted index.js with gpt-4o-mini:
model: "gpt-4o-mini",Create .env beside package.json:
VITE_OPENAI_API_KEY=your-openai-api-keyCreate .gitignore in the same folder:
.env
node_modules/The .gitignore keeps your key out of any repository you create from this folder; ignoring files and good habits explains why that matters.
This learning setup exposes the key
The OpenAI SDK is intentionally running in the browser, and Vite places the key in the frontend bundle. Use a temporary, restricted key only. Do not deploy or share this version. Production agents need a backend.
index.js, put your temporary key in .env, and keep that file out of Git. This learning version shows the key to the browser on purpose, so use a key you can cancel the moment you finish this project. Never use a key that anything else depends on. Run the project
$ npm startOpen the exact Local URL printed by Vite. For a console-only milestone, open your browser's developer tools and select Console. The ReAct and function loops print their progress and response there. In the UI milestone, send a message and look for the response in the page. Stop Vite with Ctrl+C.
npm start and open the exact Local URL Vite prints. For the earlier milestones the output appears in the browser's Console, so a page that looks empty can still be running correctly. Press Ctrl+C to stop when you finish. Troubleshooting
process is not defined: Search index.js for the remaining process.env.OPENAI_API_KEY and replace it with the Vite form above.
A legacy model is unavailable: Confirm that every model field uses a current model available to your OpenAI project. The downloaded milestones can contain different legacy IDs.
The page looks empty: The earlier milestones report progress in the developer console rather than the page. Use the final UI lesson if you want a visible chat interface.
Authentication or quota error: Check that .env is beside package.json, restart Vite, and confirm billing and key access in the OpenAI account.
process is not defined means the key lookup still needs changing, an empty page usually means the output is in the Console, and an authentication error points at the key or the account. Each one has a single fix. Work through them calmly, one at a time. 
