anthropics / anthropic-sdk-typescript

Access to Anthropic's safety-first language model APIs
https://www.npmjs.com/package/@anthropic-ai/sdk
MIT License
722 stars 78 forks source link

Enable CORS #219

Closed PaulKinlan closed 11 months ago

PaulKinlan commented 11 months ago

I understand that #28 was closed, but it would be incredibly useful to enable CORS support so that the Claude API can be called from the browser. There are a lot of times where sites will work in a trusted environment or allow the user to add their own API key, or for example like with Google APIs I can configure the sites that a browser key can run on and not having to set up a proxy would be incredibly useful.

Not enabling CORS and thus blocking requests from the browser limits the web when running on the client, and Apps on iOS and Android won't be limited in the same way.

x5a commented 11 months ago

Hi @PaulKinlan, we appreciate your feedback and input. I understand that there are certain use cases where CORS headers could be useful, but at this time we cannot prioritize supporting every use case. Our suggested approach is to build a server-side application that securely stores or proxies API keys from the client. We are continually improving our services, so stay tuned for future updates.

phusting commented 8 months ago

Hi, I would like to reopen this and have it enabled. I use the Office and Google add-in frameworks which is basically browser based. Not having CORS enabled on your end is very limiting.

Kaddtechnologies commented 5 months ago

@x5a Im sorry but that response is not acceptable. This is 2024 and many months later and this is still an issue. Cors needs to be enabled. No other API has this problem. Please fix this as soon as possible.

julian-shalaby commented 5 months ago

+1 Please enable CORS

jonathanpv commented 4 months ago

trynna make a viral tweet here fam squad why u no cors :(

Yarflam commented 4 months ago

+1 Please enable CORS

I would like to integrate Claude in my AI client interface. Everyone can use their API keys (local storage) to use GPT-4o, Mistral, DeepSeek, Bloom, Gemma etc. I can't integrate Claude. :/

therealzac commented 4 months ago

OpenAI's SDK has the following option:

dangerouslyAllowBrowser: true

Please add this, because we're forced to use their service until you do.

dested commented 4 months ago

This is really painful...

robsalasco commented 4 months ago

Hey! I'm also having this issue! please enable CORS!

digovc commented 4 months ago

Every browser-based integration is impossible. This is very bad.

joelwright-dev commented 4 months ago

+1 please dangerously allow browser or some alternative like OpenAI.

metjm commented 4 months ago

+1 please consider allowing this

moomindani commented 4 months ago

+1 I believe that this is not edge case, this is one of common access pattern.

mweel1 commented 4 months ago

+1 we should be able to call from the browser

radiantone commented 4 months ago

Access to fetch at 'https://api.anthropic.com/v1/messages' from origin 'https://app.visualagents.ai' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled. This is a no go

rattrayalex commented 4 months ago

Thank you, everyone, for the input. Anthropic is aware of the demand for browser-based integrations, and will take your asks into account as a part of its planning.

x5a commented 2 months ago

@PaulKinlan + thread, see our latest SDK release now offers CORS support [changelog].