A parametric method to generate low energy gait for both single and double support phases with zero moment point(ZMP) stability is presented. The ZMP stability condition is expressed as a limit to the actuating torque of the support ankle, and the inverse dynamics of both walking phases is investigated. A parametric optimization method is implemented which approximates joint trajectories by cubic spline functions connected at uniformly distributed time knots and makes optimization parameters only involve finite discrete states describing key postures. Thus, the gait optimization is transformed into an ordinary constrained nonlinear programming problem. The effectiveness of the method is verified through numerical simulations conducted on the humanoid robot THBIP-I model.