Running Intro to Mistral AI locally
Use this page to run the extracted Intro to Mistral AI project on your computer. You adapt its Scrimba-only API-key lookup for Vite, start the project, and find the function-calling result in the browser console. The key handling here matches the pattern in Running Chef Claude locally, so the two pages solve the same problem for different providers.
What you need first
Install a supported LTS version of Node.js. Node 24 is recommended and includes npm.
Check that Node and npm are available:
$ node --version
v24.18.0
$ npm --version
11.18.0You also need a Mistral API key. If you do not have one, follow Mistral's Studio key setup, create a key, and copy it when it is shown. You will add it to the local environment file later on this page.
Open the project folder
Open a terminal in the extracted folder containing package.json:
$ cd path-to-your-downloaded-projectpackage.json, and run every npm command from there. The environment file you create later belongs in that same folder. The most common reason a setup fails at this point is running the commands from the wrong folder, and one command confirms which folder you are in. Make the API key work in Vite
The downloaded index.js reads the key with Scrimba's environment syntax:
const client = new MistralClient(process.env.MISTRAL_API_KEY)A stock Vite browser project does not provide that process.env value. Change the line to:
const client = new MistralClient(import.meta.env.VITE_MISTRAL_API_KEY)Create .env beside package.json:
VITE_MISTRAL_API_KEY=your-mistral-api-key-hereCreate .gitignore beside it and add:
.env
node_modules/The VITE_ prefix is required because Vite exposes only specially prefixed environment variables to browser code. Adding a key to Git by accident is not undone by deleting the file, because the value stays in the repository history, and the Git handbook covers the wider habit in ignoring files and good habits.
This key is visible in the browser
The VITE_ prefix deliberately puts the API key into the frontend bundle. Use a temporary, restricted key for local learning only. Never deploy or share this version, and never commit .env. A production application needs a backend or serverless function that keeps the key on the server.
.env, and keep that file out of Git. The browser can still read this key, so use a key you are willing to delete afterwards. This exposure is a limitation of frontend-only projects, not an error in your setup. Install and run the project
Install the downloaded dependencies and start Vite:
$ npm install
$ npm startOpen the exact Local URL Vite prints, usually http://localhost:5173/. In the function-calling lesson, open your browser's developer tools and select Console. A returned Mistral response there is the visible success result; the lesson does not render that result on the page.
Restart Vite after changing .env. Stop it with Ctrl+C.
npm install, then npm start, and open the Local URL it prints. Then open the browser Console, because the function-calling lesson prints its answer there rather than on the page. An empty-looking page is the expected result, not a failure. Troubleshooting
process is not defined: The Scrimba-style environment read remains in index.js. Replace it with the import.meta.env.VITE_MISTRAL_API_KEY form above and restart Vite.
The key is undefined or authentication fails: Confirm the exact VITE_ variable name, make sure .env is beside package.json, and restart the project. Check that the key is still active in your Mistral account.
The model is unavailable or the SDK request fails: The downloaded ZIP pins an older Mistral SDK and asks for mistral-large-latest. Provider SDKs and model catalogs change. Compare the model ID in index.js against the models listed in Mistral's documentation, and change the ID before you change the pinned SDK version, since a renamed model is the more common cause.
Nothing appears on the page: Open the browser console. The representative function-calling lesson logs its final response there instead of rendering it in the page.
If you want to publish this project: Do not publish this frontend-only version. Move the Mistral call and credential to a backend first.
VITE_ name, where .env sits, the model ID, and the browser Console, then restart. Work through those one at a time instead of changing several things at once. Do not publish this version, however well it runs on your machine. 
