Skip to content

feat: add COHERE_API_URL support for custom Cohere rerank endpoints#47

Open
busla wants to merge 2 commits intodanny-avila:mainfrom
aproorg:feature/cohere-base-url
Open

feat: add COHERE_API_URL support for custom Cohere rerank endpoints#47
busla wants to merge 2 commits intodanny-avila:mainfrom
aproorg:feature/cohere-base-url

Conversation

@busla
Copy link
Copy Markdown

@busla busla commented Jan 13, 2026

Summary

  • Allow configuring a custom Cohere API URL via the COHERE_API_URL environment variable
  • Falls back to the default api.cohere.com/v2/rerank endpoint when not set
  • Mirrors the existing JINA_API_URL pattern for JinaReranker

Motivation

Users want to use Cohere-compatible reranking endpoints like LiteLLM proxy or other self-hosted solutions. Currently, the Cohere reranker URL is hardcoded, preventing this use case.

Related: danny-avila/LibreChat#5944

Changes

  • Add apiUrl property to CohereReranker class
  • Add apiUrl parameter to CohereReranker constructor with env var fallback
  • Update rerank method to use dynamic apiUrl instead of hardcoded URL
  • Add cohereApiUrl parameter to createReranker factory function

Test plan

  • Set COHERE_API_URL to a custom endpoint and verify requests go there
  • Leave COHERE_API_URL unset and verify fallback to default URL works

Dependency: danny-avila/LibreChat#9544

busla and others added 2 commits January 13, 2026 07:45
Allow configuring a custom Cohere API URL via the COHERE_API_URL
environment variable, falling back to the default api.cohere.com/v2/rerank
endpoint when not set.

This mirrors the existing JINA_API_URL pattern for JinaReranker and
enables users to use Cohere-compatible reranking endpoints like LiteLLM
proxy or other self-hosted solutions.

Changes:
- Add apiUrl property to CohereReranker class
- Add apiUrl parameter to CohereReranker constructor with env var fallback
- Update rerank method to use dynamic apiUrl instead of hardcoded URL
- Add cohereApiUrl parameter to createReranker factory function

Co-Authored-By: Claude <noreply@anthropic.com>
- Test default API URL (https://api.cohere.com/v2/rerank)
- Test custom API URL via constructor parameter
- Test COHERE_API_URL environment variable support
- Test explicit apiUrl parameter takes precedence over env var
- Test createReranker factory with cohereApiUrl option
- Test debug logging includes the API URL being used

Co-Authored-By: Claude <noreply@anthropic.com>
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.

1 participant