In general a stud fee is the price paid by the owner of a female horse, or broodmare, to the owner of the male horse, or stallion. This fee is paid when the baby, or foal, can stand and nurse from the mare. If the foal is sold at auction, it has no impact on the stud fee. This fee is always paid by the owner of the mare who is bred to the stallion.
Stud fees are determined by a number of factors, including the quality of the stallion, his racing record, the performance of his offspring, the quality of the stallion's pedigree. As a stallion's career progresses it is not uncommon to see the stud fee increase or decrease as their offspring preform well or rather poorly.
Most North American stud fees can be found here: https://www.bloodhorse.com/stallion-register/