The extraction process plays a crucial role in the production of Tibetan medicines. This study focused on assembling a set of online near-infrared (NIR) spectroscopy detection devices for the extraction of medicinal herbs. The original infrared device was transformed into an online detection system. After evaluating the stability of the system, we applied online NIR spectroscopy monitoring to the flavonoid contents (total flavonoids, quercetin-3-O-sophoroside, and luteolin) of Meconopsis quintuplinervia Regel. during the ultrasonic extraction process and determined the extraction endpoint. Nine batches of samples were employed to construct quantitative and discriminant models, half of the remaining two batches of samples are used for external verification. Our research shows that the residual predictive deviation (RPD) values of total flavonoids, quercetin-3-O-sophoroside and luteolin models exceeded 2.5. The R values for external verification of the three ingredients were above 0.9, with RPD values generally exceeding 2 and RSEP values within 10 %, demonstrating the model’s strong predictive performance. Most of the extraction endpoints of the flavonoid components in M. quintuplinervia ranged from 18 to 58 min, with high consistency between the predicted extraction endpoints of the external validation, suggesting accurate determination of extraction endpoints based on predicted values. This study can provide a reference for the online NIR spectroscopy quality monitoring of the extraction process of Chinese and Tibetan herbs.