feat: add COHERE_BASE_URL configuration support for custom Cohere rerank endpoints

- Add cohereBaseUrl to webSearchSchema configuration
- Update loadWebSearchConfig to load cohereBaseUrl from environment
- Add cohereBaseUrl to TWebSearchKeys type definition
- Configure cohereBaseUrl as optional parameter for cohere reranker
- Add COHERE_BASE_URL documentation to .env.example

This enables configuration of custom Cohere endpoints (such as LiteLLM proxy)
for web search reranking. The configuration infrastructure is ready for when
the @librechat/agents package supports custom base URLs.

Usage:
COHERE_BASE_URL=http://litellm:8000/v1
COHERE_API_KEY=your_api_key
This commit is contained in:
Jón Levy 2025-08-17 12:51:47 +00:00 committed by Jón Levy
parent 2a50c372ef
commit 00a99aca0a
No known key found for this signature in database
GPG key ID: 397E4D775F694BF3
4 changed files with 11 additions and 2 deletions

View file

@ -814,6 +814,7 @@ OPENWEATHER_API_KEY=
# JINA_API_KEY=your_jina_api_key
# or
# COHERE_API_KEY=your_cohere_api_key
# COHERE_BASE_URL=your_custom_cohere_base_url
#======================#
# MCP Configuration #

View file

@ -836,6 +836,7 @@ export const webSearchSchema = z.object({
jinaApiKey: z.string().optional().default('${JINA_API_KEY}'),
jinaApiUrl: z.string().optional().default('${JINA_API_URL}'),
cohereApiKey: z.string().optional().default('${COHERE_API_KEY}'),
cohereBaseUrl: z.string().optional().default('${COHERE_BASE_URL}'),
searchProvider: z.nativeEnum(SearchProviders).optional(),
scraperProvider: z.nativeEnum(ScraperProviders).optional(),
rerankerType: z.nativeEnum(RerankerTypes).optional(),

View file

@ -30,7 +30,11 @@ export const webSearchAuth = {
/** Optional (0) */
jinaApiUrl: 0 as const,
},
cohere: { cohereApiKey: 1 as const },
cohere: {
cohereApiKey: 1 as const,
/** Optional (0) */
cohereBaseUrl: 0 as const,
},
},
};
@ -72,6 +76,7 @@ export function loadWebSearchConfig(
const jinaApiKey = config?.jinaApiKey ?? '${JINA_API_KEY}';
const jinaApiUrl = config?.jinaApiUrl ?? '${JINA_API_URL}';
const cohereApiKey = config?.cohereApiKey ?? '${COHERE_API_KEY}';
const cohereBaseUrl = config?.cohereBaseUrl ?? '${COHERE_BASE_URL}';
const safeSearch = config?.safeSearch ?? SafeSearchTypes.MODERATE;
return {
@ -80,6 +85,7 @@ export function loadWebSearchConfig(
jinaApiKey,
jinaApiUrl,
cohereApiKey,
cohereBaseUrl,
serperApiKey,
searxngApiKey,
firecrawlApiKey,

View file

@ -9,7 +9,8 @@ export type TWebSearchKeys =
| 'firecrawlVersion'
| 'jinaApiKey'
| 'jinaApiUrl'
| 'cohereApiKey';
| 'cohereApiKey'
| 'cohereBaseUrl';
export type TWebSearchCategories =
| SearchCategories.PROVIDERS