providers
Grok (xAI)
xAI's Grok models over their OpenAI-compatible API. A bare grok-* model name is all mantis needs — it routes to api.x.ai on its own and maps the reasoning knob per model.
| endpoint | https://api.x.ai/v1 |
| env var | XAI_API_KEY (alias: GROK_API_KEY) |
| get a key | console.x.ai |
Get an API key
- Sign in at console.x.ai with your X or xAI account
- Open the API Keys page and click 'Create API key'
- Name it and copy the
xai-…key (shown once) - Add credits under Billing
Pay-as-you-go; new accounts usually get a small trial credit.
Enable
export XAI_API_KEY=xai-... # shell profile — survives foreveror in the terminal — validates the key live before saving:
/enable xaior pick any locked 🔒 Grok (xAI) model in /models and paste the key inline.
Models
Starter menu (once enabled, /models fetches the provider's full live list):
grok-4— 256k window, reasoning always ongrok-4-fast— 2M windowgrok-3grok-3-mini— the one that takesreasoning_effort(low/high)
Switch anytime — /model grok jumps to the flagship, /model grok-3 fuzzy-matches; context carries over.
SDK
from mantis_agent import MantisAgentOptions
options = MantisAgentOptions(model="grok-4") # routes to api.x.ai; key read from $XAI_API_KEYThe explicit form is the same as any other hosted provider:
from mantis_agent import MantisAgentOptions
options = MantisAgentOptions(
model="grok-4",
backend="https://api.x.ai/v1",
)Notes
GROK_API_KEYworks too (alias). The vendor key wins by host, so a staleOPENAI_API_KEYin the same shell is never sent to xAI.reasoning_effortis sent only to the models that accept it —grok-3-mini— and the universalthinkingconfig maps onto it.grok-4,grok-3andgrok-code-fastreason at a fixed level and are never sent the field.- Streamed
reasoning_contentdeltas surface as thinking blocks, collapsed to one line in the terminal (/thinking showexpands them). - Native tool calling on every model; xAI bills cached prompt tokens at a discount, and mantis keeps the prompt prefix stable to make use of it.