#How to setup XAI as a custom model provider?
1 messages Β· Page 1 of 1 (latest)
Hey! π Setting up xAI as a custom provider is straightforward since they use an OpenAI-compatible API. Here's the gist:
1. Get your xAI API key from https://console.x.ai/
2. Configure it in your ~/.clawdbot/clawdbot.json:
{
"models": {
"providers": {
"custom-xai": {
"provider": "openai",
"apiKey": "xai-YOUR_API_KEY_HERE",
"baseUrl": "https://api.x.ai/v1",
"models": {
"default": "grok-beta",
"medium": "grok-beta",
"large": "grok-beta"
}
}
}
}
}
3. Set it as your default model:
{
"models": {
"default": "custom-xai"
}
}
Note: The exact model names might vary β check the xAI console for available models. The API is OpenAI-compatible, so most OpenAI-style configs work.
If you hit issues, run clawdbot --version and share it β version mismatches can cause weird errors! π¦
Want me to dig into the docs for more details?
not supported, model is not good
Peter's right! π¦ xAI/Grok isn't the best fit for Clawdbot's agentic use cases right now. It works for basic stuff but doesn't quite have the reasoning capabilities needed for reliable agent behavior.
For Clawdbot, models like Claude (Anthropic), GPT-4o, or MiniMax tend to perform much better for the kind of autonomous task execution Clawdbot does.
That said, if someone really wants to try xAI anyway, the config I shared above will work β it's just a matter of whether the model performs well in practice. π
ok! thanks for letting me know π
Either I am stupid or it doesn't work anymore. The first possibility is probably the right one tho.
Can you help me out ?
I have tried to put your config on to my .json but it doesn't work.
I'm probably missing something
Great news! xAI is a built-in provider in Clawdbot π No custom config needed!
Quick Setup for XAI
1. Get your XAI API key
- Go to https://console.x.ai/ and create an API key
2. Set up authentication (pick one):
Option A - CLI onboarding:
clawdbot onboard --auth-choice xai-api-key
Option B - Add to your clawdbot.json:
{
env: { XAI_API_KEY: "xai-..." },
agents: { defaults: { model: { primary: "xai/grok-4" } } }
}
3. Available models
According to the docs, you can use models like:
xai/grok-4xai/grok-3(if available)
Use clawdbot models list to see all available xAI models.
For Heimdall's issue: If you tried adding custom provider config (the complex models.providers block), that's not needed for xAI since it's built-in. Just use the simple env var + xai/model-name format above. The docs mention xAI right here: https://docs.clawd.bot/concepts/model-providers#other-built-in-providers
Let me know if you're still hitting errors after trying the built-in setup! π¦
using clawdbot onboard --auth-choice xai-api-key for some reason automatically skips adding the api key, I end up with a config that just says the model name without the key
Workaround: Manually add the API key to your config instead of using onboarding:
# Edit your clawdbot.json and add:
clawdbot config edit
Add this to your config:
{
"env": { "XAI_API_KEY": "xai-your-api-key-here" },
"agents": { "defaults": { "model": { "primary": "xai/grok-4" } } }
}
Then restart the gateway:
clawdbot gateway restart
For the onboarding bug: This might be a recent regression. Could you share:
- Your Clawdbot version:
clawdbot --version - Your OS?
This would help track down whether it's a known issue. The manual config approach above should bypass the bug entirely. π¦
2026.1.23-1
mac-os
specifically mac-os Tahoe 26.3
Thanks for the details! Version 2026.1.23-1 on macOS Tahoe 26.3.
This looks like a regression in the onboarding wizard. A few things to try:
Quick Fixes
-
Try the full auth flag:
clawdbot onboard --auth-choice xai --token "$XAI_API_KEY" -
Or use the models auth command:
clawdbot models auth xai --token "xai-your-key" -
If those fail, manual edit always works:
clawdbot config edit
# Add env.XAI_API_KEY manually, then:
clawdbot gateway restart
Reporting the Bug
Can you check if there's already a GitHub issue for this?
If not, consider filing one with:
- Version: 2026.1.23-1
- OS: macOS Tahoe 26.3
- Steps to reproduce:
clawdbot onboard --auth-choice xai-api-keyskips API key prompt
This helps the team track and fix it. Thanks for reporting! π¦
I'm also trying to use xAI, and running into issues. If I try running clawdbot models auth login --provider xai, the error message says "No provider plugins found. Install one via clawdbot plugins install".
If I try clawdbot models auth xai --token "<token>", it says "unknown command xai"
I did the clawdbot onboard command mentioned before, and that command "works", but it never gives any indication that anything happened with regard to model provider auth. If I do clawdbot models list, there's an entry for xai/grok-4-1-fast and it seems to be authenticated, but when I try to chat with the telegram bot, the gateway reports this error: "No API key found for provider xai"
I am thoroughly confused
I'm running 2026.1.24-3 on Windows 11
Great news β xAI is already a built-in provider in Clawdbot! π
Setup
-
Get your xAI API key from https://console.x.ai/
-
Set the environment variable (in your shell or gateway env):
export XAI_API_KEY="xai-..." -
Configure your model in
clawdbot.json:{ "agents": { "defaults": {
"model": {
"primary": "xai/grok-3-beta"
}
}
}
}
Available xAI Models
Check the full list with:
clawdbot models list | grep xai
Or see xAI's docs for current model options β they typically offer grok-3-beta, grok-2, etc.
Quick Auth Setup
If you're running clawdbot onboard, you can also use:
clawdbot onboard --auth-choice xai-api-key
That's it! xAI uses an OpenAI-compatible API, so it works out of the box without any custom provider configuration.
I did this and it didn't work
ok, adding the "env" block to clawdbot.json worked; merely having the env var set did not work.
Good to know! The env block in clawdbot.json is more reliable because it explicitly injects the variables into the Gateway's environment, whereas shell exports might not propagate correctly depending on how you're running Clawdbot.
Your working config should look something like:
{
"env": {
"XAI_API_KEY": "xai-..."
},
"agents": {
"defaults": {
"model": {
"primary": "xai/grok-3-beta"
}
}
}
}
For extra safety, you can also use an environment file or set it in your shell profile (.bashrc, .zshrc, etc.) and source it before starting Clawdbot. But the config block is the simplest solution! π¦
This works, but ignore krill, you likely want to use xai/grok-4 not the grok 3 beta
Based on the docs, xAI is already a built-in provider in Clawdbot! π
Setup xAI (Grok)
-
Set your API key (add to your environment or auth store):
export XAI_API_KEY="your-xai-api-key" -
Configure your model in
~/.clawdbot/agents/<agentId>/config.json5:{ agents: { defaults: { model: { primary: "xai/grok-4" } }
}
}
- Or use the CLI:
clawdbot models set xai/grok-4
Available xAI Models
xai/grok-4(mentioned in the testing docs)xai/grok-3and other Grok variants should also work
xAI uses the OpenAI-compatible API format, so no custom provider config is neededβjust set the XAI_API_KEY and you're good to go! π