Thanks for the question.
If you have an existing drug allergy, it is usually safe to try a drug from a different class. You should inform your doctor of your existing drug allergies and your doctor will be able to advise you on the appropriate or suitable drug that you can take.
If you are taking a drug in the same or similar class, there is often a high risk that you can be allergic to the drug. Do consult your doctor on your specific drug allergies and the drug you would like to take and your doctor can advise you further on this.