Six months after taking office, Gen. Prem Tinsulanond and the coalition government he heads appear to have dissipated much of the public enthusiasm that greeted their coming to power. Already, politically minded Thais have begun speculating on who might eventally replace Prem.

Inflation, persistent shortages of sugar and a decision to extend Prem's military career beyond the supposedly manadtory retirement at age 60 have helped tarnish the white knight image he enjoyed before becoming prime minister in March.

American diplomats have less access to Prem than they did to his predecessor Gen. Kriangsak Chamanan. But Prem has held Thailand to its course as the United State's most important ally on the Southeast Asian mainland.

Despite his slipping popularity, analysts maintain that the soft-spoken four-star general is exceptional agmon Thailand's long line of soldier-politicians. Personally incorruptble, he appears genuinely devoted to the common good within the Thai social framework and has no qualms about taking advice from specialists.

Prem also favors an orderly succession of command within the armed forces and, apparently, a decreased political role for the military as Thailand attempt to nurture parliamentary democracy.

But eary this month, in giving in to pressure from other military leaders to defer his retirement, he demonstrated how deeply Thailand's traditions of military rule are ingrained.

Patterns of power in Bangkok have long dictated that it is wise for a prime minister to be his own Army commander-in-chief. Retaining control of footsoldiers and tanks helps provide security against coups by rival groups of officers, the reasoning goes.

Prem is now Army coommander -- indeed, his elevation to the post in 1978 made him a shoo-in as prime minister. But after turning 60 last month, he publicly announced his intention to resign his commission, as the law required, but said he would stay on as prime minister.

The logical successor to the top Army post was the deputy commander, Gen. Sant Chitpatima, a Prem protege who, like the prime minister, is a native of southern Thailand.

Problems arose because Gen. Sant was unacceptable to many senior officers. Business leaders received anonymous letters calling him corrupt and incompetent. Low circulation newspapers published claims that he and his wife had enriched themselves through the illegal export of tin ore.

Diplomats here doubt, however, that these charges were anything more than a pretext for Sant's personal enemis to block his promotion. "what four-star's wife hasn't got her hand in the till?" asked one military officer.

Soon it was clear that opposition was being coordinated by Gen. Arthit Kamlangek, commander of the Army's 1st Division, the Bangkok-base unit that traditionally provides security for whatever millitary group is in power.

Arthit circulated a petition calling for Prem's term to be extended, later explaining to the press he did it to help "Thai soldiers morale and the Army's solidarity." Two weeks ago, the petition was put before King Bhumibol Adulyadej, Thailand's revered constitutional monarch.

In Thailand the phrase "helping Army solidarity" can be restated as "preventing a coup." While relations probably had not degenerated to the point that dissaffected generals were thinking of putting tanks in the streets, the implications of Arthit's petition were clear.

Meanwhile, Prem continued to repeat his apparently genuine desire to resign his commission. The civiliancontrolled Democrat Party, student groups and the Civil Servants Association of Thailand expresse support for his retirement as an important step toward development of democracy.

But by lodging his petition at the palace, Arthit took the dispute over everyone's head. King Bhumibol told political party leaders during a special 45-minute audience on Sept. 4 that perhaps an extension was in the country's best interests.

Bowing to the king's suggestion, the Democrats quickly announced they would cease opposing an extension, iting "new information" provided by the palace. Student groups dropped their demands, too.

Cabinet ministers quickly followed up by approving an amendment to the Pension Act that would postpone Prem's retirement. Prem, who is known to be a favorite of the royal family, announced that he would, after all, accept another year on the job.

Arthit, many poilitical analysts believe, hopes to be appointed commander of the 1st Army region, which encompasses all of central Thailand. Holding that job for a year, he might acquire sufficent clout to succeed Prem as commander-in-chief.

Having assumed for the past year that the top post was his for the asking Gen. Sant was reportedly crestfallen by what amounted to a decision by Prem to abandon him.

Though the extension has appeared to patch up military relations for the time-being, many Prem supporters are deeply critical of his allowing Arthit to mount such a compaign and create yet another precedent against orderly transfer of power.

Prem's habit of remaining aloof backfired, it is said . . "He's always placed himself above the fray," commented one analyst. "Now he's right down with the rest of the hogs" in the public's eye."

The retirement flap has come at a time when dissatisfaction with government economic policies appear to be on the rise in parliament and in the streets of Bangkok.

Prem's Cabinet is a broadly based coalition comprising the legislature's four major political parties. Deputy Prime Minister Boonchu Rojanasathien, member of the Social Action Party and former head of Thailand's largest private bank, received authority to devise technocratic solutions for Thailand's economic woes.

His team appears to have made few inroads into what most Thais consider the number one problem, inflation of 20 percent or more. But it has probably suffered far more over its handling of what should have been a minor matter, the persistent shortages of granulated sugar on Thais store shelves.

Businessmen blame shortfalls on a bad crop and unrealistic price controls imposed by the government. Boonchuhs team blames hoarding. He has sought the arrest of persons possessing sugar in excess of certain quantities and, in the meantime, increased sugar imports.

Some economists say that the controlled price is too low and suggest that the government raise it to stop the hoarding and to stimulate production. The government's public explanations notwithstanding, such a decision could have extreme political side effects.

This is beause Thal politics are essentially Bangkok politics. The predilections of old Thai families, military men and the Sino-Thai commercial class in this city of 5 million determine who is in power. Thailand's more than 40 million rural dwellers have little direct say in the question.

To keep the city happy, successvie governments have become addicted to subsidizing basic commodities despite rises in world prices. Electricity, water, but tickets and gasoline are often sold at a loss which is made up with government funds. This in an economy that has no pretensions toward socialism.

Bangkok consumers have come to view the low prices as a right. The downfall of Prem's predecessor Gen. Kriangask was speeded by his reluntant decision to bring gasoline pump prices closer in line with what OPEC was charging for oil -- a step economists lauded almost unanimously.

Now Prem's government is widely blamed for creating the sugar shortage -- after all, there was plenty when Kriangsak was in power. Deputy Prime Minister Boonchuhs poorly coordinated efforts to hold the line, however, have won him little affection. Mass circulation newspapers have published numerous cartoons ridiculng his team's handling of the shortage.

"people expect too much of the boonchu team," said a Thai political scientist. "they think he's a miracle man" and complain if results are not immediate. He said it is unlikely any other government would fare better.

Despite its shortcomings Pren's government retains a resonable solid base in Bangkok. Fears that Vietnamese forces in Cambodia might repeat their June incursion into Thailand have probably served in solidify support for him.

But his image has fallen to the point that people are looking beyond him. One measure of Prem's standing is that Gen. Kriangsak, considered at the end of his political career when he resigned six months ago, is now being mentioned as a possible future prime minister.