Set your Instant Pot to "Sauté" mode and add the butter or olive oil. Once heated, add the thinly sliced onions and sauté for about 10 minutes until they become soft and caramelized.
Add the minced garlic and continue sautéing for another minute until fragrant.
Stir in the balsamic vinegar and cook for a minute to deglaze the pot.
Sprinkle the flour over the onion mixture and stir well to coat the onions evenly.
If using red wine, add it to the pot and stir for a minute to allow the alcohol to cook off.
Pour in the vegetable broth and soy sauce. Add the dried thyme, salt, and pepper to taste. Give it a good stir to combine all the ingredients.
Cancel the "Sauté" mode and close the Instant Pot lid. Set it to "Manual" or "Pressure Cook" mode on high pressure for 10 minutes.
Once the cooking time is complete, allow for a natural pressure release for about 10 minutes, then do a quick release to release any remaining pressure.
Carefully open the lid and give the soup a stir. Adjust the seasoning if needed.
Preheat your oven's broiler. Ladle the soup into oven-safe bowls or crocks, leaving some space at the top. Place a slice of toasted crusty bread on top of each bowl and sprinkle with shredded Gruyere or Swiss cheese.
Place the bowls on a baking sheet and transfer them under the broiler until the cheese is melted and bubbly, usually around 2-3 minutes.
Remove from the oven and let the soup cool slightly before serving. Garnish with fresh thyme leaves if desired.
Enjoy your delicious homemade French onion soup made in the Instant Pot!