Skip to content

fix(rag): use router for completion in RAG query pipeline - #19550

Merged
1 commit merged into
BerriAI:litellm_oss_staging_01_24_2026from
marcosgriselli:fix/rag-query-router-serialization
Jan 24, 2026
Merged

1 commit merged into
BerriAI:litellm_oss_staging_01_24_2026from
marcosgriselli:fix/rag-query-router-serialization

Conversation

@marcosgriselli

@marcosgriselli marcosgriselli commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Summary

The RAG query endpoint (/v1/rag/query) was failing with Object of type Router is not JSON serializable when called through the proxy. This fix addresses two related issues:

  1. Router serialization error: The Router object passed via kwargs was leaking into the request payload sent to providers like Bedrock, causing JSON serialization errors.

  2. Model name resolution: The RAG query pipeline was calling litellm.acompletion() directly instead of using the router, so virtual model names configured in the proxy weren't being resolved to actual provider model IDs.

Tested RAG query endpoint with Bedrock and OpenAI providers through the proxy

The RAG query endpoint was failing with "Object of type Router is not
JSON serializable" when called through the proxy. This was caused by two
issues:

1. The Router object passed via kwargs was leaking into the request
   payload sent to providers like Bedrock, causing JSON serialization
   errors.

2. The RAG query pipeline was calling litellm.acompletion() directly
   instead of using the router, so virtual model names configured in the
   proxy weren't being resolved to actual provider model IDs.

This fix:
- Extracts the router from kwargs and uses router.acompletion() when
  available, falling back to litellm.acompletion() otherwise
- Adds "Router" to the list of non-serializable types in
  filter_exceptions_from_params as a defensive measure

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Jan 22, 2026

Copy link
Copy Markdown

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

Project Deployment Review Updated (UTC)
litellm Ready Ready Preview, Comment Jan 22, 2026 6:02am

Request Review

@CLAassistant

CLAassistant commented Jan 22, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

# Skip known non-serializable object types (Logging, Router, etc.)
obj_type_name = type(data).__name__
if obj_type_name in ["Logging", "LiteLLMLoggingObj"]:
if obj_type_name in ["Logging", "LiteLLMLoggingObj", "Router"]:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Open to more guidance if this is not the right route but Router hits this issue

@ghost
ghost changed the base branch from main to litellm_oss_staging_01_24_2026 January 24, 2026 04:11
@ghost
ghost merged commit 6b1ce4e into BerriAI:litellm_oss_staging_01_24_2026 Jan 24, 2026
5 of 7 checks passed
fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
)

The RAG query endpoint was failing with "Object of type Router is not
JSON serializable" when called through the proxy. This was caused by two
issues:

1. The Router object passed via kwargs was leaking into the request
   payload sent to providers like Bedrock, causing JSON serialization
   errors.

2. The RAG query pipeline was calling litellm.acompletion() directly
   instead of using the router, so virtual model names configured in the
   proxy weren't being resolved to actual provider model IDs.

This fix:
- Extracts the router from kwargs and uses router.acompletion() when
  available, falling back to litellm.acompletion() otherwise
- Adds "Router" to the list of non-serializable types in
  filter_exceptions_from_params as a defensive measure
This pull request was closed.
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