Energy flows from the sun to producers (plants), then to herbivores, then to carnivores. At each step, some energy is lost as heat, so less energy is available at higher trophic levels. This relationship is often shown as an ecological pyramid, with producers at the base and top predators at the peak.