Kim Kardashian says speaking openly about her sex tape helped her cope. (Courtesy)

Kim Kardashian opened up about her infamous sex tape and said speaking openly about it helped her cope.

The 40-year-old reality star and her ex-boyfriend Ray J filmed a sex tape in 2002, which was then leaked onto the internet in 2007.

Her sex tape came out around the same time she and her family were about to launch the first series of Keeping Up With The Kardashians.

She told Los Angeles Times: "I do think that, obviously, as producers, I'm sure they loved it. And loved [us] wanting to talk about the elephant in the room. And I probably wouldn't have, unless it was for the show.

"Sometimes I feel like, 'OK, I know I should probably deal and get this over with. Someone's gonna ask me, so I might as well just go ahead and do it."

Kim Kardashian and her ex-boyfriend Ray J. (Courtesy)

She continued: "In a way, filming has helped us deal with things, instead of sweeping them under the rug.

"At the end of the day, I was always open and honest and wanted to share whatever I was going through. I wasn't gonna hold back."

The executive producer of the E! series, Farnaz Farjam, also talked to the publication about how Kim felt about talking about the tape.

He revealed she was initially "conflicted about it" but eventually changed her mind.

Farnaz explained: "I remember Kim being conflicted about it because she hated everything that was going on around that tape.

"We all talked about, 'We just have to own all the controversy around this family' and jumped in with both feet in the first episode.

Kim Kardashian.

"Then, the audience can get to know them at a much deeper level than what's been tabloid headlines."

On the very first episode of the reality show in 2007, Kim immediately opened up about the tape she made with the One Wish singer when they were together.

While Kourtney Kardashian was helping her prepare for her appearance on The Tyra Banks Show, she asked Kim why she made the tape.

Kim then responded: "Because I was horny and I felt like it".

Over a decade on, KUWTK is coming to a close after 20 seasons. The family announced last September that the 20th season would be the very last.