The safest way to keep bettas is singly. They need friends like you need teeth in your colon; bettas are solitary, territorial, aggressive predators by nature. This is compounded by selective breeding for aggression over hundreds of years since these have been a popular fighting animal in their countries of origin.
While some bettas are more peaceable and will interact passively with other fish, especially bottom/middle dwellers with small finnage and dull colors, many will feel the need to constantly defend their territory against anything that moves. From what I've read time and time again on the betta forum I moderate, it isn't uncommon for them to be fine in a community for months, then one day randomly "snap" and kill tankmates. And it's not just the males; females can be equally nasty as males, particularly in their interactions with one another. Likewise, many community fish harass bettas by nipping their fins, and because that cumbersome finnage is lousy for fast retreats, they often get beat up or killed when another fish decides to be the aggressor in the situation.
Providing a wide, shallow, well-planted tank with the betta and no tankmates is the least stressful and safest to the betta; they're fun to make small, naturalistic habitats for and make a great centerpiece fish, so why not save everyone some grief? If they are to be housed with other fish, any attempts at integrating them into a community should be done carefully with a good deal of research and constant observation.
This photo pretty much sums up my opinion of keeping bettas with other fish as a seasoned betta keeper of many years.