4. Given that $P$ is a point inside a square $A B C D$ with center $O$, $A P \perp B P, O P=\sqrt{2}, P A=6$. Then the side length of the square $A B C D$ is $\qquad$
$4.2 \sqrt{13}$ or 10.
As shown in Figure 8, when point $P$ is inside $\triangle O A D$, it is clear that $P A > P B$. On $P A$, intercept $A Q = P B$, and connect $O Q$.
It is easy to prove that
$\triangle O A Q \cong \triangle O B P$,
$$
O Q = O P = \sqrt{2} \text{. }
$$

It is evident that $\angle P O Q = 90^{\circ}$.
Thus, $P Q = 2$, $P B = A Q = 4$,
$$
A B = \sqrt{P A^{2} + P B^{2}} = \sqrt{6^{2} + 4^{2}} = 2 \sqrt{13} \text{. }
$$