We compute the high-dimensional limit of the free energy associated with a multi-layer generalized linear model. Under certain technical assumptions, we identify the limit in terms of a variational formula. The approach is to first show that the limit is a solution to a Hamilton-Jacobi equation whose initial condition is related to the limiting free energy of a model with one fewer layer. Then, we conclude by an iteration.