Ambien is a prescription medication primarily used to treat insomnia. It belongs to a class of drugs called sedative-hypnotics, and its generic name is zolpidem. Ambien works by affecting certain chemicals in the brain that may be unbalanced in people with sleep problems. It helps you fall asleep faster and enjoy a more restful night.