Firstly, we elucidate how integrable lattice models described by Costello's 4d Chern-Simons theory can be realized via a stack of D4-branes ending on an NS5-brane in type IIA string theory, with D0-branes on the D4-brane worldvolume sourcing an RR 1-form, and fundamental strings forming the lattice. This provides us with a nonperturbative integration cycle for the 4d Chern-Simons theory. Secondly, we study 4d Chern-Simons theory on a manifold with boundary. We find that the theory is dual to a boundary theory, that is a 3d analogue of the chiral WZW model in 2d. We derive a current algebra that turns out to be an “analytically-continued” toroidal Lie algebra. In addition, we show how bulk correlation functions of Wilson lines can be captured by boundary correlation functions of local operators in the 3d WZW theory. We then reproduce Costello, Witten and Yamazaki’s result for the R-matrix to leading nontrivial order purely from the boundary theory.