In the Coulomb gauge, we can write the electromagnetic Hamiltonian as
\begin{equation} \label{eq:em-hamiltonian}\tag{1} H_\mathrm{EM} = - \int d^3 x \, \mathbf{j}(\mathbf{x}) \cdot \mathbf{A}(\mathbf{x}) + \frac{1}{2} \int d^3 x \, d^3 x' \, \frac{\rho(\mathbf{x}) \rho(\mathbf{x}')}{4\pi \vert \mathbf{x} - \mathbf{x}' \vert}, \end{equation} where $\mathbf{j}(\mathbf{x})$ is a current density, $\mathbf{A}(\mathbf{x})$ is the vector current, and $\rho(\mathbf{x})$ is a charge density.
For a magnetic dipole in a uniform magnetic field, we can write the interaction Hamiltonian as $$ \label{eq:dipole-hamiltonian}\tag{2} H_\mathrm{dipole} = - \mathbf{\mu}\cdot\mathbf{B} $$ where we can express the dipole moment $\mathbf{\mu}$ in terms of the current density via $$ \mathbf{\mu} = \frac{1}{2} \int_{\mathbb{R}^3} d^3 x \, \mathbf{x} \times \mathbf{j}(\vec{x}). $$
How can we recover \eqref{eq:dipole-hamiltonian} from \eqref{eq:em-hamiltonian}? We know that $\mathbf{B}(\mathbf{x}) = \mathbf{\nabla} \times \mathbf{A}(\mathbf{x})$, and can assume that $\mathbf{j}(\mathbf{x})$ is localized in space.