The gender of a baby can typically be determined through ultrasound around 18-20 weeks into pregnancy. During this time, the genitals are developed enough to be visible on the ultrasound scan. However, it's important to note that accuracy may vary depending on factors such as fetal position and technician experience. If you're eager to find out earlier, there are non-invasive prenatal tests (NIPT) available that can determine the baby's gender as early as 9-10 weeks into pregnancy, but these tests are usually recommended for high-risk pregnancies or if there is a medical need. It's best to consult with your healthcare provider to discuss your options and decide what is most suitable for you.