The process in which microorganisms use inorganic substances as a source of energy to produce organic compounds.