Codeine is an opioid analgesic used to treat mild to moderate pain and, in some cases, cough. It works by changing how the brain and nervous system respond to pain. Because it may cause dependence, drowsiness, slowed breathing, and misuse, it is usually dispensed only with a valid prescription.