Cai Yan was born into a substantial local family in Chenliu , which had a reputation of not having their territory divided for three generations. When his father Cai Leng died, Cai Yong lived with his uncle Cai Zhi while taking great care for his own mother for her last three years. When she died, Cai Yong became known for his arrangement of his mother's tomb. After that, Cai Yong studied composition, mathematics, astronomy, pitch-pipes, and music under Hu Guang , one of the highest ranking officials in the Han court.
Service under Emperor Ling
In the early 160s Cai Yong was recommended to the by the senior eunuchs for his skill with the drums and the guqin. On his way to the capital, Cai Yong feigned illness to return home to study in seclusion. Ten years later in the early 170s, Cai Yong went to serve Qiao Xuan as a clerk, and Qiao Xuan greatly admired his abilities. Afterwards, Cai Yong served as a county magistrate and then a Consultant in the capital, in charge of editing and collating the text in the library. Known for his literary skills, he was constantly commissioned to write eulogies, memorial inscriptions, and the like.
In 175, in fear of parties trying to alter the classics to support their views, Cai Yong and a group of scholars petitioned to have the Five Classics engraved in stone. approved, and the result was the Xiping Stone Classics , completed in 183, which set the canon for future generations of scholars.
Throughout his political career, he was an advocate of restoring ceremonial and often criticized against the eunuchs' influence in politics. He was successful in persuading the emperor to participate in a ritual in the winter of 177 through his memorials, but his attacks on the eunuchs were not so successful.
In the autumn of 178, the scholars were asked for advice on recent ill omens. Cai Yong responded with criticisms of eunuch pretensions. The eunuchs learnt of the attack, and accused Cai Yong and his uncle Cai Zhi of extortion. They were thrown into prison and sentenced to death, but the sentence was later remitted to exile in the northern frontiers. Nine months later, he cited to the throne that his work on the dynastic history and classics were at risk from enemy raids, and was allowed back to the capital. However, he offended the sibling of an influential eunuch during a farewell banquet before his return, which put his position in the capital at risk. Cai Yong fled south to the Wu and Guiji commanderies and stayed there for twelve years.
Service under Dong Zhuo
When Dong Zhuo came to power in 189, he summoned Cai Yong back to the capital. At first Cai Yong was unwilling, but Dong Zhuo enforced his demand with the threat "I can eliminate whole clans", Cai Yong had no choice but to comply. Under Dong Zhuo, Cai Yong was made a General of the Household, and became in charge of revising rituals for Dong Zhuo's new government. Despite Dong Zhuo's admiration of Cai Yong as a scholar and musician, Cai Yong worried about Dong Zhuo's temper and once considered to return home, but was persuaded that he was too well known to escape.
In 192, when Dong Zhuo was killed in a plot by Wang Yun, Cai Yong was put into prison and sentenced to death for allegedly expressing grief at Dong Zhuo's death. Cai Yong and other government officials pleaded with Wang Yun to allow him to finish his work on the history of Han, but Wang Yun denied them, saying: It was said that Wang Yun eventually regretted this decision, but Cai Yong had already died in prison. After his death, pictures were set up in his honour, and commemorative eulogies were composed throughout his home county of Chenliu and the Yan province.
Due to the turmoil in China in the decade after his death, much of his work had been lost. However, Cai Yong had apparently entrusted the bulk of his library to his protégé Wang Can, and it is through his collection that Cai Yong's work can be found in compilations like the ''Book of Later Han''. Few items of his work survive today.
His contributions include:
*The editing of the Xiping Stone Classics
*The compilation of ''Dongguan Hanji''
*''Duduan'' on ceremonial
*''Cai Yong bencao'' on pharmacology
*''Nü Xun'' , advice for women
*''Qin Cao'' on playing the guqin
*''Zhuan shi'' on the aspects of the traditional seal script
*Daughter, name unknown, married to Yang Dao
*Son, name unknown