fix(ai): Add dangerouslyAllowBrowser flag for Anthropic client

- Enables browser support for Anthropic SDK
- Required for browser-based applications using the AI library
This commit is contained in:
Mario Zechner 2025-09-01 21:55:52 +02:00
parent 3caa3af8fc
commit da43e625f8

View file

@ -52,10 +52,16 @@ export class AnthropicLLM implements LLM<AnthropicLLMOptions> {
if (typeof process !== "undefined" && process.env) {
process.env.ANTHROPIC_API_KEY = undefined;
}
this.client = new Anthropic({ apiKey: null, authToken: apiKey, baseURL: model.baseUrl, defaultHeaders });
this.client = new Anthropic({
apiKey: null,
authToken: apiKey,
baseURL: model.baseUrl,
defaultHeaders,
dangerouslyAllowBrowser: true,
});
this.isOAuthToken = true;
} else {
this.client = new Anthropic({ apiKey, baseURL: model.baseUrl });
this.client = new Anthropic({ apiKey, baseURL: model.baseUrl, dangerouslyAllowBrowser: true });
this.isOAuthToken = false;
}
this.modelInfo = model;