It is possible to determine the sex of a baby as early as 7-8 weeks of pregnancy through genetic testing methods such as chorionic villus sampling (CVS) or amniocentesis. However, it is important to note that these tests are invasive and carry a small risk of complications.
A safer and non-invasive option is to wait until the 18-20 week mark of pregnancy, when a trained medical professional can typically determine the sex of the baby through an ultrasound examination. This method is widely used and considered routine during prenatal care.