This paper proposes a new car-following model for electric vehicle traffic flow in order to minimize the energy consumption. In particular, the energy consumption model is introduced for electric vehicles to capture the energy consumption at every moment. Then, the new car-following models with zero initial state and non-zero initial state are derived from the optimal energy consumption model by using the minimum principle theory. The theoretical analysis shows that the model with the zero initial state condition is a special case of the model with the non-zero initial state condition. Finally, the numerical experiments are conducted with three scenarios: acceleration process, deceleration process and evolution process. Results from numerical experiments demonstrate the effectiveness of the proposed model in terms of position, velocity, and acceleration profiles.