All perfect praise be to Allah, The Lord of the worlds. I testify that there is none worthy of worship except Allah and that Muhammad, sallallahu ‘alayhi wa sallam, is His slave and Messenger.
First of all, you should know that the scholars held different views about the ruling on eating insects. The correct view adopted at Islamweb is the view held by the majority of the scholars, which is that eating insects is unlawful because they are considered Khabaa’ith (foul things).
However, since you ate it by mistake, there is no sin on you, and you did not have to rinse your mouth afterward because although insects are unlawful to eat, they are ritually pure and your mouth is not defiled by eating it. Your prayer is valid and you are not required to repeat it.
Allah knows best.