Renewable Energy Communities (RECs), characterized by localized energy generation and consumption, are a key enabler for enhancing renewable energy utilization, cost-efficient planning and clean energy transition. However, optimizing RECs operations is challenging due to the complex interplay of different stakeholders with conflicting requirements. The complexity of managing such systems often leads to a lack of transparent and reliable decision-making, creating barriers for actors within the community. This paper explores the integration of Generative AI into Renewable Energy Communities (RECs) to enhance the transparency, explainability and accessibility of energy management systems (EMSs) that depend on solving optimization problems. We propose a novel framework, Chat-SGP, which uses generative AI to synthesize optimization modeling code to provide actionable, explainable insights for managing the REC operations. Our approach allows us to interact with the EMS through natural language queries, enhancing the system’s accessibility and user-friendliness. Our evaluation shows that using GPT-4 with in-context learning performs 96.72% accuracy on average in generating correct answers.