Cerebrospinal fluid (CSF) leak during endoscopic endonasal transsphenoidal surgery can lead to postoperative complications. The clinical and anatomic risk factors of intraoperative CSF leak are not well defined. We applied a two-dimensional (2D) convolutional neural network (CNN) machine learning model to identify risk factors from preoperative magnetic resonance imaging. All adults who underwent endoscopic endonasal transsphenoidal surgery at our institution from January 2007 to March 2023 who had accessible preoperative stereotactic magnetic resonance imaging were included. A retrospective classic statistical analysis was performed to identify demographic, clinical, and anatomic risk factors of intraoperative CSF leak. Stereotactic T2-weighted brain magnetic resonance imaging scans were used to train and test a 2D CNN model. Of 220 included patients, 81 (36.8%) experienced intraoperative CSF leak. Among all preoperative variables, visual disturbance was the only statistically significant identified risk factor (P= 0.008). The trained 2D CNN model predicted CSF leak with 92% accuracy and area under receiver operating characteristic curve of 0.90 (sensitivity of 86% and specificity of 93%). Class activation mapping of this model revealed that anatomic regions of CSF flow were most important in predicting CSF leak. Further review of the class activation mapping gradients revealed regions of the diaphragma sellae, clinoid processes, temporal horns, and optic nerves to have anatomic correlation to intraoperative CSF leak risk. Additionally, visual disturbances from anatomic compression of the optic chiasm were the only identified clinical risk factor. Our 2D CNN model can help a treating team to better anticipate and prepare for intraoperative CSF leak.