NEW YORK (AP) _ Mayor Edward I. Koch said Wednesday he has gone off the diet his doctors put him on and has only himself to blame.

''I brought the poison myself,'' he said, referring to a chocolate cake.

The mayor, who was instructed to lose weight after he suffered a minor stroke Aug. 6, said he took the cake along on a weekend visit to friends, but did not intend to eat it. He said he normally has great will power.

Koch said that when the cake was served, he held off eating the cake itself, but ''I ate the chocolate (frosting).''

The mayor, 62, weigned 216 1/2 when he got out of the hospital Aug. 9, dropped to about 211, then went up a bit before the cake episode. He declined to reveal how much he weighed Wednesday, ''on the advice of counsel.''

Koch said he intends to resume his diet because he wants to write a diet book and to do so, ''I have to have a successful diet.''

He said he plans to go back on the diet, but after the Labor Day weekend, which he is spending at the home of his friend David Margolis on Long Island.

''David Margolis makes the best coconut daiquiris,'' he explained.