  Ultracold atoms in an ultrahigh-finesse optical cavity are a powerful
platform to produce spin squeezing since photon of cavity mode can induce
nonlinear spin-spin interaction and thus generate a one-axis twisting
Hamiltonian $H_{\text{OAT}}=qJ_{x}^{2}$, whose corresponding maximal squeezing
factor scales as $N^{-2/3}$, where $N$ is the atomic number. On the contrary,
for the other two-axis twisting Hamiltonian
$H_{\text{TAT}}=q(J_{x}^{2}-J_{y}^{2})$, the maximal squeezing factor scales as
$N^{-1}$, approaching the Heisenberg limit. In this paper, inspired by recent
experiments of cavity-assisted Raman transitions, we propose a scheme, in which
an ensemble of ultracold six-level atoms interacts with two quantized cavity
fields and two pairs of Raman lasers, to realize a tunable two-axis spin
Hamiltonian $%H=q(J_{x}^{2}+\chi J_{y}^{2})+\omega_{0}J_{z}$. For proper
parameters, the above one- and two- axis twisting Hamiltonians are recovered,
and the scaling of $N^{-1}$ of the maximal squeezing factor can occur
naturally. On the other hand, in the two-axis twisting Hamiltonian, spin
squeezing is usually reduced when increasing the effective atomic resonant
frequency $\omega_{0}$. Surprisingly, we find that by combined with the
dimensionless parameter $\chi(>-1)$, the effective atomic resonant frequency
$\omega_{0}$ can enhance spin squeezing largely. These results are benefit for
achieving the required spin squeezing in experiments.
