Some "answers" that I would give, just to provoke some thoughts:
1) Open war:
First of all try to avoid that several AI's gang up on you. Bribe them into attacking each other, get some AI's to fight on your side, etc. Secondly, if your economy is in bad shape, devote some worlds that don't run immediate risk of being attacked to economy, allowing you to focus on military production on your other planets.
Having a sizeable military (aided by some buildings such as Spin control centers) and spying on the AI's often avoids being attacked.
2) Peacetime:
Consider getting AI's to fight each other, that often keeps them from declaring war on you. Get freighters out to either distant AI capitals or to AI's you want to be friends with. Since TA trade income has decreased quite a bit (unless release 2.X has changed that) but it's particularly useful to improve diplomatic relations.
Also remember to build a decent fleet and research weapons during peacetime, rather than having to rush at the outbreak of a war.
3) Cold war with a less-than-friendly race.
Either try to improve your relation with them or consider striking hard first. But be ready when you attack them, have a sizeable fleet that you can dedicate to attacking, have a few transports ready, etc. A mistake often made is attacking too softly and allowing the AI too much time to recover or build defenses.
4) Different enemies: hard to say, usually I have researched my weapons before I know which AI's will become my mortal enemies so I usually don't adapt them until I see specific defenses against my weapon type. Often I don't bother with defensive research since too much defenses can render your ships rather powerless.
An exception is when they have large fleets of relatively weak ships: in that case some defenses will significantly help your ships to survive combat.
5) Different intelligence levels: for the higher difficulty levels I'd say you need to be even more prepared, make sure your military rating is ahead of the other races. And trade techs with them even more. Give 1 technology to each of 3 AI's in return for their technology (especially unique ones with bonuses that you can't research yourself) and you'll still pull ahead of those 3 AI's in total.
6) Booming economies: if you mean that the AI has a lot of cash, it's a good time to sell technology and build up some cash reserves of your own. If they're really low on cash it's either a good time to give them cash in return for their technology or to swindle them out of their last cash, particularly nice to do before a war erupts 