Bi Gui's father, Bi Zili, served as a Colonel of Agriculture in the late Eastern Han dynasty during the reign of Emperor Xian. Bi Gui, who was from Dongping Commandery, was known for his talent since he was young. When Cao Rui was still the crown prince, Bi Gui served in the Imperial Academy. He was appointed as a Chief Clerk in the final years of the reign of Cao Pi, the first ruler of Wei. In 227, Cao Rui ascended the throne upon the death of his father, Cao Pi. Bi Gui became very wealthy as he not only served as a Gentleman of the Yellow Gate, but also had his son married to a Wei princess. Bi Gui was appointed as the Inspector of Bing Province later and was known for behaving arrogantly while he was in office. Around the time, the Xianbei tribes in the north often raided the Wei border and killed Wei citizens. Around 233, Budugen, a Xianbei chieftain who had initially submitted to Wei, was discovered to be secretly maintaining contact with Kebineng, another Xianbei leader who had been staging raids at the Wei border. Bi Gui wrote a memorial to the Wei court, requesting for permission to attack the Xianbei and pressure Budugen into remaining loyal to Wei. Cao Rui read the memorial and felt that it was unwise to attack the Xianbei at the time because it would only result in Budugen and Kebineng becoming more united. He issued an order to Bi Gui, ordering the latter to not advance beyond Juzhu. However, Bi Gui received the order too late as he had already led an army past Juzhu and was garrisoning at Yinguan. He ordered his deputies Su Shang and Dong Bi to lead their forces to attack the Xianbei. Kebineng sent about 1,000 horsemen to reinforce Budugen. They encountered the Wei army led by Su Shang and Dong Bi and clashed at Loufan. The Wei forces were defeated and both Su Shang and Dong Bi were killed in action. Budugen rebelled against Wei and led his forces to join Kebineng and they raided Wei's border together. The Xianbei were driven away later by an army led by the Wei general Qin Lang. The Wei official Jiang Ji suggested to Cao Rui to reassign Bi Gui to another province on the grounds that Bi was not competent enough to govern Bing Province, an important location in Wei. During the Zhengshi era in the reign of Cao Fang, Bi Gui was consecutively appointed as Central Protector of the Army, Palace Attendant, Master of Writing and Colonel-Director of Retainers. He became a close aide to the Wei regent Cao Shuang, who often heeded his advice. Bi Gui, Ding Mi and Cao Shuang's other aides urged Cao to be wary of his co-regent Sima Yi, whom they considered a threat to their lord. In 249, Sima Yi successfully seized power from Cao Shuang in the Incident at Gaoping Tombs and had Cao and all his associatesarrested. Bi Gui, Cao Shuang and Cao's other aides were executed along with their families for alleged treason.