From b053bae9d90a6b3ed36e08954e6d2246dee7a585 Mon Sep 17 00:00:00 2001 From: Filippo Mattia Menghi Date: Wed, 10 Jun 2026 09:29:57 +0200 Subject: [PATCH] Strip vector store ids from Anthropic request payload The proxy's vector store pre-call hooks leave vector_store_ids in optional_params, and transform_request spreads optional_params into the outgoing request body. Anthropic rejects the unknown field with a 400 "vector_store_ids: Extra inputs are not permitted". Pop vector_store_ids and vector_store_id alongside the existing is_vertex_request / client_metadata cleanup before building the payload. Fixes #23741. --- litellm/llms/anthropic/chat/transformation.py | 9 +++++++-- .../test_anthropic_chat_transformation.py | 19 +++++++++++++++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 9ecd0df0cb8..411151c10d9 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1977,8 +1977,13 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): optional_params.pop("metadata") # Remove internal LiteLLM parameters that should not be sent to Anthropic API - optional_params.pop("is_vertex_request", None) - optional_params.pop("client_metadata", None) + for internal_param in ( + "is_vertex_request", + "client_metadata", + "vector_store_ids", + "vector_store_id", + ): + optional_params.pop(internal_param, None) # ``top_k`` is a provider-specific kwarg that bypasses # ``map_openai_params``; gate it here, the single boundary shared by diff --git a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py index abb162e9ddb..2b4244b326f 100644 --- a/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py +++ b/tests/test_litellm/llms/anthropic/chat/test_anthropic_chat_transformation.py @@ -5361,6 +5361,25 @@ def test_client_metadata_stripped_from_anthropic_request(): assert "client_metadata" not in result +def test_transform_request_strips_vector_store_ids(): + """vector_store_ids injected by proxy vector store hooks must not reach the Anthropic payload.""" + config = AnthropicConfig() + result = config.transform_request( + model="claude-3-5-haiku-20241022", + messages=[{"role": "user", "content": "hello"}], + optional_params={ + "max_tokens": 10, + "vector_store_ids": ["vs_abc123"], + "vector_store_id": "vs_abc123", + }, + litellm_params={}, + headers={}, + ) + assert "vector_store_ids" not in result + assert "vector_store_id" not in result + assert result["max_tokens"] == 10 + + @pytest.mark.parametrize( "model", ["claude-fable-5", "claude-opus-4-7", "claude-opus-4-8-20260120"],