Running Context Engineering locally
Use this page to run the summarization challenge you extracted from the Context Engineering module and watch it summarize a long conversation with your own OpenRouter key. The code runs as downloaded: you install the packages, add one .env file with your key and a model, and start it.
What you need first
Install a supported LTS version of Node.js. Node 24 is recommended and includes npm. The project uses Vite 7, which needs Node 22.12 or newer.
Check that both commands work. Your version numbers may be different:
$ node --version
v24.18.0
$ npm --version
11.18.0If node --version prints anything below v22.12.0, install Node 24 before you continue.
You also need an OpenRouter API key and a little credit on your OpenRouter account, because the app asks OpenRouter for every summary and reply. Create a key you will delete when you are done, and give it a low credit limit when you create it: this project calls OpenRouter straight from the browser, so the key ends up in the page.
node --version prints v22.12.0 or higher. Then add a little credit to your OpenRouter account (a dollar covers many summaries) and create a key with a low credit limit. That one key is all this project needs.
Install the packages
Open a terminal in the extracted folder. It is the one containing package.json and main.js:
$ cd path-to-your-extracted-project
$ npm cinpm ci installs exactly the versions listed in package-lock.json. npm finishes by reporting how many packages it added:
added 29 packages, and audited 30 packages in 6snpm may also report vulnerabilities and suggest npm audit fix. Leave them for now: the fix can change the package versions the course was built on. npm may also warn about install scripts; that changes nothing here.
package.json, then run npm ci. npm ends by saying how many packages it added, and a node_modules folder appears. If npm says it cannot find package.json, you are in the wrong folder.
Add your key and model to .env
The project reads two values: OPENROUTER_KEY and MODEL_ID. Scrimba's editor fills them in for you; on your computer they go in a file. Create .env beside package.json:
OPENROUTER_KEY=your-openrouter-key-here
MODEL_ID=mistralai/ministral-3b-2512Keep both names exactly as shown, with no VITE_ in front: the project's vite.config.js reads these two names and hands them to the browser code. mistralai/ministral-3b-2512 is a low-cost model on OpenRouter. Any OpenRouter model ID works; copy it exactly.
Create .gitignore beside package.json and add:
.env
node_modules/A key that reaches a Git repository stays in its history even after you delete the file. The Git handbook covers the habit in ignoring files and good habits.
This key is visible in the browser
vite.config.js writes both values into the code it sends to the browser, so anyone who opens this page can read your key. Keep this version on your own computer: never deploy or share it, and never commit .env. A version you publish needs a backend or serverless function that keeps the key on the server.
.env next to package.json with two lines: your key after OPENROUTER_KEY= and the model after MODEL_ID=. Then list .env in .gitignore so Git never saves it. You don't need to change any JavaScript file.
Start the app and send a message
Start the development server:
$ npm startVite prints the address to open:
VITE v7.2.2 ready in 157 ms
➜ Local: http://localhost:5173/Open the exact Local address. The page opens on a long conversation that is already there, with the counters below it showing 26294 total tokens and 26294 context tokens. The app summarizes once the context passes 20,000 tokens, so your first message is enough.
Type any message and send it. The app shows Summarizing conversation while OpenRouter writes the summary. When it works, a Context Summary card appears under the counters (click it to read the summary), the context tokens count drops well below the total, and the reply to your message appears.
If you downloaded the challenge before finishing splitForSummary and generateSummary in summary.js, your first message gets stuck here: the app calls both as soon as it summarizes, and the console shows why.
If Summarizing conversation stays on screen and the send button stays grey, open your browser's developer tools (F12, or Cmd+Option+J in Chrome on a Mac) and read the Console tab. The reason is printed there, not on the page; the troubleshooting below matches each message. A red 404 for favicon.ico is harmless.
You don't need to restart anything after changing .env: when you save it, Vite restarts itself and the open page reloads with the new values. Stop the project with Ctrl+C.
npm start, open the Local address, and send any message. Wait for the Context Summary card and the reply. If it stays on Summarizing conversation, open the Console in your browser's developer tools and look for the red error that mentions OpenRouter or the API key.
Troubleshooting
The console says OPENROUTER_KEY env variable is not set, then OpenRouter API key is missing: The browser has no key. Check that .env is beside package.json and that the names are exactly OPENROUTER_KEY and MODEL_ID, then save it. The page reloads by itself.
The console shows 401 with User not found. or Missing Authentication header: The key reached OpenRouter, but OpenRouter did not accept it. Copy it again from your OpenRouter account and check that it has not been deleted. Missing Authentication header usually means .env still holds the example text instead of your key.
The console shows 402: The key works, but your account or the key's credit limit has no credit left. Add credit in OpenRouter, or raise the key's limit, then reload the page and send again.
The console says the model is not valid or not found: Check the MODEL_ID line in .env against the model's page on OpenRouter, letter for letter, including the part before the slash.
401 or a 402, and match it to a bold line above. After you edit .env and save it, wait for the page to reload, then send another message. 
