Skip to content

feat: configurable Cohere reranker API URL#149

Open
npeham wants to merge 1 commit intodanny-avila:mainfrom
pcode-at:feat/MIA-201-configurable-cohere-reranker-url
Open

feat: configurable Cohere reranker API URL#149
npeham wants to merge 1 commit intodanny-avila:mainfrom
pcode-at:feat/MIA-201-configurable-cohere-reranker-url

Conversation

@npeham
Copy link
Copy Markdown

@npeham npeham commented May 6, 2026

Summary

Fix for danny-avila/LibreChat#12328

This PR adds support for configurable API URLs in the Cohere reranker, enabling users to specify custom endpoints (e.g., for Azure deployments) while maintaining backward compatibility with the default Cohere API endpoint.

Key Changes

  • CohereReranker class: Added apiUrl as a private property with support for:
    • Explicit apiUrl parameter (highest priority)
    • COHERE_API_URL environment variable (medium priority)
    • Default fallback to https://api.cohere.com/v2/rerank (lowest priority)
  • createReranker factory function: Updated to accept and pass through cohereApiUrl configuration
  • SearchToolConfig interface: Added cohereApiUrl optional property
  • createSearchTool function: Updated to accept and forward cohereApiUrl parameter
  • Logging improvements: Enhanced debug logging to include the API URL being used for Cohere reranking
  • Code formatting: Improved line wrapping for consistency with Jina reranker implementation
  • Test coverage: Added comprehensive unit tests for CohereReranker constructor covering all URL resolution scenarios

Implementation Details

The API URL resolution follows a priority order: explicit parameter > environment variable > default URL. This pattern matches the existing implementation for JinaReranker and provides flexibility for different deployment scenarios while maintaining sensible defaults.

Mirror the JinaReranker pattern by accepting an optional `apiUrl`
in the CohereReranker constructor (with COHERE_API_URL env-var
fallback) and propagating `cohereApiUrl` through `createReranker`
and the `createSearchTool` config.

Defaults to https://api.cohere.com/v2/rerank, fully backwards
compatible. Enables Azure AI Foundry serverless Cohere endpoints
and other Cohere-compatible deployments.

Refs danny-avila/LibreChat#12328
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants