The increase in the use of energy sources causes air pollution. The Air Pollutant Index (API) is information about the air quality of a place and at a certain time. API has several parameters, namely SO2, PM10, NO2, O3, and CO. In this study, the KNN method was used to assist categorize air quality. However, all training data were used during the classification process with KNN causes a long prediction process. Another problem with KNN is difficult to determine the optimal value of the K parameter in KNN. The Particle Swarm Optimization (PSO) method can be used for problems on KNN. Therefore, the aim of this study is to predict air quality based on the API by combining the KNN-PSO method. The dataset used is the API dataset for the DKI Jakarta area 2017-2019 totaling 1075 data. The results showed the accuracy for the KNN-PSO method was 98.42% with a precision value of 97.75% and a recall value of 98.13%. To further analyze the results on the combined method, the results of this study were compared with the KNN method only. The results obtained from the KNN method are lower than the KNN-PSO method. So it can be concluded that the KNN-PSO method is great and robust in air quality classification or prediction.