Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

Fix extra body error

Sameer Kankutecf74f55b7983
diff --git a/litellm/llms/azure_ai/vector_stores/transformation.py b/litellm/llms/azure_ai/vector_stores/transformation.py
index d2c8206ca9a..d1b93c9e7a3 100644
--- a/litellm/llms/azure_ai/vector_stores/transformation.py
+++ b/litellm/llms/azure_ai/vector_stores/transformation.py
@@ -92,10 +92,10 @@ class AzureAIVectorStoreConfig(BaseVectorStoreConfig, BaseAzureLLM):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict[str, Any]]:
"""
Transform search request for Azure AI Search API
diff --git a/litellm/llms/base_llm/vector_store/transformation.py b/litellm/llms/base_llm/vector_store/transformation.py
index 49d2f72db7c..85a9c838264 100644
--- a/litellm/llms/base_llm/vector_store/transformation.py
+++ b/litellm/llms/base_llm/vector_store/transformation.py
@@ -56,10 +56,10 @@ class BaseVectorStoreConfig:
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
pass
@@ -68,10 +68,10 @@ class BaseVectorStoreConfig:
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
"""
Optional async version of transform_search_vector_store_request.
@@ -83,10 +83,10 @@ class BaseVectorStoreConfig:
vector_store_id=vector_store_id,
query=query,
vector_store_search_optional_params=vector_store_search_optional_params,
- extra_body=extra_body,
api_base=api_base,
litellm_logging_obj=litellm_logging_obj,
litellm_params=litellm_params,
+ extra_body=extra_body,
)
@abstractmethod
diff --git a/litellm/llms/bedrock/vector_stores/transformation.py b/litellm/llms/bedrock/vector_stores/transformation.py
index 4e81fa4e66e..f028503c6a2 100644
--- a/litellm/llms/bedrock/vector_stores/transformation.py
+++ b/litellm/llms/bedrock/vector_stores/transformation.py
@@ -201,10 +201,10 @@ class BedrockVectorStoreConfig(BaseVectorStoreConfig, BaseAWSLLM):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
if isinstance(query, list):
query = " ".join(query)
diff --git a/litellm/llms/custom_httpx/llm_http_handler.py b/litellm/llms/custom_httpx/llm_http_handler.py
index 99f748c0c1a..d8515d2c4d6 100644
--- a/litellm/llms/custom_httpx/llm_http_handler.py
+++ b/litellm/llms/custom_httpx/llm_http_handler.py
@@ -8582,10 +8582,10 @@ class BaseLLMHTTPHandler:
vector_store_id=vector_store_id,
query=query,
vector_store_search_optional_params=vector_store_search_optional_params,
- extra_body=extra_body,
api_base=api_base,
litellm_logging_obj=logging_obj,
litellm_params=dict(litellm_params),
+ extra_body=extra_body,
)
else:
(
@@ -8595,10 +8595,10 @@ class BaseLLMHTTPHandler:
vector_store_id=vector_store_id,
query=query,
vector_store_search_optional_params=vector_store_search_optional_params,
- extra_body=extra_body,
api_base=api_base,
litellm_logging_obj=logging_obj,
litellm_params=dict(litellm_params),
+ extra_body=extra_body,
)
all_optional_params: Dict[str, Any] = dict(litellm_params)
all_optional_params.update(vector_store_search_optional_params or {})
@@ -8696,10 +8696,10 @@ class BaseLLMHTTPHandler:
vector_store_id=vector_store_id,
query=query,
vector_store_search_optional_params=vector_store_search_optional_params,
- extra_body=extra_body,
api_base=api_base,
litellm_logging_obj=logging_obj,
litellm_params=dict(litellm_params),
+ extra_body=extra_body,
)
all_optional_params: Dict[str, Any] = dict(litellm_params)
diff --git a/litellm/llms/gemini/vector_stores/transformation.py b/litellm/llms/gemini/vector_stores/transformation.py
index b6cace066c8..35d83bd2adc 100644
--- a/litellm/llms/gemini/vector_stores/transformation.py
+++ b/litellm/llms/gemini/vector_stores/transformation.py
@@ -115,10 +115,10 @@ class GeminiVectorStoreConfig(BaseVectorStoreConfig):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
"""
Transform search request to Gemini's generateContent format.
diff --git a/litellm/llms/milvus/vector_stores/transformation.py b/litellm/llms/milvus/vector_stores/transformation.py
index 8c08b783387..af78cd8dbda 100644
--- a/litellm/llms/milvus/vector_stores/transformation.py
+++ b/litellm/llms/milvus/vector_stores/transformation.py
@@ -127,10 +127,10 @@ class MilvusVectorStoreConfig(BaseVectorStoreConfig):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict[str, Any]]:
"""
Transform search request for Azure AI Search API
diff --git a/litellm/llms/openai/vector_stores/transformation.py b/litellm/llms/openai/vector_stores/transformation.py
index b6eae390d93..2c11d137480 100644
--- a/litellm/llms/openai/vector_stores/transformation.py
+++ b/litellm/llms/openai/vector_stores/transformation.py
@@ -103,10 +103,10 @@ class OpenAIVectorStoreConfig(BaseVectorStoreConfig):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
url = f"{api_base}/{vector_store_id}/search"
typed_request_body = VectorStoreSearchRequest(
diff --git a/litellm/llms/pg_vector/vector_stores/transformation.py b/litellm/llms/pg_vector/vector_stores/transformation.py
index 8261036cae0..7b22edd8676 100644
--- a/litellm/llms/pg_vector/vector_stores/transformation.py
+++ b/litellm/llms/pg_vector/vector_stores/transformation.py
@@ -77,19 +77,19 @@ class PGVectorStoreConfig(OpenAIVectorStoreConfig):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
url = f"{api_base}/{vector_store_id}/search"
_, request_body = super().transform_search_vector_store_request(
vector_store_id=vector_store_id,
query=query,
vector_store_search_optional_params=vector_store_search_optional_params,
- extra_body=extra_body,
api_base=api_base,
litellm_logging_obj=litellm_logging_obj,
litellm_params=litellm_params,
+ extra_body=extra_body,
)
return url, request_body
diff --git a/litellm/llms/ragflow/vector_stores/transformation.py b/litellm/llms/ragflow/vector_stores/transformation.py
index ae28222c3ce..3238d3e9c14 100644
--- a/litellm/llms/ragflow/vector_stores/transformation.py
+++ b/litellm/llms/ragflow/vector_stores/transformation.py
@@ -99,10 +99,10 @@ class RAGFlowVectorStoreConfig(BaseVectorStoreConfig):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
"""RAGFlow vector stores are management-only, search is not supported."""
raise NotImplementedError(
diff --git a/litellm/llms/s3_vectors/vector_stores/transformation.py b/litellm/llms/s3_vectors/vector_stores/transformation.py
index 0cf86358873..8270e99d456 100644
--- a/litellm/llms/s3_vectors/vector_stores/transformation.py
+++ b/litellm/llms/s3_vectors/vector_stores/transformation.py
@@ -76,10 +76,10 @@ class S3VectorsVectorStoreConfig(BaseVectorStoreConfig, BaseAWSLLM):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
"""Sync version - generates embedding synchronously."""
# For S3 Vectors, vector_store_id should be in format: bucket_name:index_name
@@ -138,10 +138,10 @@ class S3VectorsVectorStoreConfig(BaseVectorStoreConfig, BaseAWSLLM):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict]:
"""Async version - generates embedding asynchronously."""
# For S3 Vectors, vector_store_id should be in format: bucket_name:index_name
diff --git a/litellm/llms/vertex_ai/vector_stores/rag_api/transformation.py b/litellm/llms/vertex_ai/vector_stores/rag_api/transformation.py
index b3fcf4b394c..d31e1f6c8f2 100644
--- a/litellm/llms/vertex_ai/vector_stores/rag_api/transformation.py
+++ b/litellm/llms/vertex_ai/vector_stores/rag_api/transformation.py
@@ -97,10 +97,10 @@ class VertexVectorStoreConfig(BaseVectorStoreConfig, VertexBase):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict[str, Any]]:
"""
Transform search request for Vertex AI RAG API
diff --git a/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py b/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py
index 47dac8dca32..6cb7a86bea2 100644
--- a/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py
+++ b/litellm/llms/vertex_ai/vector_stores/search_api/transformation.py
@@ -104,10 +104,10 @@ class VertexSearchAPIVectorStoreConfig(BaseVectorStoreConfig, VertexBase):
vector_store_id: str,
query: Union[str, List[str]],
vector_store_search_optional_params: VectorStoreSearchOptionalRequestParams,
- extra_body: Optional[Dict[str, Any]],
api_base: str,
litellm_logging_obj: LiteLLMLoggingObj,
litellm_params: dict,
+ extra_body: Optional[Dict[str, Any]] = None,
) -> Tuple[str, Dict[str, Any]]:
"""
Transform search request for Vertex AI RAG API
diff --git a/tests/logging_callback_tests/test_bedrock_knowledgebase_hook.py b/tests/logging_callback_tests/test_bedrock_knowledgebase_hook.py
index abe96b2ea2e..3e8d59b2992 100644
--- a/tests/logging_callback_tests/test_bedrock_knowledgebase_hook.py
+++ b/tests/logging_callback_tests/test_bedrock_knowledgebase_hook.py
@@ -354,6 +354,7 @@ async def test_bedrock_kb_request_body_has_transformed_filters(
api_base=api_base,
litellm_logging_obj=logging_obj,
litellm_params=litellm_params_dict,
+ extra_body=None,
)
)
captured_request_body["url"] = url
diff --git a/tests/test_litellm/llms/bedrock/vector_stores/test_bedrock_vector_store_transformation.py b/tests/test_litellm/llms/bedrock/vector_stores/test_bedrock_vector_store_transformation.py
index c211a3536e3..d60d0487d06 100644
--- a/tests/test_litellm/llms/bedrock/vector_stores/test_bedrock_vector_store_transformation.py
+++ b/tests/test_litellm/llms/bedrock/vector_stores/test_bedrock_vector_store_transformation.py
@@ -18,10 +18,10 @@ def test_transform_search_request():
vector_store_id="kb123",
query="hello",
vector_store_search_optional_params={},
- extra_body=None,
api_base="https://bedrock-agent-runtime.us-west-2.amazonaws.com/knowledgebases",
litellm_logging_obj=mock_log,
litellm_params={},
+ extra_body=None,
)
assert url.endswith("/kb123/retrieve")
@@ -37,6 +37,9 @@ def test_transform_search_request_uses_only_retrieval_config_from_extra_body():
vector_store_id="kb123",
query="hello",
vector_store_search_optional_params={},
+ api_base="https://bedrock-agent-runtime.us-west-2.amazonaws.com/knowledgebases",
+ litellm_logging_obj=mock_log,
+ litellm_params={},
extra_body={
"retrievalConfiguration": {
"vectorSearchConfiguration": {
@@ -46,9 +49,6 @@ def test_transform_search_request_uses_only_retrieval_config_from_extra_body():
},
"unrelatedField": {"should_not": "be_forwarded"},
},
- api_base="https://bedrock-agent-runtime.us-west-2.amazonaws.com/knowledgebases",
- litellm_logging_obj=mock_log,
- litellm_params={},
)
assert url.endswith("/kb123/retrieve")
@@ -79,10 +79,10 @@ def test_transform_search_request_does_not_mutate_extra_body_and_overrides_numbe
vector_store_id="kb123",
query="hello",
vector_store_search_optional_params={"max_num_results": 10},
- extra_body=extra_body,
api_base="https://bedrock-agent-runtime.us-west-2.amazonaws.com/knowledgebases",
litellm_logging_obj=mock_log,
litellm_params={},
+ extra_body=extra_body,
)
assert (
@@ -114,10 +114,10 @@ def test_transform_search_request_overrides_filter_without_mutating_extra_body()
vector_store_id="kb123",
query="hello",
vector_store_search_optional_params={"filters": new_filter},
- extra_body=extra_body,
api_base="https://bedrock-agent-runtime.us-west-2.amazonaws.com/knowledgebases",
litellm_logging_obj=mock_log,
litellm_params={},
+ extra_body=extra_body,
)
assert (
diff --git a/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py b/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py
index 9507ff401aa..7085e45cdc3 100644
--- a/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py
+++ b/tests/test_litellm/llms/s3_vectors/vector_stores/test_s3_vectors_transformation.py
@@ -56,10 +56,10 @@ class TestS3VectorsVectorStoreConfig:
vector_store_id="invalid-format",
query="test query",
vector_store_search_optional_params={},
- extra_body=None,
api_base="https://s3vectors.us-west-2.api.aws",
litellm_logging_obj=mock_logging_obj,
litellm_params={},
+ extra_body=None,
)
def test_transform_search_response(self):
diff --git a/tests/vector_store_tests/test_ragflow_vector_store.py b/tests/vector_store_tests/test_ragflow_vector_store.py
index 4ca38233129..cb4cfd75c1f 100644
--- a/tests/vector_store_tests/test_ragflow_vector_store.py
+++ b/tests/vector_store_tests/test_ragflow_vector_store.py
@@ -267,6 +267,7 @@ class TestRAGFlowVectorStore(BaseVectorStoreTest):
api_base="http://localhost:9380",
litellm_logging_obj=logging_obj,
litellm_params={},
+ extra_body=None,
)
def test_transform_search_vector_store_response_not_implemented(self):