You iMac does not meet the hardware requirements for Target Display Mode.
Niel's response is correct regarding VNC.
You run the Screen Sharing Application (System : Library : CoreServices : Applications : Screen Sharing) on the iMac (you will need to refer to your MacBook Air by its computer name.local to make the connection. You enable System Preferences : Sharing Panel : Screen Sharing on the MBA. You remember to disable this before you connect to any unsecure public network, because your MBA will show up as advertising Shared services on all other Macs on the same Wi-Fi cloud.
A helpful Apple article on screen sharing.