Addiction, and specifically OUD is complicated, but there is real evidence that genetics plays a sizeable role in the physiological dependence side of it.
However the main risk factor for trying and then abusing opioids, for example, is trauma, typically but not only in childhood. Basically, it’s both nature and nurture, as most things are. Where the percentages lie for both, I don’t think we know yet.