You can get an ultrasound to determine your baby’s sex around weeks 18 to 22 of pregnancy. Otherwise, non-invasive prenatal testing, NIPT, is a blood test that can be done as early as 7 weeks.