This will primarily depend on the type of antibiotic you intend to take, the prescribed dose, and how long and in which trimester you’re going to take it. There are antibiotics that are generally considered safe to take throughout pregnancy, such as penicillin, cephalosporin, and erythromycin. However, other antibiotics such as streptomycin, quinolones, and tetracycline have been known to pose potential risks to a fetus and should be avoided altogether by pregnant women.
It is best to weigh the risks a drug poses against the potential detrimental effects of the condition if left untreated. If your doctor sees that an antibiotic is the only cure to an infection or illness, then the only other choice is to prescribe the safest drug available at the safest dosage possible.