Cai Yan was married to Wei Zhongdao in 192, but he died shortly after the marriage. After that Cai Yan was captured by soldiers of the southern Xiongnu people (often referred to in English as the Huns) and taken as a concubine by the Xiongnu nobleman Zuo Xianwang. She lived in an alien land with these non-Han people for twelve years, during which time she gave birth to two sons.
12 years later, the Han Chancellor, Cao Cao, paid a heavy ransom in the name of Cai's father for her release. After Cai was freed, she returned to her homeland but left her children behind in Xiongnu territory. The reason Cao Cao wanted her back was that she was the sole surviving member of her clan and he needed her to placate the spirits of her ancestors.
When she returned to her homeland Cai Yan was recorded in the official history of the Eastern Han dynasty, the History of the Later Han Dynasty (Hou Han shu), as she became the wife of Dong Si, an army officer in the service of Cao Cao.
The bibliographical chapter of the History of the Sui Dynasty (Sui shu), the official history of the Sui dynasty (581-618), notes that there had been a Collected Works of Cai Wenji in one volume but it was then no longer extant. Only three of Cai Yan’s works have survived. Her two works titled Indignant Grief are recorded in the History of the Later Han Dynasty. Eighteen Songs of a Nomad Flute is a long lyric-style poem made up of eighteen songs, or sections, totaling 1,297 characters.
Cai Yan was learned, versatile, eloquent, and musically gifted.
Cai Yan was married to Wei Zhongdao. After his death, she married the Xiongnu chieftain Liu Bao and bore him two sons. Later she returned to her homeland and married again, this time to Dong Si, a local government official from her hometown.