Guinea pigs are herd animals, so you always need at least two - and with no upward limit apart from what practicalities of space, time, and finances allow!
It may take time for guinea pigs to get used to each other if they are not from the same litter, but they'll get there in the end.

Guinea pigs need the company of other guinea pigs
For more tips and advice on introducing guinea pigs to one another, have a look at the Making Introductions section of this guide.
Hailee, 23 February 2023
I have a six year old male guinea pig whose brother just recently passed away. I am wondering if I should get him another companion for my remaining Guinea pig and if so, should it be another male or a spayed female? I heard from someone that bonding two males after one of the males had a past companion that passed away could lead to fighting with the new guinea pig could lead to fighting but I am not sure it that’s true.