2. Given real numbers $a, b$ satisfy $a^{3}+b^{3}+3 a b=1$. Then $a+b$ $=$ . $\qquad$
2.1 or -2.

Let $a+b=x$. From $a^{3}+b^{3}+3 a b=1$, we easily get $x^{3}-3 a b x+3 a b-1=0$.
Factoring, we get $(x-1)\left(x^{2}+x+1-3 a b\right)=0$.
Therefore, $x=1$ or $x^{2}+x+1-3 a b=0$.
If $x^{2}+x+1-3 a b=0$, then
$$
a^{2}+b^{2}-a b+a+b+1=0 \text {. }
$$

Completing the square, we get $\frac{1}{2}\left[(a-b)^{2}+(a+1)^{2}+(b+1)^{2}\right]=0$.
Thus, $a=b=-1$, at this time $x=a+b=-2$.
Therefore, $a+b=1$ or -2.