How to reinstall a G4 iMac without CDs?
Before you do anything, you need to obtain the install disks.  The latest version that was supported was OS X 10.5.8 (Leopard).
I don't recommend downloading them from a torrent site or from an unknown person off the Internet.  Your best bet would be to obtain the genuine installer disks from  eBay, Craigslist, GumTree, etc.  If you have the inclination, you can attempt to install FreeBSD on that G4 (I installed it on a G5 XServe)
Don't wipe your disk until you know you have a working installer. And even if you do have a working installer, make a backup, preferably an image using dd or another cloning tool, of that hard drive.  If things go sideways, you'll have a way to get back to a working machine.  Ideally, I would use a different drive and put the original away for safekeeping.