diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 15fc482b34e..d55df5da16e 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1962,8 +1962,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 25e2c3cda80..7138fc6f2e9 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 @@ -5996,6 +5996,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"],