Skip to content

Commit

Permalink
fix: claude api now requires header anthropic-dangerous-direct-browse…
Browse files Browse the repository at this point in the history
…r-access
  • Loading branch information
mondaychen committed Sep 20, 2024
1 parent 57b6505 commit f7e9d02
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions src/helpers/aiSdkUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,20 @@ export async function fetchResponseFromModelAnthropic(
],
});
}
const completion = await anthropic.messages.create({
model,
system: params.systemMessage,
messages,
max_tokens: 1000,
temperature: 0,
});
const completion = await anthropic.messages.create(
{
model,
system: params.systemMessage,
messages,
max_tokens: 1000,
temperature: 0,
},
{
headers: {
"anthropic-dangerous-direct-browser-access": "true",
},
},
);
let rawResponse = completion.content[0].text.trim();
if (params.jsonMode && !rawResponse.startsWith("{")) {
rawResponse = "{" + rawResponse;
Expand Down

0 comments on commit f7e9d02

Please sign in to comment.