Certain toxic plants are beneficial for health if small amounts are ingested infrequently and in a specific context of illness. Among our closest living relatives, chimpanzees are found to consume plants with pharmacological properties. Providing insight on the origins of human self-medication, this study investigates the role social systems and physiology (namely gut specialization) play on learning mechanisms involved in the consumption of unusual and potentially bioactive foods by two great ape species. We collected data from a community of 41–44 wild chimpanzees in Uganda (11 months, 2008), and a group of 11–13 wild western gorillas in Central African Republic (10 months, 2008–2009). During feeding, we recorded food consumed, its availability, and social interactions (including observers watching conspecifics and the observers' subsequent activity). Unusual food consumption in chimpanzees was twice higher than in gorillas. Additionally chimpanzees relied more on social information with vertical knowledge transmission on unusual foods by continually acquiring information during their life through mostly observing the fittest (pre-senescent) adults. In contrast, in gorillas observational learning primarily occurred between related immatures, showing instead the importance of horizontal knowledge transmission. As chimpanzees' guts are physiologically less specialized than gorillas (more capable of detoxifying harmful compounds), unusual-food consumption may be more risky for chimpanzees and linked to reasons other than nutrition (like self-medication). Our results show that differences in sociality and physiology between the two species may influence mechanisms that discriminate between plants for nutrition and plants with potential therapeutic dietary components. We conclude that self-medication may have appeared in our ancestors in association with high social tolerance and lack of herbivorous gut specialization.