You have to buy a code as there is no way to unlock the AHD for free. In order to enter the code, you need to be on a pure stock or close-to-pure stock rom in order to enter the unlock code.
If you're an AT&T customer, they may give you the code for free.
I purchased this one: http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=221338036489 and the seller sended me the unlock code within a couple of hours. Also you can use gsmliberty.net. They are a very trusted site and works.