To determine the independent risk factors of cardiopulmonary exercise test (CPET) parameters related to adverse prognostic events within 5 years in patients undergoing percutaneous coronary intervention (PCI) for acute myocardial infarction (AMI), and establish a prediction model for the occurrence of adverse events within 5 years to provide a reference for cardiac rehabilitation training. From August 2015 to December 2021, patients who underwent PCI for AMI and completed CPET within 1–2 weeks after surgery before discharge from the Department of Cardiovascular Medicine of Zhengzhou Central Hospital Affiliated to Zhengzhou University, Henan Provincial Hospital of Traditional Chinese Medicine, and Anyang District Hospital were selected as participants. Univariate and multivariate analyses were used to screen for independent risk factors associated with 5-year adverse events. Feature importance was interpreted using SHapley Additive exPlanations (SHAP), and a logistic regression model was established for prediction. A receiver operating characteristic (ROC) curve was constructed to evaluate the performance of the prediction model. Calibration was assessed by the Hosmer–Lemeshow test and the calibration curve. In total, 375 patients met the inclusion criteria. Based on whether adverse events occurred during the 5-year follow-up period, the patients were divided into two groups: the event group (n = 53) and the non-event group (n = 322). Peak oxygen uptake (peakVO2), carbon dioxide ventilation equivalent slope (VE/VCO2slop), and peak end-tidal carbon dioxide partial pressure (PETCO2) were three independent risk factors for re-acute myocardial infarction (re-AMI), heart failure (HF), and even death after PCI for AMI (P < 0.05). The SHAP plots demonstrated that the significant contributors to model performance were related to peakVO2, VE/VCO2slop, and PETCO2. The risk of adverse events was significantly reduced when the peakVO2 was ≥ 20 mL/kg/min and the VE/VCO2slop was < 33. The ROC curves of the three models were drawn, including the no-event and event groups, re-AMI group, and HF group, which performed well, with AUC of 0.894, 0.760, and 0.883, respectively. The Hosmer–Lemeshow test showed that the three models were a good fit (P > 0.05). The calibration curve of the three models was close to the ideal diagonal lines. CPET parameters can predict the prognosis of adverse events within 5 years after PCI in patients with AMI and provide a theoretical basis for cardiac rehabilitation training.