Codeine is an opioid medication that is commonly used to treat mild to moderate pain and to relieve cough. It works by altering the way the brain and nervous system respond to pain. It is often prescribed in combination with other medications, such as acetaminophen or aspirin, to increase its effectiveness for pain relief.