Nxivm’s accused cult leader played twisted sex games with his top female lieutenants — and even planned to build a basement dungeon to cage some of them, a former disciple testified Monday.

Supposed self-help guru Keith Raniere’s sick methods of control included having his female “slave masters’’ whipped when he thought they transgressed and viciously paddling them with a rubber-spiked sex toy, Lauren Salzman said in Brooklyn federal court.

Meanwhile, Raniere was busy plotting to build a dungeon in a home the group bought in upstate Waterford — while one of his top lieutenants was ordering “BDSM sex-torture things … handcuffs, nipple clamps … all things that were sexual in nature,’’ said Salzman, 42.

“They were making a dungeon in the basement. There would be a cage for the people who were most committed to growth,’’ Salzman, a onetime “slave master’’ and longtime lover of Raniere, said she was told by the Svengali and a top sidekick, Daniela Padilla Bergeron.

Raniere had sex with seven of the eight members of his all-female inner circle, known as DOS — including TV’s “Smallville” actress Allison Mack and her now-wife, Nicki Clyne, Salzman said.

He also coerced some of them to have threesomes with him, including Salzman and Mack, the witness said.

The only one he didn’t have sex with was Rosa Laura Junco, Salzman said. She didn’t explain why.

Testifying at Raniere’s sex-trafficking trial, Salzman, who has already copped a plea, said that after the group of women shed their clothes for a photo before every meeting, the punishment began.

“We would take the naked picture, and everyone would take the number of whips commensurate with our failures,’’ she said.

Raniere “would call in” to make sure people were being hit hard enough, Salzman said.

He was very specific about the “wrist flick’’ and making sure it was done to inflict the most pain, she said.

The understanding with the paddling was that “it should really hurt,’’ Salzman said.

“We were to paddle each other.”

At times, though, Raniere would grab the spiked sex paddle himself to deliver the blows, she said.

“Daniela told me she had been paddled by Keith’’ and that it was excruciating, the witness said.

One time, Raniere accused Daniela of being “prideful,’’ Salzman said, “and she was on the floor, and he kicked her.

“These things began to get scary.’’

Salzman said that while it didn’t appear the dungeon was ever built, two cages had been ordered from a sex toy manufacturer in 2017. One of them was part of a $900 order that included the studded paddle and a “puppy trainer’’ perfect for “naughty slaves,’’ another witness testified last week.

Salzman said she was worried that she was going to eventually be asked to get in the dungeon cage.

She said the idea was that “you were just in there till they let you out. It could be 10 minutes. It could be an hour. it could be days.’’

“What I imagined was being there and having to go to the bathroom.’’

She said the idea seemed to be that of “complete humiliation.’’

If that was the goal, Raniere only allegedly reinforced it by demanding troves of photos of his women’s private parts.

“He looked at a picture specifically of my vagina and said he wanted to know why it looked groomed,’’ Salzman said.

“We were taking naked pictures — up-close vagina pictures — three times a week. We were running out of ideas as to what to do’’ to keep Raniere satisfied.

She said that at one point, the sick guru suggested they stage crimes, such as breaking into someone’s house and stealing things.