dnd 5e – How to determine the sex of an unborn baby?

There’s not an awful lot of official options, because this isn’t really something that comes up much in an adventurer’s life.

If this is a plot significant question, then I would personally suggest adding a plot-based resolution to it. Something like “find the legendary midwife of the gods who can tell all these thing at a glance.”

But, if you’re just a player, and you’re stuck with official player options:

A medicine check might work (ask your DM), but there’s no real basis in reality. It took the development of ultrasound in the real world before telling the sex of an unborn child became a thing. (And it’s still wrong sometimes).

So you’re probably in the realm of divination magic.

You’ll probably want to use Commune and directly ask a deity or divine messenger. That requires a 9th level caster and gives you 3 reliable yes-or-no questions per day. They’ll probably know these things if they’re in any way related to the subjects of life, fertility or community or if the NPC is a follower of the same or a closely related deity.

If the child is close to being born, you could also try Divination, which only requires a 7th level caster, but requires you to describe something that happens in the next 7 days.

If you’ve got a Wizard in the group, you could also try Contact other Plane to try and chat with a deity that way, but it might make you go crazy. Otherwise, same rules as Commune apply.