Is there a way to prevent a Macbook Air from sleeping when external monitor is plugged in but power is not?
The power adapter is required for closed display mode on any Apple portable machine, without it you can't use closed display mode. 

Reference:  http://support.apple.com/kb/ht3131

There is however a third party solution, called Caffine.  Which when enabled, forces the mac to stay on until the battery dies, it won't ever sleep.

http://lightheadsw.com/caffeine/