Preheat the air fryer to 350°F (180°C) for 3 minutes.
In a small bowl, toss the sliced onion with olive oil or butter, salt, pepper, and sugar if using.
Spread the onions in a thin layer in the air fryer basket or tray.
Air fry the onions for 10–12 minutes, shaking or stirring halfway, until golden, soft, and caramelized. Lower heat to 320°F (160°C) if browning too fast.
Lightly oil small oven-safe dishes or silicone egg cups.
Crack 2 eggs into each dish and season with salt and pepper.
Air fry the eggs at 320–340°F (160–170°C) for 7–10 minutes, depending on desired yolk consistency.
Spoon warm caramelized onions over the cooked eggs.
Serve eggs topped with onions on toasted bread or English muffins, adding avocado, fresh herbs, or hot sauce as desired.