Pieter W. Botha today became the first South African prime minister to visit Soweto, the teeming all-black suburb of Johannesburg, which has become a symbol of resistance to apartheid since bloody upheavals there in 1976 focused world attention on South Africa's race problems.

Botha, with seven Cabinet ministers, was flown into the dusty, segregated township of 1.5 million people in a military helicopter and was greeted warmly by modest crowds as he toured schools, a nursery and other sites selected for him by the townshipS government-created community council.

His visit is part of a new approach of cooperation and consultation in his dealings with moderate black leaders who have chosen to operate within the system of apartheid, or racial separation. His style contrasts sharply with that of his predecessor, John Vorster, and has won Botha praise from the blacks he deals with.

The visit to Soweto comes at the end of the first tour by a South African prime minister to the "homelands," or reserves set aside for blacks that the government expects to make into small independent states.

In some ways, however, the Soweto tour is more significant than his travels to the homelands since the poverty-ridden township is regarded as a bellwether of political sentiment among the country's blacks and it represents the serious political problem facing the white minority government -- what to do about the estimated 9 million urbanized blacks who reject the homeland system.

To accent the importance he attached to the Soweto visit, Botha brought with him seven Cabinet ministers, including Minister of Black Affairs Piet Koornhof. Addressing the community council Botha said his visit "was not only a courtesy call."

Botha implied that the government now regards Soweto as a permanent community destined to play an as yet undefined role of its own in the country's political life. Up to now, government policy has been that Soweto is merely a transient community of people who live close to Johannesburg in order to work there and who must regard one of the tribal homelands as their true residence.

In a gesture of good will, Botha said he was canceling a $13.7 million deficit of the administrative board that runs Soweto and other black townships in the area.

Repeating his councilatory remarks made to homeland leaders and his promises to consult with rather than dictate to them, he said, "Today, Soweto opened its heart to the government of South Africa and our presence here is proof that we are prepared to open our hearts to you."

Asked by a reporter to give his impression of Soweto for an American audience Botha replied somewhat impatiently, "It's a challenge, we will accept the challenge. Human relations are sound. We live in a relaxed country. Leave us alone to do our job."

As in the homelands, Botha's hosts today were black leaders who concentrate on economic and social grievances in dealing with Pretoria and do not challenge the government's denial of the political rights enjoyed by the white minority of 4.5 million. About 22 million nonwhites live in South Africa.

Soweto's community council was installed only after a massive crackdown and banning of black political organizations and the jailing of 50 black leaders in October 1977. Then the council was elected by only 6 percent of the registered voters in Soweto.

"He's being taken to all the programmed, prechanneled people, that's been carefully calculated for this visit," said one black reporter covering Botha's trip today.

Notably absent from his schedule was a meeting with the popular though unelected leader of Soweto, Nthato Motlana, who is chairman of Soweto's ad hoc Committee of Ten.This body opposes working on terms set by Pretoria and advocates a complete abolition of apartheid and its replacement with a system of equal rights. Motlana said he would not meet Botha until he first agreed to eliminate the hated pass system which restricts the movements of blacks in white sections of South Africa.

Outside Soweto's only hotel, a crowd of about 2,000, many of them elementary school children, mobbed Botha's car and tried to speak with him. Some were heard shouting "Hi, Boss." Smiling and appearing at ease, Botha walked along the edge of a larger crowd of about 5,000 that cheered him warmly outside the community council building.

Apart from these crowds at his designated stops, however, Botha's visit went unnoticed by the huge community of Soweto.

Though armed policemen, both black and white, were in evidence, security was relaxed and there were no incidents.

The only sign of protest were posters on a pedestrian bridge. One said, "Speak to Mandela for Soweto," a reference to black nationalist leader, Nelson Mandela, now serving a life sentence in the political prison of Robben Island.