6. If the inequality
$$
a \sin ^{2} x+\cos x \geqslant a^{2}-1
$$

holds for any $x \in \mathbf{R}$, then the range of real number $a$ is $\qquad$
6. $a=0$.

Let $\cos x=-1, \sin x=0$.
From the given condition, we have $a^{2} \leqslant 0 \Rightarrow a=0$.
When $a=0$, the original equation is obviously always true.