Yeah prostitution is illegal in Thailand. But of course that law was never enforced, unless of course you forgot to pay tea money or pissed off the wrong people.
Technically speaking tipping someone for sex is no different than agreeing on a price beforehand. Not sure why anyone would want to get around prostitution being illegal. At the end of the day, you already paid the off fee, so you are going with a prostitute.