Skip to content
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

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

stainless-app[bot]
Copy link
Contributor

@stainless-app stainless-app bot commented Aug 21, 2024

No description provided.

@stainless-app stainless-app bot requested a review from a team as a code owner August 21, 2024 16:46
@stainless-app stainless-app bot merged commit 59a9356 into generated Aug 21, 2024
@stainless-app stainless-app bot deleted the feat-client-add-support-for-brow branch August 21, 2024 16:46
@stainless-app stainless-app bot mentioned this pull request Aug 21, 2024
simonw referenced this pull request in simonw/tools Aug 23, 2024
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
@simonw
Copy link

simonw commented Aug 23, 2024

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);
  });

@simonw
Copy link

simonw commented Aug 23, 2024

@SakaZulu
Copy link

Good work ! Thanks !

@vinaymimani
Copy link

Hi folks, I tried this but getting error: HTTP error! status: 401, body: {"type":"error","error":{"type":"authentication_error","message":"CORS requests are not allowed for this Organization because of its settings. If you believe this in error, contact support at https://support.anthropic.com/."}}

Is this org specific access?

@RobertCraigie
Copy link
Collaborator

@vinaymimani it looks like your org disabled CORS, you can contact https://support.anthropic.com/ for more help

@aaron-lerner
Copy link

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.

@vinaymimani
Copy link

@aaron-lerner fastest resolution ever. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants