A toolkit for nonlinear model predictive control using gradient projection and code generation. Nonlinear model predictive control (NMPC) is a control strategy based on finding an optimal control trajectory that minimizes a given objective function. The optimization is recalculated at each control cycle and only the first control values are actually used. The dynamics of the system can be nonlinear and there can be constraints on states and controls. A new toolkit called VIATOC has been developed that can be used to automatically generate the code needed to implement NMPC. The generated code is self-contained ANSI C and the compiled program has a small footprint. In VIATOC, the gradient projection method is used to solve the nonlinear optimization problem. Barzilai–Borwein type step length selection for the gradient method has also been implemented. The performance of the controllers generated with the toolkit is compared with those solved with the ACADO toolkit and HQP. The performance of the optimization is compared with two different test cases with different numbers of controls and states. The first one is based on a model of a pendulum hanging freely on a movable platform. The second one is a more complex model of a chain of three masses connected by springs. Seven different prediction horizons between 10 and 100 steps are used. When the time to achieve a near optimum solution is measured, VIATOC is in most cases the fastest one when the length of the prediction horizon is shorter than 70 steps.