diff --git a/packages/api/src/endpoints/anthropic/initialize.ts b/packages/api/src/endpoints/anthropic/initialize.ts index 8bebd8467b..756afd5d75 100644 --- a/packages/api/src/endpoints/anthropic/initialize.ts +++ b/packages/api/src/endpoints/anthropic/initialize.ts @@ -80,7 +80,12 @@ export async function initializeAnthropic({ const anthropicConfig = appConfig?.endpoints?.[EModelEndpoint.anthropic]; const allConfig = appConfig?.endpoints?.all; - const result = getLLMConfig(credentials, clientOptions); + const result = getLLMConfig(credentials, { + ...clientOptions, + ...(anthropicConfig?.addParams != null && { addParams: anthropicConfig.addParams }), + ...(anthropicConfig?.dropParams != null && { dropParams: anthropicConfig.dropParams }), + ...(anthropicConfig?.defaultParams != null && { defaultParams: anthropicConfig.defaultParams }), + }); if (anthropicConfig?.streamRate) { (result.llmConfig as Record)._lc_stream_delay = anthropicConfig.streamRate; diff --git a/packages/api/src/endpoints/anthropic/llm.spec.ts b/packages/api/src/endpoints/anthropic/llm.spec.ts index b945eacb34..ec4cdabb45 100644 --- a/packages/api/src/endpoints/anthropic/llm.spec.ts +++ b/packages/api/src/endpoints/anthropic/llm.spec.ts @@ -1535,6 +1535,17 @@ describe('getLLMConfig', () => { } }); }); + + it('should omit native web_search tool when dropParams includes web_search', () => { + const result = getLLMConfig('test-key', { + modelOptions: { + model: 'claude-3-opus', + web_search: true, + }, + dropParams: ['web_search'], + }); + expect(result.tools).toEqual([]); + }); }); describe('Parameter Precedence and Override Logic', () => { diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index ae3f5b9560..91d2461a04 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -454,6 +454,12 @@ export const anthropicEndpointSchema = baseEndpointSchema.merge( vertex: vertexAISchema.optional(), /** Optional: List of available models */ models: z.array(z.string()).optional(), + /** Additional parameters passed to getLLMConfig (same pattern as custom endpoints) */ + addParams: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(), + /** Parameters excluded from the Anthropic client; e.g. web_search when using LibreChat search tools */ + dropParams: z.array(z.string()).optional(), + /** Default parameters applied when model options omit a value */ + defaultParams: z.record(z.union([z.string(), z.number(), z.boolean(), z.null()])).optional(), }), );