Should be 100% After 18 weeks gestation, most sonographers can determine the gender of a fetus via abdominal ultrasound with near 100% accuracy. When it is not sure by 18 weeks, a repeat scan around 28 weeks will virtually always be definitive.
Cooperation helps. If the kid is a boy it helps if he will cooperate with the sonographer and let the part become evident. You can also get the sex without an amnio using the NIPP, a blood test that finds fetal cells circulating in the mothers blood as early as 8 wks. Originally promoted for paternity testing, it can be used to verify sex and many other issues previously only available with an amnio.