The two NYPD cops who admittedly had sex with a teenager while on-duty — and are now facing potential rape charges — are trying to avoid indictment by attacking their accuser’s credibility, The Post has learned.

In a letter to the Brooklyn District Attorney’s Office, lawyers for disgraced cops Eddie Martins and Richard Hall targeted the young woman’s raunchy social-media posts since the alleged Sept. 15 attack and her $50 million claim against the city.

Examples cited by lawyers John Arlia and Mark Bederow include a “provocative ‘selfie’” the 18-year-old woman posted on Instagram and a tweet in which she “bragged about being followed by the ‘paparazzi’” following an Oct. 13 meeting with prosecutors.

And while arguing this week with a fellow Twitter user over her allegations against the cops, she also said: “Stop clockin my s- -t u loser, I hope ya mommy gets gang raped gangsta 100%,” the letter says.

“This behavior is unprecedented for a depressed victim of a vicious rape,” the lawyers wrote.

The Thursday letter obtained by The Post also says the young woman, who calls herself “Anna Chambers” online, has “rebranded herself as a wannabe rapper named ‘Fi5ty Milli,’ an obvious reference to her lawsuit.”

“She has posted Instagram videos of herself using drugs and rapping in her ‘Fi5ty Milli’ persona about the case while joking about the millions that will be ‘in her bank account,” the letter says.

The defense lawyers urged prosecutors “to further investigate Chambers’ dubious claim before you ask the grand jury to return an indictment against Martins and Hall.”

The accuser has said one cop raped her and both forced her to perform oral sex on them inside a police van after she was caught with loose prescription pills inside Calvert Vaux Park in Coney Island.

The cops claim the sex was consensual.

They were stripped of their guns and badges following the incident and were demoted on Wednesday.

​In a prepared statement, a spokesman for the Brooklyn DA’s Office said: “Without commenting on this ongoing investigation, defense counsel’s characterization of how a rape victim should behave is inaccurate, inappropriate and demeaning.”

​The woman’s lawyer also said, “We’re dealing with a teenager here….and teenagers, they post a lot of things.”

“This is her way of trying to cope. People have different methods of coping. She’s been helpless until now,” lawyer ​​M​ichael​ David said.

“So it doesn’t matter what this teenager says on social media. It can never take away from what these monsters did to her.”