Decisions to prescribe opioids to patients depend on many factors, including illness severity, pain assessment, and patient age, race, ethnicity, and gender. Gender and sex disparities have been documented in many healthcare settings, but are understudied in inpatient general medicine hospital settings. We assessed for differences in opioid administration and prescription patterns by legal sex in adult patient hospitalizations from the general medicine service at a large urban academic center. This study included all adult patient hospitalizations discharged from the acute care inpatient general medicine services at the University of California, San Francisco (UCSF) Helen Diller Medical Center at Parnassus Heights from 1/1/2013 to 9/30/2021. The primary outcomes were (1) average daily inpatient opioids received and (2) days of opioids prescribed on discharge. For both outcomes, we first performed logistic regression to assess differences in whether or not any opioids were administered or prescribed. Then, we performed negative binomial regression to assess differences in the amount of opioids given. We also performed all analyses on a subgroup of hospitalizations with pain-related diagnoses. Our study cohort included 48,745 hospitalizations involving 27,777 patients. Of these, 24,398 (50.1%) hospitalizations were female patients and 24,347 (49.9%) were male. Controlling for demographic, clinical, and hospitalization-level variables, female patients were less likely to receive inpatient opioids compared to male patents (adjusted OR 0.87; 95% CI 0.82, 0.92) and received 27.5 fewer morphine milligram equivalents per day on average (95% CI - 39.0, - 16.0). When considering discharge opioids, no significant differences were found between sexes. In the subgroup analysis of pain-related diagnoses, female patients received fewer inpatient opioids. Female patients were less likely to receive inpatient opioids and received fewer opioids when prescribed. Future work to promote equity should identify strategies to ensure all patients receive adequate pain management.