LOS ANGELES (AP) _ Actress-author Lilli Palmer, who appeared in more than 50 movies or stage productions, including ''The Counterfeit Traitor'', ''The Boys from Brazil'' and Alfred Hitchcock's ''Secret Agent'', has died. She was 71.

Miss Palmer died Monday, said Forest Lawn spokesman Dick Fisher. The funeral will be private.

The cause of death was not released, but Victor Ross, Miss Palmer's brother-in-law, said he believed the actress suffered a heart attack.

She was hospitalized with cancer at Cedar-Sinai Medical Center from Jan. 3 until Thursday, when she was released, hospital spokesman Ron Wise said.

''Lilli was a gracious, lovely lady, a pleasure and a delight to work with, a trouper in every sense of that word,'' said Marvin J. Chomsky, producer and co-director of Miss Palmer's final television movie, ''Peter the Great.''

''She held up under the extreme Russian cold and the rigors of shooting in the Soviet Union,'' he said.

The eight-hour NBC-TV miniseries, in which Miss Palmer plays Natalya, mother of Czar Peter the Great of Russia, will be broadcast Sunday through Wednesday.

Miss Palmer appeared in more than 50 movies or stage productions with stars like Rex Harrison, whom she once married, Fred Astaire, William Holden and Clark Gable. But she is perhaps best known in the United States for her appearances in Hitchcock's ''Secret Agent'' in 1936, ''The Four Poster'' in 1952, ''The Counterfeit Traitor'' in 1962 and ''The Boys from Brazil'' in 1978.

She and Harrison were also part of ''Bell, Book and Candle,'' considered the biggest hit of the 1950 Broadway season.

Born in Posen, Germany, to a surgeon and an Austrian actress, Miss Palmer attended the Ilka Gurening dramatic school before her 1932 stage debut in Berlin at age 18.

After the Nazi takeover, she fled to Paris, where she changed her name from Maria Lilli Peiser and appeared in an operetta at the Moulin Rouge.

She made her screen debut in London in 1935. Her British films included ''Secret Agent,'' ''The Man with 1,000 Faces,'' ''A Girl Must Live,'' ''Thunder Rock,'' ''The Gentle Sex,'' ''English Without Tears,'' ''Rake's Progress'' and ''Beware of Pity.''

She was touring England when she met Harrison in November 1939. She was reportedly angry at him because his play was hurting hers at the box office.

Their relationship blossomed during World War II, and he proposed to her by telephone from London to a Nottingham theater.

She is said to have replied, ''Yes, but let me finish the play first.''

The two were married in January 1943, and in 1944 had a son, Carey.

They were divorced in 1957, and Miss Palmer married Carlos Thompson, a writer and actor from Argentina, that year.

In addition to her autobiography, ''Change Lobsters and Dance,'' Miss Palmer has written at least five novels, some of which were best sellers.

''I have made more money with my books than with all my movies,'' she said in a 1984 interview.

Miss Palmer, who also maintained a home in Switzerland, said she liked to paint more than write. Her work has been exhibited in Britain, Germany and Austria, but she contended the prices for it were too high.

''For that money, I would rather buy a little drawing by Picasso than a large painting by Palmer,'' she said.

Despite careers as an actress, mother, writer and painter, Miss Palmer was not satisfied. ''I would like to be a pianist. I would like to sing Isolde (in the Richard Wagner opera) and have an enormous bosom,'' she joked.