-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(client): add support for browser usage #504
Conversation
Now talks to the Anthropic API directly using their new anthropic-dangerous-direct-browser-access: true header. Also shows a "Generating..." message. Code change mostly by Claude: https://gist.github.com/simonw/6ff7bc0d47575a53463abc3482608f74
Here's how to use this new feature with vanilla JavaScript fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": apiKey,
"anthropic-version": "2023-06-01",
"content-type": "application/json",
"anthropic-dangerous-direct-browser-access": "true",
},
body: JSON.stringify({
model: "claude-3-haiku-20240307",
max_tokens: 1024,
messages: [
{
role: "user",
content: [
{ type: "text", text: "Return a haiku about how great pelicans are" },
],
},
],
}),
})
.then((response) => response.json())
.then((data) => {
const haiku = data.content[0].text;
alert(haiku);
}); |
Blogged about this here: https://simonwillison.net/2024/Aug/23/anthropic-dangerous-direct-browser-access/ |
Good work ! Thanks ! |
Hi folks, I tried this but getting error: Is this org specific access? |
@vinaymimani it looks like your org disabled CORS, you can contact https://support.anthropic.com/ for more help |
Hey @vinaymimani, all orgs should have access, but some are automatically locked down for various reasons. I believe yours was mistakenly locked down and I've now corrected this. Give it another shot. |
@aaron-lerner fastest resolution ever. Thank you! |
No description provided.