Some people keep homes on either coast. Anais Nin, the mid-20th century writer known for her tell-all diaries and steamy erotica, kept two husbands: one in New York and one in Los Angeles.

In the new book “Apprenticed to Venus: My Secret Life With Anais Nin” (Arcade Publishing), Tristine Rainer opens up about the many years she spent as Nin’s faithful acolyte, and how her most important task was helping her mentor maintain a secret double life. Nin had been married to Hugo Guiler for over two decades when she got engaged to her much younger lover, Rupert Pole, after meeting him at a smoky literary party in the East Village in 1947.

The deception was so elaborate that Nin maintained a series of files she called her “lie box,” in which she kept track of the stories invented for both husbands.

At the time, Pole was a handsome, out-of-work actor leaving New York for a job as a forest ranger in California. After a few passionate nights together, Nin invented a cover story for Guiler — whom she had already cheated on with “Tropic of Cancer” author Henry Miller — so that she could join Pole on his cross-country drive.

It was the beginning of what Nin described to Rainer as her “trapeze”: an endless swing back and forth between two cities and two men.

For their trip, Pole bought Nin a pretend wedding ring from Woolworths so they could believably register at motels as husband and wife. But she officially became a bigamist in 1955. Pole, who thought Nin was long divorced from Guiler, proposed to his girlfriend with a diamond ring at the bottom of a glass of orange juice. They were married in a courtroom in Arizona, after Nin had already spent eight years juggling two partners.

“At first, her fear of being found out [as a bigamist] and arrested by the authorities scared her day and night,” Rainer writes. Eventually, she got used to it.

The deception was so elaborate that Nin maintained a series of files she called her “lie box,” in which she kept track of the stories invented for both husbands. “She was the accountant of her bigamy,” Rainer explains, “keeping double books, ever fearful of discovery as a love embezzler.”

But Nin couldn’t do it all alone, and so she had friends like Rainer, a student at UCLA at the time, covering for her. Rainer first met the French diarist in New York in 1962, when her godmother sent her on an errand to deliver a pile of books to Nin and Guiler’s Greenwich Village apartment. Nin invited the young woman to join her and her friends at a jazz club in Harlem that night, and Rainer couldn’t believe her luck. She vowed she would do anything to become a part of Nin and Guiler’s sophisticated inner circle.

Nin used that eagerness to her advantage. Later, after Rainer and her mentor became close enough for Nin to reveal the truth about her relationships with both men, she enlisted Rainer’s help. For a long time, Nin had been justifying her many long trips out West by telling Guiler that she was spending time at a fictitious “rest ranch” — one that didn’t allow guests to take phone calls. However, Guiler had become suspicious and Nin needed a new story. She convinced Rainer, an English major, to steal a pile of department letterhead and send an official-looking letter to New York, inviting Nin to give a series of lectures at the university. That way, Nin could justify a number of visits to California, where she lived with Pole in Hollywood.

Nin even rented a post-office box in Rainer’s name, where Guiler could send his wife mail. Rainer was a willing participant in the lie: “I loved her terrible secret,” she writes. “She’d beaten the system of marriage that kept women down.” Their arrangement worked out well until the winter of 1964, when Pole announced he was coming to New York; he was suspicious that his wife was still sharing an apartment with Guiler when she was there.

Nin, by this time a very skillful liar, booked Pole a room at the Washington Square Hotel, directly across the park from her New York City home. The scope of her trapeze had considerably narrowed and for weeks, she swung back and forth under the Washington Square arch, blaming yet another invented job for her frantic behavior and long daily absences.

Despite some very close calls, Nin managed to hide the truth from both men until the mid-1970s, when she became sick with cancer. Then, practically on her deathbed, she confessed — and Guiler and Pole absolved her. Deep down, they both understood why she had never been able to let go of the other one.

Guiler provided comfort and financial stability at a time when she hadn’t yet received recognition for her work. Pole was the opposite: a source of inspiration and endless passion for the woman who ultimately got famous writing about sex.

Rainer, who came to resent her mentor almost as much as she loved her, believes both husbands willfully turned a blind eye because it was worth it: “They both realized,” she writes, “that having half of Anais Nin was better than all of any other woman.”