Running Multimodality locally
Use this page to run either extracted Multimodality project: image generation or image understanding. Both need the same Vite key change and the same OpenAI SDK update. After that, follow the repair for the project you have. That key change is the one every extracted course project needs; Running Chef Claude locally applies it to a React project with two provider routes.
What you need first
Install a supported LTS version of Node.js. Node 24 is recommended and includes npm.
Check that both commands work:
$ node --version
v24.18.0
$ npm --version
11.18.0You need an OpenAI API key with billing and access to the model you use. Image generation access can require organization verification.
Use a temporary key with a low spending limit. Both projects make paid OpenAI requests from browser code, so anyone who opens the browser's developer tools can read the key.
Open and prepare the project
Open a terminal in the extracted folder containing package.json:
$ cd path-to-your-downloaded-project
$ npm install
$ npm install openai@latestThe second install updates the old course SDK before using current image APIs.
Create .env and .gitignore beside package.json:
VITE_OPENAI_API_KEY=your-openai-api-key.env
node_modules/The .gitignore entries keep two things out of any repository you create from this folder: your key, and the node_modules folder that npm can rebuild at any time. Ignoring files and good habits covers the wider habit.
In index.js, change the OpenAI client key from:
apiKey: process.env.OPENAI_API_KEY,to:
apiKey: import.meta.env.VITE_OPENAI_API_KEY,The key is included in the frontend
This is acceptable only for temporary local learning with a restricted key. Image requests can cost money. Never deploy or share this browser-only version; move the OpenAI request to a backend first.
package.json, install its packages, then install the current OpenAI SDK on top. Your temporary key goes in .env, and .gitignore keeps that file out of Git. A key that never appears in a commit is a key you never have to replace! Repair the image-generation project
The course snapshot calls the discontinued dall-e-3 model and expects a hosted image URL. Following the current OpenAI image-generation guide, change its image request to use gpt-image-2:
const image = await openai.images.generate({
model: "gpt-image-2",
prompt,
size: "1024x1024",
})Where the code reads image.data[0].url, replace it with a data URL made from the returned base64 image:
`data:image/png;base64,${image.data[0].b64_json}`Keep the surrounding assignment or markup from your extracted file.
The base64 string is the entire image inlined into the response, so expect payloads of a megabyte or more. A version with a backend would save the image server-side and send the page a short URL instead of a long data URL.
gpt-image-2 and turn the returned base64 value into a PNG data URL. The discontinued model and the old .url field are part of the same change, so update both. If you change one and not the other, the image will be broken, which is exactly the mistake I made first! Repair the vision project
In the Vision Part 2 project, replace the discontinued model ID:
model: "gpt-4-vision-preview",with the image-capable gpt-4o-mini:
model: "gpt-4o-mini",The existing message format can still send text and image inputs.
If the updated request fails, send a text-only message to gpt-4o-mini first. A success there confirms your account can use the model, so the image part of the message is what to inspect next.
gpt-4o-mini and keep the text-and-image message format unchanged. Only the model ID changed, not the shape of the request. Changing fewer lines means fewer lines that can break, a lesson I keep relearning! Run either project
$ npm startOpen the Local URL printed by Vite. In the image-generation project, submit a prompt and look for the generated image on the page. In the vision project, submit an image and question and look for the model's text response. Restart after changing .env, and stop the project with Ctrl+C.
npm start, open the Local URL Vite prints, and try the flow end to end. A generated image or a vision reply is the success signal, and every attempt is a paid request. I write my test prompt before I start clicking, so I spend less money and waste less time wondering whether to try again! Troubleshooting
process is not defined: Replace the remaining process.env key read in index.js with the import.meta.env.VITE_... form.
The generated image is broken: Confirm the code reads b64_json and adds the data:image/png;base64, prefix instead of reading .url.
The model is unavailable: Confirm billing, organization verification, and model access in the OpenAI project. Provider availability can vary by account.
The SDK reports an error about running in a browser environment: npm install openai@latest keeps the SDK's browser guard, which refuses to run with an API key in browser code. If your extracted project does not already pass dangerouslyAllowBrowser: true in the OpenAI client options, add it beside the apiKey line. The option name is the warning: this stays acceptable only for a temporary, restricted key used locally.
The request works but the page stays unchanged: Check the browser console for a rendering error and compare the returned field with the relevant repair above.
process.env read, confirm the model, then check b64_json for image generation or the browser Console for a rendering error. Most failures here are one unfinished edit rather than a mystery. Check the ordinary things first; it took me far too long to make that a habit! 
