The accurate and real-time detection of antibiotics in the complex mixtures remain a significant challenge in the clinical drug monitoring, the food safety and the environmental surveillance. In this study, we developed an innovative electrochemical sensor platform, i.e. Ag/ZIF-67/g-C3N4/GCE, combined with the assistance of machine learning for the detection of chloramphenicol (CHL) in the practice pharmaceutical and urine samples. The incorporation of machine learning into the sensor design represents a key advancement, enabling the intelligent analysis and the enhanced sensing performance. The Ag/ZIF-67/g-C3N4 composite electrode exhibited remarkable electrochemical properties, including a broad linear detection range (0.01-250.00 mu mol L- 1) and an ultralow detection limit of 5.32 nmol L- 1. The sensor demonstrated excellent selectivity, reproducibility and stability, even in the complex sample matrices. For practical application, the developed sensor achieved high recovery rates (98.00-103.00 % in the pharmaceutical samples and 96.67-103.33 % in the urine samples) with the standard deviations below 2.56 % and 2.26 %, respectively. More importantly, the artificial neural network (ANN), specifically the backpropagation (BP) neural network, was applied to analyze the collected sensor data, successfully predicting and validating the CHL sensing efficiency. This study highlights the synergistic combination of the advanced materials and machine learning for the intelligent and the accurate detection of antibiotics, paving ways for the AI-powered electrochemical sensing platforms with potential applications in both health monitoring and real-world sample analysis.