Over a medium-high flame, heat the oil and add the onions. Cook them slowly (make sure the heat is high enough that they don’t steam) and allow them to gently caramelize, about 30 minutes. Add salt, pepper, and the butter at the end to season.
Assemble the sandwich. On a slice of rye, layer cheese, onions, and a second layer of cheese. Cover with the second slice of rye. Place on a panini grill and press. Sandwich is ready when the cheese has melted.