Skip to content

feat: support custom Cohere reranker API URL - #498

Merged
danny-avila merged 2 commits into
LibreChat-AI:mainfrom
aproorg:feat/cohere-reranker-custom-url
Sep 3, 2026
Merged

danny-avila merged 2 commits into
LibreChat-AI:mainfrom
aproorg:feat/cohere-reranker-custom-url

Conversation

@busla

@busla busla commented Sep 2, 2026 •

Copy link
Copy Markdown

Summary

  • CohereReranker now accepts an apiUrl option, mirroring JinaReranker's existing apiUrl/JINA_API_URL pattern.
  • Defaults to the COHERE_API_URL env var, falling back to https://api.cohere.com/v2/rerank when unset.
  • createReranker accepts and forwards a new cohereApiUrl field.

This lets callers point the Cohere reranker at a Cohere-compatible endpoint (e.g. a self-hosted LiteLLM proxy) instead of Cohere's own API, the same way jinaApiUrl already does for Jina.

Companion PR on the LibreChat side wiring this through the web search config: LibreChat-AI/LibreChat#15518

Test plan

  • Added constructor/env-var/createReranker tests mirroring the existing JinaReranker suite
  • npx jest cohere-reranker jina-reranker rag-api-reranker — 53/53 passing
  • npx tsc --noEmit and npx eslint src/ clean

A note on why this is a re-submission

This is at least the fourth independent submission of this exact feature on this repo. All add the same apiUrl/COHERE_API_URL option to CohereReranker. A one-file, backward-compatible, test-covered change going unreviewed for over a year — independently, from three different contributors — isn't a great signal about how community PRs get handled here.

Related PRs:

The companion LibreChat-side PR (#9544, now closed in favor of #15518) has real users confirming the underlying need and the fix working in production. Happy to coordinate with @davidjrh and @npeham so effort isn't split four ways.

Adds an apiUrl option to CohereReranker, mirroring JinaReranker's
existing apiUrl/JINA_API_URL pattern. Defaults to COHERE_API_URL
(falling back to https://api.cohere.com/v2/rerank), letting callers
point at a Cohere-compatible endpoint such as a self-hosted LiteLLM
proxy. createReranker forwards a new cohereApiUrl field through.
@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-03T10:59:23.111804Z f1c5d0b Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3b05e1a831

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

jinaApiKey?: string;
jinaApiUrl?: string;
cohereApiKey?: string;
cohereApiUrl?: string;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Thread cohereApiUrl through the public search factory

When consumers configure the exported createSearchTool, this option cannot reach the newly updated factory: SearchToolConfig in src/tools/search/types.ts has no cohereApiUrl, and createSearchTool neither destructures nor forwards it in the call at src/tools/search/tool.ts:635-647. Consequently, a host-supplied custom Cohere endpoint is ignored and reranking still targets the environment/default URL; add the field to SearchToolConfig and pass it through alongside cohereApiKey.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch — fixed in f1c5d0b: SearchToolConfig (types.ts) now declares cohereApiUrl, and createSearchTool (tool.ts) destructures and forwards it to createReranker alongside cohereApiKey, same as jinaApiUrl.

SearchToolConfig and createSearchTool destructured jinaApiUrl but not
cohereApiUrl, so a host-supplied custom Cohere endpoint never reached
createReranker — the option was accepted but silently ignored end to
end. Forward it alongside cohereApiKey, mirroring jinaApiUrl.
@danny-avila

Copy link
Copy Markdown
Collaborator

@codex review the latest head

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🎉

Reviewed commit: f1c5d0b3ec

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@danny-avila
danny-avila merged commit f1091c0 into LibreChat-AI:main Sep 3, 2026
13 checks passed
@davidjrh

davidjrh commented Sep 3, 2026

Copy link
Copy Markdown

Great!! Thanks to all for the effort and @danny-avila for merging this! Really appreciated.

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.

3 participants