NEW YORK — It was an only-in-New York scene, orchestrated and directed by the city's only-in-New York mayor.

There stood Ed Koch on Columbus Avenue near 77th Street last week, surrounded by so many reporters, photographers and television crews that an unwitting passer-by thought someone was shooting a movie.

It wasn't a movie. It was Koch doing what he does like no one else -- grabbing, and getting, attention.

The mere fact of holding office gives people in those positions the kind of power that can drive their political opponents to distraction. Koch buttresses that power with a combination of showmanship, a fondness for what comedians call shtick and -- despite his frequent claims that he is unwilling to take unpopular positions -- an instinct to discern and respond to the public pulse. All that has given his holding office a new meaning.

So when a famous New Orleans chef ran awry of the city's health and building codes recently, it came as no surprise when Koch -- the top brass of his administration in tow -- dropped everything, went to ''inspect'' the place himself and pronounced it safe for devotees of $50-a-meal Cajun cuisine.

The performance won all-around news coverage, which is not a bad thing for someone up for re-election. It was quintessential Koch, the latest example of the mayor's exercising his instinct for what plays in a city where the brash seems to be not just the norm. It's a requirement.

New Yorkers have come to expect that kind of behavior from Koch and are rarely disappointed.

Never has the Koch instinct for what plays been more evident than in this election season. His opponents have quite a problem: how to challenge a one- man public-relations phenomenon whose powers led him to veto on one day the very bill he proposed to ban peddlers throughout most of Manhattan, and on another day to intercede for a restaurant or summon the city's news corps to city hall to say that it is safe to drink city water, even if one test did show a slightly elevated level of plutonium.

''I'd be stupid to underestimate it, the fun and games, the cutesy,'' said city council President Carol Bellamy, one of Koch's chief opponents in the race for mayor. ''But it's a phenomenon that gets reduced once people start asking, 'What have you done for me, what are going to do for me?' ''

Maybe. But the same morning that the mayor was inspecting the restaurant, a news conference Bellamy called in Brooklyn to complain about housing and shop rehabilitation was all but ignored.

Much of the Koch public persona is abetted by audiovisual aids separate from his campaign costing more than $5 million. His opponents also have to contend with:

-- The autobiography Mayor and a record and tape of Koch reading from his book.

-- A television profile of him produced by the U.S. Information Agency -- for those New Yorkers who might be outside the country.

-- So many guest-celebrity appearances that an actor's agent complained that his Koch look-alike was out of a job because the mayor was so willing to provide the real thing.

In recent weeks the mayor has sent out a flurry of announcements about the future. Among them have been a pledge to clean ''landscaped malls, squares and triangles'' in Queens -- beginning next January; a plan to start recycling garbage -- next spring, and a promise that some elderly Brooklynites can move into a new apartment building -- by Christmas.

''Are we announcing things so that people will know what this administration is doing?'' the mayor said. ''And is part of that that it may show up in votes on Election Day? Sure. What's wrong with that? What's wrong with blowing your own horn?''

His remarks illustrate what might be called the Koch say-it-ain't-so technique. ''He deflects criticism by refusing to admit it's criticism,'' said one of his consultants, Philip Friedman.

For instance, the Penthouse caricature, with a slogan that said Koch ''puts on a grand show so the people below don't see New York is falling apart,'' was not meant kindly. But the mayor said he ''loved'' the caricature, even hoped to use it in his campaign.

''That was deliberate,'' the mayor said later with a chuckle. ''And it worked.''

It hasn't always. After he called suburban living ''sterile'' and rural life ''a joke'' in a Playboy interview published during his losing race for governor in 1982, the mayor said he had spoken ''jocularly.'' That explanation was not universally accepted.

Then again, Mayor, the musical, is actually quite critical of Koch. It shows him as sympathetic to the rich and the powerful, dismissive of the have- nots, enamored of good times. In the end, it is only a midnight visit by the ghost of Mayor Fiorello H. La Guardia, who warns him to reform ''or you're going to lose the only thing you've ever cared about,'' that turns Koch around.

But the public seems to think the musical is kind to the mayor, in part because Koch has had only praise for it.

''It has zingers, but I don't like bland,'' the mayor said.

Whether all of what Bellamy calls the ''razzmatazz'' will help Koch or, as she hopes, backfire remains to be seen. She said the public would vote on substance.

So did Koch. He made the comment the same week he reopened the restaurant, put on headphones in Central Park to demonstrate how to listen quietly to rock music, held the plutonium press conference, posed with Miss Universe and Miss U.S.A. and issued his 320th news release of the year.