We compute the imaginary part of the heavy quark contribution to the photon polarization tensor, i.e. the quarkonium spectral function in the vector channel, at next-to-leading order in thermal QCD. Matching our result, which is valid sufficiently far away from the two-quark threshold, with a previously determined resummed expression, which is valid close to the threshold, we obtain a phenomenological estimate for the spectral function valid for all non-zero energies. In particular, the new expression allows to fix the overall normalization of the previous resummed one. Our result may be helpful for lattice reconstructions of the spectral function (near the continuum limit), which necessitate its high energy behaviour as input, and can in principle also be compared with the dilepton production rate measured in heavy ion collision experiments. In an appendix analogous results are given for the scalar channel.