diff --git a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py index a58fe3bb5c2..d94c8b55883 100644 --- a/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py +++ b/tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py @@ -336,3 +336,45 @@ def test_validate_environment_custom_api_base_calls_get_complete_vertex_url(): assert mock_get_url.call_args.kwargs["custom_api_base"] == custom_base # The returned api_base should have the suffix assert api_base == f"{custom_base}:streamRawPredict" + + +def test_validate_environment_custom_api_base_non_streaming(): + """Regression test for #25748 (non-streaming path): custom api_base must + still go through get_complete_vertex_url so that :rawPredict is appended.""" + config = VertexAIPartnerModelsAnthropicMessagesConfig() + headers = {} + litellm_params = { + "vertex_ai_project": "test-project", + "vertex_ai_location": "us-central1", + "vertex_credentials": "{}", + } + custom_base = ( + "https://aiplatform.us.rep.googleapis.com/v1/projects/my-project" + "/locations/us/publishers/anthropic/models/claude-sonnet-4-5@20250929" + ) + optional_params = {"stream": False} + + with patch.object( + config, "_ensure_access_token", return_value=("token", "test-project") + ), patch.object( + config, + "get_complete_vertex_url", + return_value=f"{custom_base}:rawPredict", + ) as mock_get_url: + updated_headers, api_base = config.validate_anthropic_messages_environment( + headers=headers, + model="claude-sonnet-4-5@20250929", + messages=[], + optional_params=optional_params, + litellm_params=litellm_params, + api_base=custom_base, + ) + + # get_complete_vertex_url MUST be called even with a custom api_base + assert mock_get_url.called, ( + "get_complete_vertex_url should be called when api_base is provided " + "so that the endpoint suffix (:rawPredict) is appended" + ) + assert mock_get_url.call_args.kwargs["custom_api_base"] == custom_base + # The returned api_base should have the non-streaming suffix + assert api_base == f"{custom_base}:rawPredict"