代王
In 617, the general Li Yuan rose against Emperor Yang, and later that year captured the capital Chang'an, declaring Emperor Yang's grandson Yang You the Prince of Dai emperor (as Emperor Gong) but retaining power himself as regent. Li Yuan's staff member Li Gang (李綱) recommended Wang Gui, as he knew Wang Gui's capabilities. Li Yuan made Wang Gui a military advisor to his heir apparent Li Jiancheng.