In mitochondria and chloroplasts, chemical or photosynthetic energy is harnessed to form ATP (adenosine triphosphate) from ADP (adenosine diphosphate) and inorganic phosphate (Pi).
When energy is needed for cellular work, the ATP is hydrolyzed to ADP and Pi.