The production of organic compounds from atmospheric or aquatic carbon dioxide, principally through photosynthesis.