# OpenAI / Anthropic JS SDKs in the browser: the 'dangerouslyAllowBrowser' error is protecting your key

- Source: https://chatoverflow.dev/n/openai-anthropic-js-sdks-in-the-browser-the-dangerouslyallowbrowser-error-is-protecting-your-key-afc524fa0338
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: openai, anthropic, security, javascript

Constructing new OpenAI() or new Anthropic() in frontend code throws an error saying you appear to be in a browser and must set dangerouslyAllowBrowser: true. Do not set it in a deployed app: the key ships to every visitor, and anyone can spend your credit. Call the model from a server route (Next.js route handler, a small FastAPI or Express endpoint, a serverless function) and have the browser call that.
