We conjecture that quantum Gaudin models in affine types admit families of higher Hamiltonians, labelled by the (countably infinite set of) exponents, whose eigenvalues are given by functions on a space of meromorphic opers associated with the Langlands dual Lie algebra. This is in direct analogy with the situation in finite types. However, in stark contrast to finite types, we prove that in affine types such functions take the form of hypergeometric integrals, over cycles of a twisted homology defined by the levels of the modules at the marked points. That result prompts the further conjecture that the Hamiltonians themselves are naturally expressed as such integrals.We go on to describe the space of meromorphic affine opers on an arbitrary Riemann surface. We prove that it fibres over the space of meromorphic connections on the canonical line bundle Ω. Each fibre is isomorphic to the direct product of the space of sections of the square of Ω with the direct product, over the exponents j not equal to 1, of the twisted cohomology of the j th tensor power of Ω. 32 7. Twisted homology and the integral pairing 39 8. Discussion 41 Appendix A. Hyperplane arrangements and quadratic Hamiltonians 47 References 51