Objective. This study addresses radiation-induced toxicity (RIT) challenges in radiotherapy (RT) by developing a personalized treatment planning framework. It leverages patient-specific data and dosimetric information to create an optimization model that limits adverse side effects using constraints learned from historical data. Approach. The study uses the optimization with constraint learning (OCL) framework, incorporating patient-specific factors into the optimization process. It consists of three steps: optimizing the baseline treatment plan using population-wide dosimetric constraints; training a machine learning (ML) model to estimate the patient’s RIT for the baseline plan; and adapting the treatment plan to minimize RIT using ML-learned patient-specific constraints. Various predictive models, including classification trees, ensembles of trees, and neural networks, are applied to predict the probability of grade 2+ radiation pneumonitis (RP2+) for non-small cell lung (NSCLC) cancer patients three months post-RT. The methodology is assessed with four high RP2+ risk NSCLC patients, with the goal of optimizing the dose distribution to constrain the RP2+ outcome below a pre-specified threshold. Conventional and OCL-enhanced plans are compared based on dosimetric parameters and predicted RP2+ risk. Sensitivity analysis on risk thresholds and data uncertainty is performed using a toy NSCLC case. Main results. Experiments show the methodology’s capacity to directly incorporate all predictive models into RT treatment planning. In the four patients studied, mean lung dose and V20 were reduced by an average of 1.78 Gy and 3.66%, resulting in an average RP2+ risk reduction from 95% to 42%. Notably, this reduction maintains tumor coverage, although in two cases, sparing the lung slightly increased spinal cord max-dose (0.23 and 0.79 Gy). Significance. By integrating patient-specific information into learned constraints, the study significantly reduces adverse side effects like RP2+ without compromising target coverage. This unified framework bridges the gap between predicting toxicities and optimizing treatment plans in personalized RT decision-making.