Ryan Kanavaugh’s Relativity Media had a “hostile environment” that included porn photo shoots at its Beverly Hills headquarters, a lawsuit filed against the Hollywood studio claims.

Adam Fields, who served as Relativity’s co-president for five months, until last September, said in court papers he first grew suspicious about the studio when he saw models traipse through the office on their way to photo shoots.

“Relativity’s cash flow problems became particularly apparent to Fields when he discovered that the so-called ‘big digital initiative’ with which the company was supplementing its income was a pornography Web site,” the suit alleges.

The site wasn’t named in court papers but Variety called it the “raunchy, flesh-peddling website, Egotastic.com, [which] had been operating out of Relativity’s offices.”

Before accepting a four-year, $10 million contract to help lead the studio, Fields claims Kavanaugh “assured him Relativity would be and was sufficiently capitalized following its reorganization.”

But that was not the case, court papers claim.

This and other incidents, including insults from then-president Dana Brunetti, had Fields believing he had joined “a dysfunctional company that operated closer to the cantina scene in ‘Star Wars’ than a normal production company,” the suit asserts.

Fields asserts that Brunetti — Kevin Spacey’s business partner who, like fields, joined Relativity in April when it emerged from Chapter 11 — never gave him a chance.

Dana Brunetti, Kevin Spacey, and Jason BinnGetty Images

An “icy” first meeting devolved into a staff-witnessed altercation that had Brunetti screaming at Fields, “I’ll f–king crush you.”

Fields also accuses Kavanaugh of throwing him under the bus after securing the services of the higher-profile Brunetti.

Relativity fired Fields in September on grounds he leaked company information — a claim his suit denies.

The Post could not reach Kavanaugh, but the founder of the still-floundering studio told the Hollywood trades that Fields picked the wrong profession: “He should be writing fiction.”

In a separate statement, Brunetti said, “Unfortunately, I never once met with any models for a photo shoot.”