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.
If you can get hold of another Mac from the same era running a compatible OSX version, you can boot the G4 in target mode and link the two Macs with FireWire. Then use something like CarbonCopyCloner to duplicate the system etc onto the G4. I have done this using an Intel iMac running 10.5 as source and a G5 PowerMac as target. Since 10.5 is a "fat" install there was no issue with different architectures.