See the "Adding Google Search to your Site" tutorial on the free tools support page:
free-tools/
see the following page for pricing details on the custom search API:
overview
up to 100 queries a day are free, if you do not sign up for paid usage, any queries after the first 100 will fail.