House Speaker Thomas P. (Tip) O'Neill Jr. has been showing off a photograph President Carter recently sent him as a momento of the private dinner the two shared in the White House three weeks ago.

The photo shows Carter intently listening to a forcefully gesturing Speaker. Across the top of that picture, Carter has written, "Thanks for another political lesson."

At that dinner, O'Neill told Carter, in his customary straightforward fashion, that a confrontation between Congress and the White House - with Carter vetoing three major bills - would lead to disaster for both.

Congress, O'Neill told Carter, could probably override only one of the vetoes - that of a Labor-HEW appropriation with what O'Neill calls money for the "sick, the halt and the lame." So O'Neill acknowledged Carter could show his muscle to Congress.

But O'Neill added, Carter would pay a price, because the resulting resentment might cause Congress to take out its ire on the rest of his legislative priorities - his energy package, voter registration, the consumer protection agency. As a result, neither Congress nor the President would have a record of accomplishment to take to the people, and they could both lose where it counts - at the polls.

Until last week, O'Neill was not sure how much of that message had gotten through."He only says, 'Uhhuh, I understand, I appreciate that," O'Neill said.

But by the end of the week of compromise and accommodation, both sides were hailing an era of cooperation between Democrats in Congress and Carter.

House members talked about the "maturing of the White House." Democratic Whip John Brademas (Ind.) said the administration had finally learned that each proposal is not an isolated case, but that they are linked, and that work and cooperation on legislation is a continuous process.

At the same time, the White House staff was claiming that Congress had finally learned that Carter is a strong President determined to have his way.

The problems between Congress and the White House are far from over. There are still complaints tha the administration pays insufficient attention to matters of patronage, and that is lobbyists are often sadly lacking in Hill acumen.

Despite the complaints, one House staff member called it a "historic week, marking a turning point in which this Congress and this President decided on accommodation rather the confrontation."

And the man getting credit as the "great accommodator" was Tip O'Neill, the old-fashioned Boston pol, who took it upon himself to teach the politically puritannica President the first lesson of a ward heeler - "You scratch our backs and we'll scratch yours."

"I think I've been selling a good pitch," O'Neill said. "I think I've been far more candid than the rest" of the hill leaders.

O'Neill has also preached to Carter to ease up on proposals he sends to Congress, not only because Congress cannot work that fast, but because each new controversial proposal increases his chances of losing.

"I've told him for everything he sends up there's a lobby group waiting to go to work on it, and we're the ones that have to deal with them."

The leaders asked carter to tell them what his priorities are for passage of legislation for the rest of the year.

They had in mind about four or five big ticket items, like Social Security funding, the minimum wage and a few others.

Carter gave them a list, but it contained some 70 items. "Well," said an aide ruefull, "I guess you can't expect them to digest all the lessons at once."

Yet despite a rocky start, there are signs that Carter and O'Neill are beginning to like each other. O'Neill calls Carter "a beautiful guy, one on one. You haven't been such charisma since John Kennedy."

Vice President Mondale says Carter and O'Neill are "getting along very well. Carter's come to like him very much." Carter has reportedly courted O'Neill as assiduously as anyone on Capitol Hill.

As a result of their private dinner. O'Neill last week was working to compromise on the three bills Carter had threatened to veto - a farm bill and Labor-HEW appropriations Carter feels are too expensive, and an appropriations bill containing water projects Carter wants to cut out.

On the farm bill, O'Neill believes Carter will not veto it if Congress finally adopts the lower target prices for supports in the House bill. Likewise, if O'Neill can keep House members from adding money to the Labor-HEW bill when it comes to the floor this week, he thinks Carter will sign it. The water projects may ultimately draw a veto, but O'Neill hopes the Senate may cut enough projects to appease the President.

In return, O'Neill is working hard for one of the President's top priorities that is now foundering in the House, a bill to allow voters to register on the same day they vote. Opposition has come from the South and from big cities, such as chicago and Philadelphia.

First of all, the political machines in those cities are not so sure they want to register voters whose loyalty is not certifiable. Secondly, they have nightmares about everybody coming to the polling places after work, lines four blocks long discouraging the voters and causing many to go home.

Last Monday O'Neill flew out to Cook County to talk to Chicago Mayor Michael A. Bilandic, and Cook County officials. The Cook County Democratic machine controls at least a dozen votes in the House. O'Neill thinks they may have worked out a compromise, by allowing the officials to set up satellite polling places, where people not previously registered could go to vote.

All of this victory is aimed at averting what O'Neill believes would be a disaster for what he cares about most - the House, the Democratic Party and his own reputation as a strong and powerful Speaker.

The disaster looms because, as one aide put it, "For the first time you have a truly independent President, a man elected by the taxpayers' money, who ran against Washington and is beholden to no one. At the same time you have an increasingly indepedent Congress that learned from Vietnam and Watergate that Presidents aren't infallible. And one in which there are a lot of young members just like Jimmy Carter - independent as hell."

"O'Neill has got to walk a tightrope between those two. He can't ignore the President's wishes. He can't ignore the President's wishes. He can't appear to be the President's waterboy. He's got to get the President to understand Congress. He's got to be blunt with him, tell him what won't sell. At the same time he's got to pass that stuff we've been flooded with."

O'Neill is, as his longtime best friend and former roommate, Rep. Edward P. Boland (D-Mass.) said, "a great believer in polls." He is aware of the polls showing Carter's popularity at around 86 per cent.

But O'Neill is also aware that with his constituency - Democrats in the House of Representatives, his own popularity is just about as high. Many House members already speak of him as a "strong Speaker" even a "great one."

Both men, in other words, have their respective strengths and constituencies. And so the key to the future of their relationship will be the manner in which the President and the Speaker respond to that reality.