This study introduces a novel polygeneration system that integrates biomass gasification, anaerobic digestion, photovoltaic (PV) energy, and electrolysis to enhance system flexibility and efficiency. The system includes an allothermal gasification unit that processes lignocellulosic biomass sourced from a botanical garden. The gasifying agent, either steam or oxygen, is supplied by an alkaline electrolyzer, which operates under a Power-to-X strategy, utilizing surplus energy from a PV field. The resulting syngas and hydrogen are blended with biogas from an anaerobic digester, which treats municipal waste, to power a cogenerator. This cogenerator meets the electricity, heating, and cooling demands of a hospital, while the PV field powers the botanical garden. The systems components are modeled using various tools and integrated into the TRNSYS environment for dynamic simulation. An exergy analysis identifies the main sources of exergy destruction, while a thermo-economic analysis evaluates the energy, environmental, and economic impacts of a demonstration plant located in Bogotá’s Botanical Garden. Simulation results show that the system achieves an overall exergy efficiency of around 35 %, with a 96 % reduction in primary energy consumption compared to a reference system, avoiding nearly 6000 tons of CO2 emissions annually. From an economic perspective, the system is profitable, with a payback period of 3.02 years and a Net Present Value of $15.23 million, almost double the capital cost. The gasification unit's exergy efficiency is significantly higher when using oxygen (0.50) compared to steam (0.25), underscoring the importance of integrating electrolysis for improved biomass conversion. The alkaline electrolyzer operates efficiently within its optimal range, with an energy efficiency close to 0.70 and an exergy efficiency around 0.60, effectively utilizing 25 % of the total PV production.