Kim Kardashian narrowly avoided an embarrassing run-in with her sex-tape partner Ray J as she dined out with her family in Miami.

The family — Bruce Jenner, mom Kris, Kim, Kourtney, Khloe, Kylie — and friend Jonathan Cheban dined at Prime 112 in Miami Sunday night to mark the nine-year anniversary of Robert Kardashian’s death.

But attention-loving Kim couldn’t resist tweeting their dinner location — and soon a giant press pack had swarmed, quickly followed by Ray J, who shot the infamous 2003 sex tape with Kim which propelled her to fame when it was made public in 2007.

Sources tell us Kim fled just in time to avoid Ray J, who we are told wasn’t looking for a rematch or a sex-tape sequel.

A fellow diner tells us, “Kim and Kris Jenner posed for pictures in front of the restaurant to allow Kourtney and son Mason to sneak out the side entrance unnoticed. And just by a few moments, Kim missed Ray J, who was seen entering the restaurant to meet a large group of friends including boxer Floyd Mayweather.”

Meanwhile, friends are wondering if things are cooling off between Kim and her new beau, Kanye West, who appeared in her life just in time to take the attention away from her disastrous marriage and divorce with Kris Humphries.

While Kim is in Miami to film her family reality show, Kanye has been living it up at Paris fashion week, even though he isn’t showing his clothing line there. On Sunday he was at a party hosted by Diane von Furstenberg and Olivier Zahm to celebrate the 20th anniversary of Purple magazine.

Another source tells us that things between Kanye and Kim are “cooling off” because “he’s getting tired of the constant press and promotion. He’s not as tight with her as he was.”

But a source close to the Kardashian klan told us, “The family did have dinner, but they never saw Ray J or Floyd. And there’s no truth that Kanye and Kim are cooling off.”