If you buy a kitten from a good breeder or rehoming/rescue organisation, you should be able to rely on their expertise to tell you what sex it is.
However, if it is from someone with no experience it can be quite difficult when the kitten is small – as kittens grow the process gets easier.
In female cats the anus and vulva openings are close together and look like the letter 'i'. In a male cat there are small testicles under the anus and the penis is below these – see pictures.
Sexing kittens is not always easy! This is a female...
...and this is a male