It is not known when Li Anqi was born. He came from a line of famed officials, as his grandfather Li Delin served as a high level official under Emperor Wen of Sui, and his father Li Baiyao served as an official of both Sui Dynasty and its successor Tang Dynasty. Li Baiyao also completed the Book of Northern Qi, the official history of Northern Qi, the dynasty under which Li Delin started his career, which Li Delin started.
Li Anqi himself was said to be intelligent and articulate in his youth, and he was able to began interpreting texts when he was six years old. Late in the reign of Emperor Yang of Sui (r. 604-618), Li Baiyao had been demoted to be the military advisor to the governor of Shi'an Prefecture (始安, roughly modern Guilin, Guangxi), when he was intercepted by agrarian rebels near Lake Tai, and the rebels were about to put him to death, when Li Anqi wept and kneeled, asking the rebels to spare his father and to kill him instead. The rebels took pity on Li Anqi and spared them both.
Early in the reign of Emperor Taizong of Tang, Li Anqi, who had become a low level governmental official, served as the official in charge of the imperial seals and staffs. He participated in the editing of the official history of Jin Dynasty (265-420), the Book of Jin, a project headed by the chancellor Fang Xuanling, and after the book was completed, he became an official at the ministry of ceremonies, serving as the deputy head of the department in charge of supplying the descendants of the imperial houses of Tang's predecessors Sui and Northern Zhou.
During Emperor Gaozong's reign
During the Yonghui era of Emperor Taizong's son and successor Emperor Gaozong, Li Anqi served as a mid-level official at the legislative bureau of government (中書省, Zhongshu Sheng), and later served as Huangmen Shilang (黃門侍郎), the deputy head of the examination bureau (門下省, Menxia Sheng). As of 666, when Emperor Gaozong was offering sacrifices to heaven and earth at Mount Tai, Li Anqi was serving as the deputy minister of civil service, and Emperor Gaozong had him author the text for the monument at the altar.
It was said that Li Anqi had the ability to find talented people. Around 667, on one occasion, Emperor Gaozong rebuked his officials for not recommending talented people to be officials. Most of the officials were silent and unable to defend themselves, but Li responded:
I have heard that good and holy emperors had always worked hard at finding good officials and intentionally avoided doing actual duties themselves. If Emperor Yao and Emperor Shun had themselves taken on much duties for themselves and did not employ good officials, they could not have been able to spread their philosophies. Ever since Xia Dynasty and Shang Dynasty, there had been tens of states, and they all tried to entrust affairs of state to good and talented officials so that the state would be in order. There is surely good talent within even a ten-town radius, and you have a large empire now; surely there are many talented people. However, recently, when officials recommended others, they would quickly be defamed as people who were seeking to benefit people close to them. Even before those talented people would be promoted, the people who recommended them would already suffer. Therefore, the officials have wanted to avoid this and thus stayed silent. If Your Imperial Majesty humbles yourself and accept others' words, work hard at listening to recommendations, have no avoidance of both people who are close and people who are inimical, and just employ people base on their talent, and at the same time not accept defamations, who would dare not to give their faithfulness to you? This problem originated from Your Imperial Majesty, not us.
Emperor Gaozong agreed, and he soon made Li the deputy head of the examination bureau again (now with the title of Dong Tai Shilang (東臺侍郎), as the examination bureau had been renamed Dong Tai (東臺)), and in summer 667 gave him the designation Tong Dong Xi Tai Sapin (同東西臺三品), making him a chancellor de facto. However, four months later, he was no longer chancellor, as he was sent to serve as the secretary general at Jing Prefecture (荊州, roughly modern Jingzhou, Hubei). He did not appear to have returned to central government service, and he was said to have died early in Emperor Gaozong's Xianheng era (670-674).