First, I'm going to strongly recommend reading Kahuna's very good
AI War guide - specifically the section about setting up your defenses.
Basically, there are three groups of Starships to worry about.
1) Raid Starships.
2) Plasma Siege Starships.
3) Spire and Zenith Starships.
Raid Starships ignore Force Fields, are very fast, and have high armor. They don't do much damage, but Command Stations don't have many HP. Best defense against them is Grav Turrets to slow them down, and Military Command Stations or Translocators for knockback, to keep them from reaching their target. For the kill, Sniper and Spider Turrets have both the range AND the high multiplier against the Raid Starship's Ultra-Light hull type.
Plasma Siege Starships are slow, medium ranged, but hit hard and do splash damage to things under forcefields. They usually aren't a problem, unless you get distracted and let them into range of your Command Station or protective forcefield. They have an Artillery hull-type, so Bombers and Needler turrets will kill them easily. Just remember to manually target them early, or if the auto-targeting of your units is ignoring them. They aren't hurt to much by Grav turrets, but a 25% or more drop in speed (and hence, time to shoot them) is still good.
Zenith Siege Engines are a fleetship that behaves very similar - take the same care with those.
Finally, the Spire and Zenith Starships. Zenith aren't so bad - they do mediocre damage, but have a HUGE amount of hitpoints. With the Neutron hull-type as well, only MLRS and Missile turrets have a multiplier. Mostly they just take time to kill. So, as mentioned before, Grav Turrets will extend that time.
Spire Starships are the nasty killers of the AI Starship fleets. They have a large number of hitpoints, and the Photon Lance hits HARD. It's terrible against most moving units, but your Command Station and Force Fields aren't moving targets, giving the Spire Starship little chance to miss. So if a Spire Starship manages to get close to your Command Station, you better kill it fast. Best solution: Keep it away from your stuff! Best way to do that is Grav Turrets. A 50% cut in speed means 100% more time to shoot at it.
Spire Starships have Medium hull-type: Missile and Sniper turrets are your go-to turrets. This is convenient, because they are the long ranged turrets, and can be shooting at the target the entire time.
If you are still having trouble, you can always get more turrets. Needler and Laser for the anti-Heavy multiplier, and Sniper/Spider for the range and multipliers, are the popular ones. Missile are a good choice as well, in many cases, although the presence of missile-immune units can limit their usefulness.
Getting Military Command Stations can also give your units, including turrets, a damage bonus of up to 100% - killing Starships up to twice as fast. A good alternative to 'MOAR TURRETS', if you can spare the Knowledge.
The common theme here is that you should place the correct Turret type to counter each Starship type, and above all, get Grav Turrets to give you more time to shoot at the starships and keep them away from your important stuff!