Override the API base URL

models and endpoints

// what it does

The default endpoint is https://api.x.ai/v1. Point the CLI elsewhere with --base-url (short -u), the GROK_BASE_URL environment variable, or "baseURL" in user-settings.json — useful for proxies, gateways, or a different OpenAI-compatible endpoint.

// shell

$ grok --base-url https://api.x.ai/v1
$ export GROK_BASE_URL=https://your-gateway.example.com/v1

// gotcha

The base URL and the API key travel together: an xai- key only works against api.x.ai. Change the base URL to another provider and you must supply that provider's key too, or every request returns 401.

// resources