system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How does trace amounts of fetanyl kill drug users but fetanyl is regularly used as a pain medication in hospitals?

ETA (edited to add)- what’s the margin of error between a pain killing dose and a just plain killing dose?
gpt
I routinely prescribe fentanyl in the emergency department.  The answer to your question is very precise dosing.  A normal dose of fentanyl is 25-100 micrograms, which is an incredibly tiny amount.  At that dose you may feel a bit drowsy but it's very unlikely anything bad will happen.

It's easy to reliably give the right dose when you have drugs that are manufactured to strict standards and tested at multiple steps during production.  When you're mixing up drugs for street distribution, quality control gets pretty loose.  A variation of a few milligrams (a few thousand micrograms) one way or another is no big deal for many drugs, but would be lethal with fentanyl.

Another important factor is that patients receiving IV opioids are generally in a monitored setting so we know if their breathing slows down too much and can give them oxygen or even narcan.  If you're using recreational drugs alone or with a group of similarly intoxicated people, nobody will know you overdosed until too late.