I think around 15wks on ultrasound
genitals don't develop until 12 weeks...before then all babies have a small bump and two larger bumps. in a girl, these become the clitoris and labia, in boys it becomes the penis and testicles. a blood test can tell you earlier, but they aren't always covered by insurance
I dont even think the boy or girl parts are fully developed yet. But you can get a blood test. Itll tell you. I think 10 weeks is the earliest so you should be good.