Shortly after arriving here Wednesday, President Carter put in a rush call to AFL-CIO President Lane Kirkland. The timing could not have been more appropriate. The call came just as Kirkland was congratulating his troops on teaching the president a painful, prime-time lesson about Democratic economics.

The night before, many pro-Carter labor delegates had joined forces with Sen. Edward M. Kennedy at the Democratic National Convention in writing into the party platform a $12 billion dose of antirecession medicine that the president was loathe to swallow.

The showdown rekindled old suspicions among unionists about Carter's credentials as their kind of Democrat, and there was angry talk of walkouts, of neutrality in November -- a rumble just serious enough for Carter to intervene personally with the lure of concessions.

But in reality, labor needed an accommodation as much as the president did, reflecting the political and economic imperatives that have undergirded their 3 1/2 awkward years of uneasy coexistence in Washington.

Just as Carter desperately needs union backing to keep Ronald Reagan from translating blue-collar frustrations into Republican votes this fall, unions, despite their rhetoric to the contrary, have no place to go but Carter if they want to keep Reagan out of the White House -- and they do.

The Wednesday morning telephone call, taken by a started Kirkland in the suddenly hushed hotel caucus room, set in motion a series of high-level meetings that finally gave both sides just enough to hand their hats on for the fall campaign. Carter dodged commitment to the $12 billion jobs program that conflicts with his anti-inflation priorities, but embraced "its spirit and its aims," leaving plenty of room for further maneuvering on both sides.

" ain't much," said a pro-Kennedy union president, "but the alternative (a Reagan presidency) is even less."

With this in mind, both the AFL-CIO and the independent United Auto Workers are expected to endorse the Carter-Mondale ticket within the month. The National Education Association, which taught the more traditional unions a lesson in power-brokering by the simple act of electing more delegates to this convention than anyone else, was already in Carter's corner. The Teamsters, big but politically lethargic, are expected to stay on the sidelines or maybe even go Republican.

Most individual unions in the AFL-CIO, which were sharply split between Carter and Kennedy in the primaries, are expected to line up behind Carter, some with less than stunning enthusiasm. The most conspicuous exception is the Internatinal Association of Machinists, whose defiant president, william Winpisinger, plans to support Citizens Party presidential candidate Barry Commoner.

Pressure on the waverers, led by the large, politically active American Federation of State, County and Municipal Employes, is intense.

AFSCME President Jerry Wurf, angrily dissenting from his AFL-CIO colleagues' acceptance of Carter's jobs program gesture, was immediately set upon by a small army of adiminstration officials, including Labor Secretary Ray Marshall. But Wurf was still holding out today, and the union's endorsement was described as doubtful.

From the pro-Kennedy union corner, the central figure is UAW President Douglas A. Fraser, who played a behind-the-scenes role in trying to fend off convention walkouts by disaffected union delegates as well s an up-front role in signing up before the convention for the speech renominating Vice President Mondale.

In a more subtle way, he also pressed the Carter camp to deal directly with the Kennedy forces in consultations over the platform in hopes of avoiding any last-minute hitches to a closing of ranks at the convention's end tonight.

Unless the UAW rank and file rebels during regional endorsement meetings over the next three weeks and refuses to endorse Carter, which is considered possible but unlikely, Fraser can be expected to continue these efforts through the fall, reaching beyond labor to the liberal community as a whole. Some unions, however, are already touchy about his mediation efforts, and it could be difficult venture.

Even more difficult, most union leaders agree, is the task f a rallying union members -- who no longer can be counted on as a cohesive, lock-step unit in the Democratic parade -- to the Carter banner.

"People are going to ask, 'Look who was president when I lost my job?'" complained Robert A. Nece, a pro-Kennedy convention delegates and president of UAW Local 1031 in Cleveland. "A lot of people will be voting Republican even, because it gives them a chance to vent their frustrations. There's something about Reagan's simplistic solutions that appeals to people."

Other say that Carter is no uninspiring, if not downright unpopular, among union members that they may stay home from the polls in droves, threatening local, state and congressional candidates whom the unions want to see win.

Chatting with reporters earlier this week, Kirkland cautioned against premature judgements, however. Things looked worse for Harry Truman in 1948, he observed. Besides, he added, Carter will look better to union members as the Nov. 4 election approaches. "Just like the country music song," he said, "the girls get prettier at closing time."