Pumping unit efficiency is highly disturbed by the presence of gas influx reducing the productivity and inducing unpredictable system response due to the change of its intrinsic properties such as the natural frequency. A poor estimation of those properties may affect the on-field crew and system safety as well as the production rate. The purpose of this paper is to construct a hydromechanical model describing the coupled multiphase flow-pumping unit system dynamics and to develop a procedure to control the pumping speed for safety assurance and oil production maximization. A coupled mechanical-multiphase flow model capturing the interplay between the gas void fraction (GVF) and the driving harmonic force of the pumping unit is developed. Specifically, the predicted downhole pressure is used to determine the sucker rod effective load. Consequently, a reduced-order model, capturing the dynamics of the sucker rod, is used to estimate the saddle bearings axial displacements which are function of polished rod loading. An error-driven adaptation using the difference between presumed bearing displacement with known GVF and the predicted bearing displacement from the proposed multiphysics model is employed to estimate the unknown downhole GVF. The obtained results prove that the adaptation allows an accurate evaluation of the pumped fluid's GVF, thereby circumventing the need for a costly and inaccurate measurement of the two-phase flow gas fraction. Based on this estimation, a control strategy is then proposed to regulate the pump speed while avoiding the resonance frequency of the sucker-rod system.