Onions peel, quarter and in fine rings cut. Peel garlic and chop finely. Wash the thyme, dab dry and remove the leaves. Heat the oil in a large pot. Fry onions, garlic and thyme in it.
Dust with cayenne pepper. Deglaze with 1 liter of water. Bring to the boil, stir in stock. Cover and simmer for about 20 minutes. Add wine to the soup, season with salt, pepper and sugar. Pour soup into 4 ovenproof soup bowls.
Place one slice of bread in each and sprinkle with cheese. Bake in the preheated oven (electric cooker: 200 °C/ convection oven: 175 °C/ gas: level 3) for 8-10 minutes. Remove from the oven and serve immediately.