Proof (criterion for sum of two squares)
Sum of two squares $\implies$ $n_i$ is even whenever $p_i\equiv 3\pmod 4$
Suppose $n = x^2 + y^2$. Then $n = N(z) = z\bar z$ where $z = x+iy\in \Z[i]$. Factorise $z = α_1 α_2 \ldots α_q$ into primes in $\Z[i]$ to get $$ \begin{align*} n = N(α_1) \, N(α_2)\, \ldots\, N(α_q). \end{align*} $$ Then either $α_i$ is a prime in $\Z$ with $α_i \equiv 3\pmod 4$, which contributes $N(α_i) = α_i^2$ in the factorisation of $n$, or $N(α_i)$ is a prime in $\Z$ with $N(α_i)\equiv 1,2\pmod 4$.
$n_i$ is even whenever $p_i\equiv 3\pmod 4$ $\implies$ sum of two squares
Suppose $n=p_1^{n_1} \ldots p_k^{n_k}$ and if $p_i \equiv 3\pmod 4$, then $n_i$ is even. Then if $p_i\equiv 3\pmod 4$, we have $p_i^{n_i} = N(p_i^{n_i/2})$, and if $p_i\equiv 1,2\pmod 4$, we have $p_i^{n_i} = N(z^{n_i})$ for some prime $z_i\in \Z[i]$ where $N(z_i) = p$. Thus by multiplying, $n=N(z)$ for some $z\in \Z[i]$.