The Magnetohydrodynamics with embedded particle-in-cell (MHD-EPIC) model has been successfully applied to global magnetospheric simulations in recent years. However, the PIC region was restricted to be a box, and it is not always feasible to cover the whole physical structure of interest with a box due to the limitation of the computational resources. The FLexible Exascale Kinetic Simulator (FLEKS), which is a new PIC code and allows a PIC region of any shape, is designed to break this restriction and extend the capabilities of the MHD-EPIC model. FLEKS uses the Gauss’s law satisfying energy-conserving semi-implicit method (GL-ECSIM) as the base PIC solver. We have also designed extra numerical techniques, such as the adaptive time stepping and particle re-sampling algorithms, to further improve the accuracy and flexibility of the PIC solver. The grid of FLEKS has to be Cartesian, but the active PIC region is not necessarily to be a box anymore since any Cartesian cells can be turned off. Furthermore, FLEKS supports switching on or switching off grid cells adaptively during a simulation. The initial conditions and boundary conditions of the active PIC region are provided by the coupled MHD code. FLEKS and the coupled MHD code constitute the MHD with adaptively embedded particle-in-cell (MHD-AEPIC) model.