The escalating sophistication of cyber threats, particularly zero-day attacks, necessitates advanced detection methodologies in cybersecurity. This study introduces the GPT-2 Enhanced Attack Detection and Defense (GEADD) method, an innovative approach that integrates the GPT-2 model with metaheuristic optimization techniques for enhanced detection of zero-day threats. The GEADD method encompasses data preprocessing, Equilibrium Optimization (EO)-based feature selection, and Salp Swarm Algorithm-Based Optimization (SABO) for hyperparameter tuning, culminating in a robust framework capable of identifying and classifying zero-day attacks with high accuracy. Through a comprehensive evaluation using standard datasets, the GEADD method demonstrates superior performance in detecting zero-day threats compared to existing models, highlighting its potential as a significant contribution to the field of cybersecurity. This study not only presents a novel application of deep learning for cyber threat detection but also sets a foundation for future research in AI-driven cybersecurity solutions