Skip to contentSkip to page list

Docs

xAI

Add a xAI API key under Settings, Model Providers and call xAI models through the LangWatch AI Gateway.

On this page

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:

FieldValue
XAI_API_KEYYour xAI API key.

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 model provider drawer with the XAI_API_KEY field and the routing handle xai
The xAI row: name, scope, XAI_API_KEY and the routing handle xai.

Model names

Write xai/<model>, for example xai/grok-4. The gateway does not infer xAI from a bare name.

Send a request

example.shBash
curl https://gateway.langwatch.ai/v1/chat/completions \  -H "Authorization: Bearer $LANGWATCH_VIRTUAL_KEY" \  -H "Content-Type: application/json" \  -d '{    "model": "xai/grok-4",    "messages": [{"role": "user", "content": "Say hi in one word"}]  }'

Endpoints

EndpointServed
POST /v1/chat/completionsYes
POST /v1/messagesYes, translated
GET /v1/modelsYes, from the xAI catalog

Documentation