Thoth predated the sun god Ra in the Egyptian pantheon. As his cult grew, he morphed into the creator god.
One legend says that in the shape of an ibis, he laid an egg and hatched Ra. Another has it that Thoth used the power of language to create himself -- an earlier version of the biblical statement that "In the beginning was the word." (John 1:1)
Thoth was the keeper of knowledge and the god of writing. He knew the number of the stars and was the author of important religious texts including The Book of the Dead.
This ibis-headed god was also associated with the moon. Some images show him as an ape, or a dog-headed ape.