Keflex (cephalexin) is a cephalosporin antibiotic prescribed to treat bacterial infections. Keflex is also used before dental procedures in patients identified with certain heart-related conditions to prevent bacterial infections of the heart known as endocarditis. Keflex is available as a generic drug.