You need an infinite number of generators for the ideal in the commutative setting. Perhaps the simplest example would be $R=k[x_1,\dots,x_n,\dots]/(x_1^2,\dots,x_n^2,\dots)$, where $k$ is field of characteristic 2 (see note).
We observe that $I=(x_1,\dots,x_n,\dots)$ is not nilpotent, since $0\ne x_1\cdots x_n\in I^n$ for each $n\ge 1$. On the other hand, the square of any element of $I$ is $0$, as we shall show. Let $f\in I$. Expressing $f$ as a linear combination of the generators of $I$, we have
$$f = g_1x_1+\dots+g_nx_n$$
for some $n>0$ and some $g_1,\dots,g_n\in R$. Then,
$$f^2 = \sum_{i=1}^n g_i^2x_i^2 + 2\sum_{1\le i<j\le n}g_ig_jx_ix_j = 0$$
as desired.
Thus, all elements of $I$ (and in fact all nilpotent elements of $R$) have the property that their square is $0$. So, an exponent of $2$ is attainable.
Note: One cannot decrease the exponent in $(x_1+\dots+x_n)^{n+1}=0$ for an arbitrary coefficient field $k$.