How did Jesus know he could do miracles?

The Bible tells us that Jesus had both a human nature, and a divine nature, meaning he was a complete human being like us, but also he was fully God.  So he would have known because of his divine nature, who he was and how he could act.

In addition, we know that Jesus was taught the Scriptures, so as he read them, he would have understood where he stood in their fulfilment.