How to generate an image (generalizing)

The API option is exactly what I am looking for.
Just need to figure out how to use it still…