fix(ai): Add anthropic-dangerous-direct-browser-access header
- Required header for browser-based access to Anthropic API - Added to both OAuth and regular API key authentication - Ensures full browser compatibility
This commit is contained in:
@@ -45,6 +45,7 @@ export class AnthropicLLM implements LLM<AnthropicLLMOptions> {
|
|||||||
if (apiKey.includes("sk-ant-oat")) {
|
if (apiKey.includes("sk-ant-oat")) {
|
||||||
const defaultHeaders = {
|
const defaultHeaders = {
|
||||||
accept: "application/json",
|
accept: "application/json",
|
||||||
|
"anthropic-dangerous-direct-browser-access": "true",
|
||||||
"anthropic-beta": "oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14",
|
"anthropic-beta": "oauth-2025-04-20,fine-grained-tool-streaming-2025-05-14",
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -61,7 +62,12 @@ export class AnthropicLLM implements LLM<AnthropicLLMOptions> {
|
|||||||
});
|
});
|
||||||
this.isOAuthToken = true;
|
this.isOAuthToken = true;
|
||||||
} else {
|
} else {
|
||||||
this.client = new Anthropic({ apiKey, baseURL: model.baseUrl, dangerouslyAllowBrowser: true });
|
const defaultHeaders = {
|
||||||
|
accept: "application/json",
|
||||||
|
"anthropic-dangerous-direct-browser-access": "true",
|
||||||
|
"anthropic-beta": "fine-grained-tool-streaming-2025-05-14",
|
||||||
|
};
|
||||||
|
this.client = new Anthropic({ apiKey, baseURL: model.baseUrl, dangerouslyAllowBrowser: true, defaultHeaders });
|
||||||
this.isOAuthToken = false;
|
this.isOAuthToken = false;
|
||||||
}
|
}
|
||||||
this.modelInfo = model;
|
this.modelInfo = model;
|
||||||
|
|||||||
Reference in New Issue
Block a user