We propose a model based on an Artificial Immune System (AIS) to be used in conjunction with any electromagnetic solver in order to solve inverse design problems of integrated photonics. The proposed AIS was inspired by the Opt-aiNET algorithm coupled to a homemade electromagnetic solver based on the frequency domain Finite Element Method (FEM), which was used for calculating the fitness function. To validate the proposed model, we evaluate the photonic bandgap (PBG) of photonic crystals by the inverse design approach by assuming triangular lattices comprised of Si and air, and compared the results with other metaheuristics. The proposed AIS model is tightly coupled to such type of problem when the photonic structure is discretized in the binary-valued domain. Interestingly, different from many bioimmune-inspired metaheuristics, this proposed model has one of its metaheuristics parameters highly related to the characteristics of the application, which allows the algorithm itself to get a better "learning" of the problem and, additionally, reveals the designer some features intrinsic to the application. We have obtained midgap ratios of the first PBGs in triangular lattices of 47.55% and 49.11% for transversal magnetic (TM) and transversal electric (TE) polarizations, respectively. Additionally, the proposed model was applied to achieve large PBGs assuming the TM polarization in PhCs based on silicon carbide, and a new structure presented a PBG equals to 33.94%.