packages/kilo-docs/pages/ai-providers/xai.md
xAI is the company behind Grok, a large language model known for its conversational abilities and large context window. Grok models are designed to provide helpful, informative, and contextually relevant responses.
Website: https://x.ai/
Kilo Code supports two ways to connect xAI:
If you have an active SuperGrok or X Premium subscription, you can authenticate with xAI using OAuth and use Grok models directly without needing a separate API key.
{% callout type="note" %} SuperGrok and X Premium subscription access works with Kilo Code's core functionality (VS Code extension and CLI). For cloud features such as Cloud Agents or KiloClaw, use the Kilo Gateway — the Gateway supports xAI via BYOK with an API key (OAuth and subscription-based access are not supported through the Gateway). {% /callout %}
{% tabs %} {% tab label="VSCode" %}
Open Settings (gear icon) and go to the Providers tab. Click Show more providers, then search for or select xAI. Choose the xAI Grok OAuth (SuperGrok / X Premium) sign-in option and complete the OAuth flow in your browser.
For headless or remote environments (VPS, SSH, Docker, WSL) where a browser redirect to 127.0.0.1 is not reachable, choose xAI Grok OAuth (Headless / Remote / VPS) instead. You will be shown a short code to enter at a URL you open on any device with a browser.
{% /tab %} {% tab label="CLI" %}
Run the auth command and follow the xAI sign-in flow:
kilo auth login --provider xai
Kilo Code offers three methods at the prompt:
https://auth.x.ai in your browser for a standard PKCE OAuth flow. Best for local desktop environments.127.0.0.1:56121 is not accessible from your browser.Then set your default model:
{
"model": "xai/grok-3",
}
{% /tab %} {% /tabs %}
kilo auth logout and choose xAI.127.0.0.1:56121 to receive the OAuth callback. If another application is already using that port, use the headless device-code method instead.kilo auth login --provider xai to restore the session.If you prefer pay-as-you-go access or do not have a SuperGrok or X Premium subscription, you can use an xAI API key.
{% tabs %} {% tab label="VSCode" %}
Open Settings (gear icon) and go to the Providers tab. Click Show more providers, then search for or select xAI and enter your API key.
The extension stores this in your kilo.json config file. You can also edit the config file directly — see the CLI tab for the file format.
{% /tab %} {% tab label="CLI" %}
Set the API key as an environment variable or configure it in your kilo.json config file:
Environment variable:
export XAI_API_KEY="your-api-key"
Config file (~/.config/kilo/kilo.json or ./kilo.json):
{
"provider": {
"xai": {
"env": ["XAI_API_KEY"],
},
},
}
Then set your default model:
{
"model": "xai/grok-3",
}
{% /tab %} {% /tabs %}
Some models feature specialized reasoning capabilities, allowing them to "think before responding" - particularly useful for complex problem-solving tasks.
When using reasoning-enabled models, you can control how hard the model thinks with the reasoning_effort parameter:
low: Minimal thinking time, using fewer tokens for quick responseshigh: Maximum thinking time, leveraging more tokens for complex problemsChoose low for simple queries that should complete quickly, and high for harder problems where response latency is less important.
reasoning_content field in the response completion objectgrok-2-vision-latest, grok-2-vision, etc.) when you need to process or analyze images.