Preheat your air fryer to 400°F (200°C) for about 5 minutes.
In a mixing bowl, combine the olive oil, garlic powder, onion powder, smoked paprika, salt, black pepper, and cayenne pepper (if using).
Add the chicken drumsticks to the bowl, ensuring they are well coated with the spice mixture.
Place the seasoned drumsticks in the air fryer basket in a single layer, ensuring they are not overcrowded. If necessary, work in batches.
Cook the chicken drumsticks in the air fryer at 400°F (200°C) for 25 minutes, turning them halfway through to ensure even cooking.
Use a meat thermometer to check that the internal temperature of the drumsticks has reached at least 165°F (75°C).
Once cooked, remove the drumsticks from the air fryer and let them rest for a couple of minutes before serving.