xAI (Grok)
xAI Grok integration via the OpenAI-compatible API.
Configuration
1export XAI_API_KEY=xai-...Endpoint
Base URL: https://api.x.ai/v1
xAI uses an OpenAI-compatible API format, so no format conversion is needed. Both streaming and non-streaming are supported.
Model Detection
Models starting with grok- are automatically routed to xAI.
Usage
Request a Grok model directly:
1curl http://localhost:4100/v1/chat/completions \2 -H "Content-Type: application/json" \3 -d '{4 "model": "grok-2",5 "messages": [{"role": "user", "content": "Hello"}]6 }'Authentication uses
Authorization: Bearer header, same as OpenAI.