Step 1: Let the function value be \(y\).
Let
\[
y=\frac{x^2+x+1}{x^2-x+1}
\]
Since
\[
x^2-x+1=\left(x-\frac{1}{2}\right)^2+\frac{3}{4}\gt 0,
\]
the denominator is always positive.
Step 2: Convert into a quadratic equation in \(x\).
\[
y(x^2-x+1)=x^2+x+1
\]
\[
yx^2-yx+y=x^2+x+1
\]
Bring all terms to one side:
\[
(y-1)x^2+(-y-1)x+(y-1)=0
\]
Step 3: Apply condition for real \(x\).
For real values of \(x\), the quadratic must have real roots.
Therefore,
\[
D\geq 0
\]
Here,
\[
D=(-y-1)^2-4(y-1)(y-1)
\]
\[
=(y+1)^2-4(y-1)^2
\]
Step 4: Simplify the discriminant.
\[
(y+1)^2-4(y-1)^2\geq 0
\]
\[
y^2+2y+1-4(y^2-2y+1)\geq 0
\]
\[
y^2+2y+1-4y^2+8y-4\geq 0
\]
\[
-3y^2+10y-3\geq 0
\]
Multiplying by \(-1\),
\[
3y^2-10y+3\leq 0
\]
Step 5: Factorize.
\[
3y^2-10y+3=0
\]
\[
3y^2-9y-y+3=0
\]
\[
3y(y-3)-1(y-3)=0
\]
\[
(3y-1)(y-3)=0
\]
So,
\[
y=\frac{1}{3},\quad y=3
\]
Since
\[
3y^2-10y+3\leq 0,
\]
we get
\[
\frac{1}{3}\leq y\leq 3
\]
Step 6: Final conclusion.
Therefore, the range is
\[
\boxed{\left[\frac{1}{3},3\right]}
\]