Alpha-solanine is an alkaloid that can inhibit the growth of pathogens and cancer cells, the present study proved that feeding with Bacillus coagulans R11 increases the concentration of alpha-solanine in the cecum of laying hens, which also decreases the abundance of potential pathogens. In addition, the bacteria genera, metabolism pathways and its proteins involved in the biosynthesis of alpha-solanine in the cecum were also characterized. The results showed that B. coagulans R11 feeding could increase the concentration of alpha-solanine, even with lead exposure. Mevalonic acid and MEP/DOXP pathways were both participated in the biosynthesis of alpha-solanine; at the same time, the gut metabolites (S)-2-amino-6-oxohexanoate, N2-succinyl-Lornithine and the bacteria proteins atoB, ispH were shown to be crucial role in the biosynthesis of alpha-solanine in the gut. The genera Faecalibacterium sp. An77 and Faecalibacterium sp. An58 2 were important in the biosynthesis of alpha-solanine, which provided the key proteins atoB and ispH. In addition, alpha-solanine could decrease the abundance of Prevotella sp. 109 and Prevotella marshii. In conclusion, alpha-solanine could be biosynthesized by cecal microorganisms with the stimulation of B. coagulans R11 in the intestine of laying hens, in addition, alpha-solanine was the main compound which also decreased the abundance of gut potential.