Best to apply in your own country at the Thai consulate. You’ll get a non immigrant OA visa that can work for almost two years. I think it’s better to wait until at least three months before you plan on traveling. If you come into Thailand on a tourist visa you’ll have to covert it and jump through a bunch of hoops. Also you can’t open a thai bank account unless you have a retirement or work visa. They stopped giving accounts to foreigners with tourist visas.