Air pollution is a hotspot of wide concern in Chinese cities. With the worsening of air pollution, urban agglomerations face an increasingly complex environment for air quality monitoring, hindering sustainable and high-quality development in China. More effective methods for predicting air quality are urgently needed. In this study, we employed seven single models and ensemble learning algorithms and constructed a hybrid learning algorithm, the LSTM-SVR model, totaling eight machine learning algorithms, to predict the Air Quality Index in six major urban agglomerations in China. We comprehensively compared the predictive performance of the eight algorithmic models in different urban agglomerations. The results reveal that, in areas with higher levels of air pollution, the situation for model prediction is more complicated, leading to a decline in predictive accuracy. The constructed hybrid model LSTM-SVR demonstrated the best predictive performance, followed by the ensemble model RF, both of which effectively enhanced the predictive accuracy in heavily polluted areas. Overall, the predictive performance of the hybrid and ensemble models is superior to that of the single-model prediction methods. This study provides AI technological support for air quality prediction in various regions and offers a more comprehensive discussion of the performance differences between different types of algorithms, contributing to the practical application of air pollution control.