BACKGROUND: Suicide risk prediction models derived from machine learning of electronic health records and insurance claims are an innovation in suicide prevention. Some models do not include opioid-related variables despite the relationship between opioids and suicide. This study evaluated whether inclusion of opioid-related variables improved suicide risk prediction models developed by the Mental Health Research Network. METHODS: Approximately 630 opioid-related variables and interactions terms were introduced into existing suicide prediction models run in datasets of patient visits in mental health care (n = 27,755,401 visits) or primary care when a mental health diagnosis was given (n = 19,340,461 visits). Training and validation datasets were created. LASSO regression with 10-fold validation identified variables to be added to the models. RESULTS: The new models predicting suicide attempts and suicide deaths in the mental health specialty visit sample performed as well as the existing models (new C-statistic for attempts model = 0.855, CI: 0.853-0.857 versus original C-statistic = 0.851, CI 0.848-0.853; death model = 0.868, CI: 0.856-0.879 versus 0.861, CI 0.848-0.875). The new model for suicide death in the primary care sample improved (0.855, CI: 0.837-0.874 versus 0.833, CI 0.813-0.853) while performance of the new model for suicide attempt in that sample degraded (0.843, CI: 0.839-0.847 versus 0.853, CI 0.849-0.857). LIMITATIONS: Analyses did not include patients without recent care, data did not include illicit opioid use or unrecognized opioid use disorder. CONCLUSIONS: Among patients with mental health diagnoses, inclusion of opioid-related variables did not improve prediction of suicide risk beyond mental health predictors.