AI generates images by learning from large datasets of existing images. It can learn patterns, textures, colors, and shapes from these datasets and use that knowledge to generate new images. Generative models, such as Generative Adversarial Networks or Variational Autoencoders, are commonly used for AI image generation.