U.S. Ambassador William Sullivan finds himself in the diplomatically awkward position these days of being the last in a long line of American envoys sent to Iran to reaffirm daily his government's unswerving faith in the shah.

That faith has been endorsed and encouraged for a quarter century by all American presidents except John F. Kennedy, but now the shah is in deep trouble. Most of the American community has fled and major U.S. economic, military and strategic interests are in jeopardy, so Sullivan is the man on the spot.

Starting with naval gunfire support duty off Normandy beaches on D-Day, Sullivan has spent most of his life getting used to tough situations, and surviving.

His diplomatic record includes serving as ambassador in Laos during the Indochina war, ambassador to the Philippines when President Ferdinand Marcos was whipping up anti-American feeling over U.S. military bases there and as assistant secretary of state handling the Vietnam peace negotiations.

Judging from sympathetic comments from many of his fellow ambassadors here, they feel he is now in the situation every diplomat dreads, the ideal candidate to become scapegoat in the American scheme of things where someone often takes the blame for a reverse of this dimension of Iran.

Sullivan has been described as too clever to allow Iran's descent into turmoil to condemn his career like that of Graham Martin, who never recovered from having presided as U.S. ambassador over the last-minute retreat of Americans from Saigon as Communist Vietnamese occupied the city.

There is a big difference between what happened in Vietnam and what is happening in Iran, where communism is not the problem. But Sullivan is known to have talked about the possible consequences if Iran is "lost."

Sullivan himself is saying nothing in public. In any case, foreign diplomats here have raised eyebrows less often at optimism about the shah emanating from his American Embassy than at the series of pronouncements of support for the monarch issued by the Carter administration in Washington until a just a few days ago.

Along with the British, and to a lesser extent the West Germans, the United States was one of the few countries to continue its policy of allout support for the shah even at the risk of jeopardizing the lives of U.S. nationals in this country where protests are turning increasingly xenophobic.

The Carter administration's talk about sending the 7th Fleet to waters off Iran helped stir up even more anti-American sentiment, nudged along by Soviet propagandists broadcasting from Moscow.

Preoccupied by hopes of an Egyptian-Israeli peace settlement, the State Department gave every sign of underestimating the situation in Iran at the very time it became increasingly doubtful that propping up the shah was a workable policy.

When and how Sullivan began switching gears away from total support of the shah is locked in the secrecy of cable traffic.

Whatever the virtues of the Sullivan embassy -- it is strong on economics, oil and the military question -- much of its political reporting has been proven wrong by recent events.

As late as the end of October, the embassy was still telling visitors that the shah was very much in control. The opposition -- lay and religious -- did not present a definite threat to his monarchy no matter how outwardly troublesome, U.S. diplomats maintained.

This was after more than a thousand Iranians had died in clashes around the country, starting in January and reaching an unmistakable watershed Sept. 8, when troops shot and killed at least 120 people in Tehran's Jaleh Square.

Even earlier in the year the State Department, basing its assessment on an embassy report, published a rosecolored evaluation of human rights in Iran. It systematically sought to put the happiest gloss on the shah's liberalization program in the face of disturbing evidence of Iranian government misdeeds.

Sullivan inherited an embassy that already had deeply rooted shortcomings when he arrived in June 1977, months after the departure of his predecessor, Richard Helms.

There is no evidence that Helms warned Washington that its policy, once described as "giving the shah everything he wants," was overloading this country's ability to absorb the massive amounts of petrodollars brought in when the monarch helped quadruple oil prices after 1973.

Britain, France, West Germany, Italy, Japan -- all eager to sell Iran industrial plants and anything else to help pay for expensive oil -- also displayed the same lack of concern.

But the United States was the premier foreign power influence in Iran and the shah threw such extraordinary weight around Washington that Kennedy was the only president to question his increasingly authoritarian and megalomaniacal behavior.

The U.S. Embassy in Tehran for decades has been known as an apologist operation suffering that most fatal of diplomatic diseases -- localities, which here meant identification of American national interests with the survival of the shah and his family.

Was it really wise, for instance, to arm Iran so heavily and encourage the shah's ambitious regional power goals? The theoretical adversary, the Soviet Union, never was really impressed, despite its propaganda complaints. Iran's smaller neighbors -- ranging from radical Iraq to the weak but rich oil emirates and Saudi Arabia itself -- became nervous and ended up involved in similar heavy purchases of arms.

Aside from such geopolitical considerations, the armed forces' drain on scarce skilled manpower also slowed progress since it starved industry of trained personnel and encouraged the outbidding that fueled inflation.

U.S. experts may have noticed all this, but the U.S. Embassy often gave visitors the impression it suffered from fear of offending the shah.

To Sullivan's credit, according to a fellow ambassador, it was only days after his arrival that he sized up the dangerous strains that the shah's quick development plans were placing on the economy.

However, the risk of a religious resurgence of the kind that has all but driven the shah from his throne in the past year was considered so farfetched by all observers here throughout 1977 that even the Soviet ambassador dismissed such suggestions as ludicrous.

President Carter's human rights policy had already named Iran as an exception by invoking American national interest -- read oil.

But Sullivan's staff insists he should be credited with having ordered within months of his arrival that the embassy contact opposition politicians.

Other Western diplomats, however, recall that these moves took place later, and that when they did those assigned to make the contacts were ill-chosen.

Some, if not all, other Western embassies went further, faster and more thoroughly in contacting the opposition once it became apparent that the shah himself had reversed the longstanding policy of making juicy contracts dependent on refusal to see the opposition. Even today, there is an impression that Sullivan's political section is weak on the opposition. Meaningful contact with some of the younger leaders especially among the religious opposition as opposed to the Westernized grandees of north Tehran, appear to have started only some time this fall.

Only after installation of the military government in November did the embassy bring in a specialist in Iranian religious affairs, the unmistakable fountainhead of the opposition challenging the shah for many months.