You can usually only replace the pulley. I did just that on my Mercedes CLS55. The pulley costs a fraction from the complete compressor. Its a bit of a hassle to get it replaced and usually involves a special tool to get it off.
If you replace the compressor, the system needs to be drained & refilled off course