Skip to content

Conversation

@Sameerlite
Copy link
Collaborator

Title

Add Vertex AI Discovery Engine Rerank Support

Relevant issues

Fixes LIT-1107

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • I have added a screenshot of my new test passing locally
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

Type

🆕 New Feature

Changes

Implementation

  • Added Vertex AI Discovery Engine rerank support via VertexAIRerankConfig class
  • Authentication: Reuses existing Vertex AI authentication infrastructure with proper Google Cloud headers
  • URL Construction: Returns Discovery Engine ranking API URL with project ID
  • Request Transformation: Converts Cohere-format requests to Vertex AI Discovery Engine format
  • Response Transformation: Converts Vertex AI responses back to Cohere format for consistency
  • Parameter Mapping: Maps return_documents to ignoreRecordDetailsInResponse for ID-only responses

Usage Examples

SDK Usage:

from litellm import rerank

response = rerank(
    model="vertex_ai/semantic-ranker-default@latest",
    query="What is Google Gemini?",
    documents=["doc1", "doc2", "doc3"],
    top_n=2,
    return_documents=True
)

Proxy Usage:

model_list:
  - model_name: semantic-ranker-default@latest
    litellm_params:
      model: vertex_ai/semantic-ranker-default@latest
      vertex_ai_project: "your-project-id"
      vertex_ai_location: "us-central1"
      vertex_ai_credentials: "path/to/service-account.json"

Supported Models

  • semantic-ranker-default@latest (1024 tokens, 25 languages)
  • semantic-ranker-fast@latest (1024 tokens, 25 languages)
  • semantic-ranker-default-003 (512 tokens, 25 languages)
  • semantic-ranker-default-002 (512 tokens, English only)

Testing

Screenshot 2025-10-14 at 4 54 24 PM Screenshot 2025-10-14 at 4 54 41 PM

@vercel
Copy link

vercel bot commented Oct 14, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
litellm Ready Ready Preview Comment Oct 14, 2025 0:23am

@CLAassistant
Copy link

CLAassistant commented Oct 14, 2025

CLA assistant check
All committers have signed the CLA.

@Sameerlite Sameerlite changed the base branch from main to litellm_staging_oct October 14, 2025 11:33
Copy link
Contributor

@ishaan-jaff ishaan-jaff left a comment

Choose a reason for hiding this comment

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

LGTM!

@Sameerlite Sameerlite merged commit 9af054b into litellm_staging_oct Oct 15, 2025
16 of 42 checks passed
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.

4 participants