A Cuban who has operated on both sides of the murky and violent world of spies and counterspies surrounding Fidel Castro and his enemies is now trying to enter the United States to tell a tale of intrigue and terrorism to the U.S. Senate.

Carlos Rivero Collado, 38, says he has worked for both the most extreme right-wing Cuban exile groups in the United States and Fidel Castro's intelligence agency. He now lives in Bogota, Colombia, moving from one residence to another to avoid Castro's agents who he says have been ordered to kill him.

Observers of the exile scene in Miami say Rivero Collado's life is perhaps in greater danger in the United States, since he is considered by many exiles to be the most notorious traitor to their cause.

Rivero Collado has given several versions of his life as a double, triple or, possibly, quadruple agent working for and against the Castro government that prevented his father from becoming president of Cuba in 1959.

His latest version - a gripping 17-page statement written like a spy novel - has been widely publicized by the Cuban media in Miami.

While the truthfulness of his story is obscured by rationalizations and posturing, it gives a unique glimpse into the underworld of exiles and spies that has developed since Castro first defied the United States, making Cuba a Communist outpost in the heart of the Western hemisphere. It also shows the passions of the exile community that may become an obstacle to improved relations between Cuba and the United States.

Rivero Collado first left Cuba the day Castro's forces took power - New Year's Day of 1959. His father, Andres Rivero, a supporter of dictator Fulgencio Batista, had recently been elected president but had not yet taken office.

The young exile became active in the quarreling factions of Castro opponents in Miami, and joined the CIA-supported Brigade 2506 that invaded the Bay of Pigs in 1961.

Rivero Collado was taken prisoner when the invassion failed, and was returned to the United States in the prisoners-fortractors deal a year and a half later.

According to testimony at a 1976 Senate hearing by Sgt. Raul Diax of the Miami police department, Rivero Collado was active in anti-Castro activities in the New York-New Jersey area and later in Miami. Rivero Collado says he was jaied for 87 days in Jersey City, N.J., in 1968 for carrying a weapon "which was absolutely necessary for my personal defense."

He was a member of the group that took credit for a failed bazooka attack on the United Nations in 1965, and helped to found groups known as "White Rose" and the "Pragmatists," whose ideology has been described as pseudo-Nazi.

According to Sgt. Diaz, these groups "were highly influenced by Rivero's philosophy."

Rivero Collado said in his statement that he become frustrated in 1969, when "the North Americans ended all aid" to exile groups. He said he decided to take matters into his own hands and try to return to Cuba on his own to assassinate Castro.

The exile said he contacted Cubans at the mission to the United Nations and offered them information on exile activities. He said they doubted him at first but eventually began to take information from him.

In 1974, he says, the Cuban intelligence ageny ordered him to return to Cuba, where he gave many interviews about exile activities and published a book about the exiles called "The Nephews of Uncle Sam."

The Cuban government widely publicized Rivero Collado's statement which accused many exiles of terrorist activity.

One of the interviews was the subject of hearings on Cuban exile terrorism by the Senate Internal Security Subcommittee in May 1976.

In his most recent statement, Rivero Collado tries to ingratiate himself with the people he attacked when he was in Cuba. He apologizes to some exiles, and says the book was heavily edited on Castro's orders.

In a telephone interview from Bogota, Rivero Collado said he hoped to be allowed to return to the United States so he could "submit myself to a tribunal of Brigade 2506."

"My story may seem strange," he added, "but I am willing to prove what I said."

His story now is that while in Cuba he tried to assassinate Castro, but was not able to obtain a weapon or access to the Cuban leader. He claims to have become involved in a conspiracy against Castro within the Cuban military.

Rivero Collado said the other conspirators he had contact with were killed, and he was arrested and tortured. A major unanswered question raised by his story is how he got out of Cuba.

Rivero Collado says he managed to call his family in Miami, and influential friends pressured the Cuban government to let him go. He has expressed thanks to Fidel Castro's sister, Juana, now an exile, and relatives of his Colombian wife for their help in obtaining his release.

Rivero Collado says he has written to several U.S. senators and to President Carter offering to give the U.S. government information about alleged Cuban plots to assassinate former Secretary of State Henry Kissinger and a number of Latin American diplomats.

"I am willing to give the U.S. government all the knowledge I acquired," he said in the telephone interview. "I am willing to cooperate 100 per cent." He said he had applied for a visa at the U.S. embassy in Bogota.

So far, Rivero Collado said, there has been no response to his request for a visa or his offer to provide information. A State Department official said Rivero Collado's visa application has not been received in Washington. The official added that Rivero Collado had probably violated the terms of his residence permit when he went to Cuba in 1974, and it was unlikely he would be allowed to return to the United States.

People who have met Rivero Collado and observers of the exile community in Miami cast doubt on his story and offer a variety of theories to explain his presence in Bogota.

Some suggest that he has been working for Castro all along, first as an agent provocateur, encouraging exiles to attempt dangerous terrorist acts, and now as an allegedly discredited spy sent out "into the cold."

Others describe him as an opportunist always seeking a better deal from one side or the other.

One long-time observer of the exile community, who speculated that Rivero Collado might still be working for Castro, said he would now try to split the exile community.

"If Castro does something he has something up his sleeve," the observer said. "It's difficult for me to swallow that Castro just turned him loose."

A Miami writer who know the exile community well described Rivero Collado as simply an opportunist.

"He probably really defected in 1974," the writer said. "Then he discovered after a while that he couldn't have a car or drink Coca Cola and decided that he wanted to come back."