Headaches account for up to 4.5% of emergency department visits, where they present a significant diagnostic challenge. While primary headaches are benign, secondary headaches can be life-threatening. It is essential to rapidly differentiate between primary and secondary headaches as the latter require immediate diagnostic work-up. Current assessment relies on subjective measures; time constraints can result in overuse of diagnostic neuroimaging, prolonging diagnosis, and adding to economic burden. There is therefore an unmet need for a time- and cost-efficient, quantitative triaging tool to guide further diagnostic testing. Routine blood tests may provide important diagnostic and prognostic biomarkers indicating underlying headache causes. In this retrospective study (approved by the UK Medicines and Healthcare products Regulatory Agency Independent Scientific Advisory Committee for Clinical Practice Research Datalink (CPRD) research [20_000173]), UK CPRD real-world data from patients (n = 121,241) presenting with headache from 1993-2021 were used to generate a predictive model based on a machine learning (ML) approach for primary versus secondary headaches. A ML-based predictive model was constructed using two different methods (logistic regression and random forest) and the following predictors were evaluated: ten standard measurements of complete blood count (CBC) test, 19 ratios of the ten CBC test parameters, and patient demographic and clinical characteristics. The model’s predictive performance was assessed using a set of cross-validated model performance metrics. The final predictive model showed modest predictive accuracy using the random forest method (balanced accuracy: 0.7405). The sensitivity, specificity, false negative rate (incorrect prediction of secondary headache as primary headache), and false positive rate (incorrect prediction of primary headache as secondary headache) were 58%, 90%, 10%, and 42%, respectively. The ML-based prediction model developed could provide a useful time- and cost-effective quantitative clinical tool to facilitate the triaging of patients presenting to the clinic with headache.