The access to clean and drinkable water is becoming one of the major health issues because most natural waters are now polluted in the context of rapid industrialization and urbanization. Moreover, most pollutants such as antibiotics escape conventional wastewater treatments and are thus discharged in ecosystems, requiring advanced techniques for wastewater treatment. Here we review the use of artificial intelligence and machine learning to optimize pharmaceutical wastewater treatment systems, with focus on water quality, disinfection, renewable energy, biological treatment, blockchain technology, machine learning algorithms, big data, cyber-physical systems, and automated smart grid power distribution networks. Artificial intelligence allows for monitoring contaminants, facilitating data analysis, diagnosing water quality, easing autonomous decision-making, and predicting process parameters. We discuss advances in technical reliability, energy resources and wastewater management, cyber-resilience, security functionalities, and robust multidimensional performance of automated platform and distributed consortium, and stabilization of abnormal fluctuations in water quality parameters.