I have an electronic locked safe that has the back up key broken off in the lock. Now, the easy solution is to use the electronic keypad but the batteries have died and it is unusable. I've tried the Rare earth magnet trick but didn't have a strong enough magnet to pull up the solenoid.
Try sticking one or two fine bladed screwdrivers down the side of the key sufficiently that you can turn them and operate the lock. Dont force it! If it wont turn easily it would be better to try sticking a third screwdriver sideways between the stems of the two driver and rotating it
With the door open you should be able to remove the lock barrel, push the broken part of the key out of it and take it to a key cutting place where they will use it to cut a new one. Take the barrel too so they can check it works without wasting a trip home for you
There are several videos on video sharing sites showing solutions for this problem.
The easiest solution is to take some plastic object (stick-shaped is best, a glue-gun stick is shown in the videos). Using some heat (lit match, lighter, candle...) melt one end of the plastic stick. Attach the melted plastic to the key inside the safe - try to NOT attach the melted plastic to the safe itself. Pull gently. Repeat if needed.
An alternative solution involves a welding machine. Instead of the plastic, you attach the welding electrode to the broken key inside the lock.
Superglue can attach pretty much anything to the broken key also. Be very cautious, not to attach the broken key to the lock itself.
Rare earth magnet trick but didn't have a strong enough magnet to pull up the solenoid.
I do not know what material the key is made of, but if the key is made of some bras, then no magnet in the world will help. You might want to try the magnet first on the part of the key which is still in your hands.
Be aware that the pulling force increases dramatically if the magnet actually touches the key - and only if the key is ferrous.