Skip to main content
xAI’s API is OpenAI-compatible, including a native Responses API. Models such as grok-4.5 are discovered automatically from xAI’s /models endpoint — no configuration beyond the API key is needed.

Configure

Or in config.yaml:
Voice models (e.g. grok-voice-latest) are not listed by xAI’s /models endpoint. To route realtime sessions to them, add them explicitly via XAI_MODELS=grok-voice-latest or a configured model list.

Reasoning effort mapping

Grok reasoning models (e.g. grok-4.5, defaulting to high) accept reasoning_effort as a top-level string on Chat Completions. GoModel rewrites the OpenAI-shaped "reasoning": {"effort": "..."} into that flat field — no client change required. On the Responses API the nested shape is xAI-native and passes through unchanged. Models without reasoning support reject the field upstream; omit reasoning for those.

Prompt-cache affinity

xAI routes a conversation’s requests to the same server via the x-grok-conv-id header; without it, cache hits are unreliable and input tokens are often billed at the uncached price.
  • Chat Completions: GoModel forwards a client-supplied X-Grok-Conv-Id header, and otherwise derives a stable one from the conversation’s opening messages — cache affinity works with no client change.
  • Responses API: pass prompt_cache_key in the request body; GoModel forwards it verbatim.