How to send image and get image as output from GPT-4o model using API

Using chatGPT UI we can attached a reference image, add a text prompt and get the output image. How we can achieve similar using API?