BACKGROUND: Hepatitis C and HIV are associated with opioid use disorders (OUD) and injection drug use. Medications for OUD can prevent the spread of HCV and HIV. OBJECTIVE: To describe the prevalence of documented OUD, as well as receipt of office-based medication treatment, among primary care patients with HCV or HIV. DESIGN: Retrospective observational cohort study using electronic health record and insurance data. PARTICIPANTS: Adults ≥ 18 years with ≥ 2 visits to primary care during the study (2014-2016) at 6 healthcare systems across five states (CO, CA, OR, WA, and MN). MAIN MEASURES: The primary outcome was the diagnosis of OUD; the secondary outcome was OUD treatment with buprenorphine or oral/injectable naltrexone. Prevalence of OUD and OUD treatment was calculated across four groups: HCV only; HIV only; HCV and HIV; and neither HCV nor HIV. In addition, adjusted odds ratios (AOR) of OUD treatment associated with HCV and HIV (separately) were estimated, adjusting for age, gender, race/ethnicity, and site. KEY RESULTS: The sample included 1,368,604 persons, of whom 10,042 had HCV, 5821 HIV, and 422 both. The prevalence of diagnosed OUD varied across groups: 11.9% (95% CI: 11.3%, 12.5%) for those with HCV; 1.6% (1.3%, 2.0%) for those with HIV; 8.8% (6.2%, 11.9%) for those with both; and 0.92% (0.91%, 0.94%) among those with neither. Among those with diagnosed OUD, the prevalence of OUD medication treatment was 20.9%, 16.0%, 10.8%, and 22.3%, for those with HCV, HIV, both, and neither, respectively. HCV was not associated with OUD treatment (AOR = 1.03; 0.88, 1.21), whereas patients with HIV had a lower probability of OUD treatment (AOR = 0.43; 0.26, 0.72). CONCLUSIONS: Among patients receiving primary care, those diagnosed with HCV and HIV were more likely to have documented OUD than those without. Patients with HIV were less likely to have documented medication treatment for OUD.