This study develops an oxyfluoride GCs embedded with β-PbF2:4Yb3+/1Er3+/xK+ NCs by conventional melting-quenching method. Based on XRD and EDS line scanning data, it was inferred that Er3+/Yb3+ and K+ ions were co-doped in the β-PbF2 lattice by substituting Pb2+ ions. Compared with K+ ions free doping GCs, in β-PbF2:4Yb3+/1Er3+/xK+ GCs, the synergistic substitution of Pb2+ ions by K+ and Er3+/Yb3+ into the β-PbF2 lattice not only effectively eliminates the charge imbalance defects caused by single doping of Er3+/Yb3+ ions, but also causes lattice distortion around Er3+/Yb3+. It is precisely the elimination of lattice defects and lattice distortion caused by K+ ion doping that leads to a significant increase in upconversion luminescence (UCL) intensity of β-PbF2:4Yb3+/1Er3+/xK+ GCs. Compared with free doping K+ ions GCs, β-PbF2:4Yb3+/1Er3+/7.5K+ GCs presents the maximum UCL intensity and the maximum enhancement is 42.7, 109.5, 32.2 and 42.4 for violet emission, blue emission, green emission and red emission, respectively. The corresponding energy transfer mechanism of UCL was addressed, and the pivotal roles of charge compensation and lattice distortion induced by K+ ions in radiative transitions of Er3+ ions energy levels were revealed through rate equations analysis. Based on significantly enhanced violet UCL, the temperature-sensing behavior based on the FIR of the thermally coupled levels (TCLs):4G11/2/2H9/2 is investigated over a temperature range from 300 to 500 K. The highest relative thermal sensitivity, 1.47 % K−1, was found at 300 K for β-PbF2:4Yb3+/1Er3+/7.5K+ GCs. The obtained results confirm the high application potential of this GCs for UCL device such as solid state lighting and fluorescence thermometers.