There is growing evidence that opioid prescribing in the United States follows a pattern in which patients who are at the highest risk of adverse outcomes from opioids are more likely to receive long-term opioid therapy. These patients include, in particular, those with substance use disorders (SUDs) and other psychiatric conditions. This study examined health insurance claims among 10,311,961 patients who filled prescriptions for opioids. Specifically, we evaluated how opioid receipt differed among patients with and without a wide range of preexisting psychiatric and behavioral conditions (ie, opioid and nonopioid SUDs, suicide attempts or other self-injury, motor vehicle crashes, and depressive, anxiety, and sleep disorders) and psychoactive medications (ie, antidepressants, benzodiazepines, hypnotics, mood stabilizers, antipsychotics, and medications used for SUD, tobacco cessation, and attention-deficit/hyperactivity disorder). Relative to those without, patients with all assessed psychiatric conditions and medications had modestly greater odds of subsequently filling prescriptions for opioids and, in particular, substantially greater risk of long-term opioid receipt. Increases in risk for long-term opioid receipt in adjusted Cox regressions ranged from approximately 1.5-fold for prior attention-deficit/hyperactivity disorder medication prescriptions (hazard ratio [HR] = 1.53; 95% confidence interval [CI], 1.48-1.58) to approximately 3-fold for prior nonopioid SUD diagnoses (HR = 3.15; 95% CI, 3.06-3.24) and nearly 9-fold for prior opioid use disorder diagnoses (HR = 8.70; 95% CI, 8.20-9.24). In sum, we found evidence of greater opioid receipt among commercially insured patients with a breadth of psychiatric conditions. Future studies assessing behavioral outcomes associated with opioid prescribing should consider preexisting psychiatric conditions.