i would assume that you are in your starting star system, am i correct?
i found myself in the same position, and actually it played out kinda like the vasari backstory... heres what i did:
1. i figured out that no matter what i did, i could not defend my worlds while effectively turning the tide in my favor
2. i took all my capships (i had 16 by this time) and went on an exodus to a nearby star system, make sure it is the star system that no AI start out in (and there is almost always one in large maps) and go to that system; the system is ussualy smaller than the systems AI and players start out in, and thus alot easier to cleanse if any AI colonized it
3. THIS STEP IS ESSENTIAL:
make ABSOLUTELY SURE that at least 1 of your planets will survive while your fleet is traveling to your new home system, if all your old planets die before you can colonize, its GAME OVER
4. if AI have colonized the system, they rarely, if ever, destroy and take the pirate base, use that to your advantage by doing so to keep yourself alive while your old planets fall
5. if AI have not colonized the system, which will probably not be the case so late in the game you can clear out the pirates and take all the planets, thus rendering the star itself as the only chokepoint you need to defend against maurading AIs
when u leave the systems the AI are in, you should find they attack far less frequently and with almost no force at all
6: if there are AI in the system, establish a base on an untaken planet or pirate base, and then proceed to make war with the AI there... ussualy there is only a single AI presence in these systems, meaning only one large fleet to deal with(ussualy)
if you have all your capships, it should be a fairly decisive victory in which you crush all their capships and send their fleet running
7: proceed to conquering the system, build it up then proceed to conquering the galaxy

8: bask in your glorious victory over the overwhelming forces of the AI