Menachem Begin and Anwar Sadat went to Capitol Hill yesterday to celebrate their new Israeli Egyptian peace treaty, and both took the occasion to warn if a new Soviet threat that must be met.

In separate, individual appearances before members of the House and Senate, Begin and Sadat each proposed that his nation could be a valuable ally in the Middle East to help the United States respond to Soviet adventurism.

On other issues the two leaders were not so unanimous. Sadat called on the United States to "use your oosition to moderate the position of the Israelis" on the sensitive issue of autonomy for Arabs living in Israeli-occupied territory on the West Bank and in the Gaza Strip.

Sadat said nogotiations on some form of autonomy for the Arabs will provide "a good test" of the real prospects for long-term peace between Israel and its Arab neighbors.

Speaking of the Soviet danger, Sadat said there was "a problem of intervention" in the Middle East, a reference to the Soviet and Cuban roles in the region. To deal with that problem, Sadat said, "there must be a millitary power that can serve a deterrent." He proposed that his country, Egypt, play that role-an implicit request for substantial military aid from the United States.

"We want to be strong enough to maintain peace," Sadat said.

Begin spoke glumly of recent world events, which he said demonstrated that "liberty is in danger."

"During the last two years, the Soviet Union took over by proxy six countries," Begin said, then enumerated seven: Angola, Mozambique, South Yemen, Afghanistan, Ethiopia, Vietnam and Cambodia.

"We must be careful," Begin warned, adding that strategic, nuclear weaponds are no deterrent to "taking over country after country by proxy."

Then, like Sadat, Begin offered up his own country as a reassuring factor: "Please take into consideration ...that you hava a realally and a stableally in the Middle East"-Israel. "Let us work together to safeguard liberty," he said.

The Middle East leaders' ceremonial appearances in the Senate Caucus Room and House Ways and Means Committee hearing room drew about 35 senators and 200 members of the House. Those on hand were eager ot join in the "historic" moment-the word was invoked repeatedly-either by posing for photographs with Begin and Sadat or asking for their automgraphs.

In the House, photographs were the thing. Rep. Thomas J. Downey (D-N.Y.) predicted that the photos of smiling representatives with the two leaders would soon adorn many congressional newsletters for the home folks. "The constituents don't know we got about three seconds with each of them," Downey said.

Several participants in the Senate meeting for the two leaders commented on the different tone of Begin's and Sadat's appearances before them in the ornate Senate Caucus Room.

"It's very reserved, isn't it?" one senator asked while Begin was still in the room. There was a marked absence of jubilation or celebration, and a lot of talk among senators about the fragility of the new peace treaty.

When Sadat arrived in the Caucus Room about 15 minutes after Begin left, the atmosphere changed abruptly. The 30 or so senators in attendance rose spontaneously to give the Egyptian a standing ovation. Sen. Frank Church (D-Idaho), chairman of the Foreign Relations Committee, set the tone for the session, saying:

"There will be no leader of the Arab world now or in the years to come whose name will be more lustrous than yours."

Majority Leader Robert C. Byrd (D-W. Va.) told Sadat, "Among the people of our country you rank as one of the world's most-admired national leaders."

Sen. Jacob K. Javiss (R-N.Y.) called Sadat " one of the great leaders of all time."

Begin had been praised by the same senators, but not as lavishly. And Sadat's banter with the senators before and after he spoke seemed more relaxed than the obviously fatigued Begin's.

In the House too, Sadat was more smiling and more gregarious than the Israeli prime minister. Begin's criticism of the Soviets was more pointed at the House meeting, where te noted that "even now (Foreign Minister Andrei) Gromyko is in Damascus, pledging more weapons." (Syria is a critic of the peace treaty.)

The scene in the Ways and Means hearing room was reminiscent of a campaign fund-raising dinner. The room was decorated with the three nations' flags, acreca palms and bouquets of red, white and blue delphiniums and geraniums. Sadat adn Begin shook hands with virtually every member in the room.

There was flowery rhetoric on both sides in praise of the treaty, some of it tempered with caution. Javits observed that "in a real sense Israel and Egypt have made peace with the United States, and now embrak on the great task of making peace with each other."

Inevitably in such political getherings, the conversation turned to the electroal import of the peace treaty. There was widespread agreement that President Carter would enjoy some political benefit, but many expressed doubt about how much.

One Democratic senator said he thought it was "really pretty pathetic" to see the White House attempt to promote the treaty as an enormous accomplishment that suggests Carter is a "great president."

Sen. Howard H. Baker Jr. (R-Tenn.) an expected candidate for president in 1980, said "these are days of exquiste personal triumph" for Begin, Sadat and Carter. Baker's colleague and chairman of his presidential campaign, Richard G. Lugar (R-Ind.), said later he saw nothing to be gained by withholding the praise from Carter that he deserved for bringing about the peace pact.

Last night, President Carter paid an extraoridinary personal compliment to Sadat by asking to introduce him to a meeting of the Egypt-U.S. Business Council at the headquarters of the U.S. Chamber of Commerce. Carter called Sadat "a man of unmatched political courage" and "a man who has come to love me and whom I have come to love as a brother."

Sadat discarded a prepared speech text about the economic benefits of peace and talked in personal terms about Egypt's natural resources and the opportunity to develop them. "Come and be my partner," he appealed to the American businessmen.