When Jon Favreau set out to cast the part of his character’s food-critic nemesis in “Chef,” he inadvertently hit the jackpot with Oliver Platt, whose older brother just so happens to be famed New York magazine critic Adam Platt.

“Oliver was somebody who I was seriously considering for the role, and then it was pointed out to me that Adam was his brother, which I wasn’t aware of,” he says. “That made it a slam dunk for me, because I wanted somebody who would have actually been in those situations.”

Indeed, Oliver is very familiar with the ways of restaurant critics — many times, he’s been to dinner with his sibling while Adam was reviewing a restaurant. But he doesn’t consider himself a foodie.

“I would go more [with] ‘glutton,’ ” he tells The Post with a laugh. “The main reason I don’t eat with him more often is he has to order everything on the menu. I just don’t have that kind of self-control [not to eat everything].”

And critical he is not.

“I don’t remember ever going to a bad restaurant,” he says.

In the film, Oliver’s character, Ramsey Michel, writes an eviscerating review of a meal whipped up by a chef played by Favreau. With input from Adam, Oliver helped Favreau rewrite the review in the script to make it more realistic.

“Adam doesn’t write the way that guy does, but he pointed me right away in the direction of a specific review,” he says, noting that Adam won’t let him identify which one. “[He showed me,] if you’re going to be that mean, you better be funny. That’s the sugar that makes the medicine go down.”

“Adam will tell you he writes for people who eat, not for people who cook. He could give a s–t about the history of the croissant,” says Oliver. “I think he does think of himself as a consumer advocate. He’d probably tell you himself he’s a little more crotchety than that.”