Add the credential
Open Settings > Model Providers, click Add Model Provider and select xAI. Give the row a name, pick the organization, team or project it belongs to, and fill in:
Save the row. Every virtual key whose scope can see the row can now dispatch to it, unless the key restricts its providers. See Virtual keys.

The xAI row: name, scope, XAI_API_KEY and the routing handle xai.
Model names
Writexai/<model>, for example xai/grok-4. The gateway does not infer xAI from a bare name.