xAI's API at https://api.x.ai/v1 is OpenAI-compatible: the same chat-completions request shape, a different base URL and key.
Get a key at console.x.ai. Send it as Authorization: Bearer <key>. In the examples it's written {{XAI_API_KEY}}.
Full reference: https://docs.x.ai/docs/api-reference
The reply is in choices[0].message.content.
curl https://api.x.ai/v1/chat/completions \
-H "Authorization: Bearer {{XAI_API_KEY}}" \
-H "Content-Type: application/json" \
-d '{"model": "grok-4.7", "messages": [{"role": "user", "content": "Explain HTTP keep-alive in two sentences."}]}'
curl https://api.x.ai/v1/models \
-H "Authorization: Bearer {{XAI_API_KEY}}"