inference-providers

xAI

first_party

DocsConsole

Getting credentials

api-key

api_key via header (header Authorization: Bearer)

Environment: XAI_API_KEY

Create a key at console.x.ai. OpenAI SDKs work by changing base_url only; also Anthropic-compatible.

Credentials docs

oauth

oauth via header (header Authorization: Bearer)

Flow: browser OIDC or device code at auth.x.ai (endpoints not publicly documented)

grok login (or grok login --device-auth) with a SuperGrok or X Premium subscription. Tokens persist in ~/.grok/auth.json with background refresh; requests use subscription quota (a weekly pool shared across Grok chat, Build, and API), not API billing.

Credentials docs

Endpoints

IDURLProtocolAuth
v1-chat-completionshttps://api.x.ai/v1/chat/completionsopenai-chatany
v1-responseshttps://api.x.ai/v1/responsesopenai-responsesany

API surfaces

textstreaming

Quirks

Models offered

ModelWire IDEndpointStatusReasoning
xai/grok-4-5grok-4.5v1-chat-completionsgaeffort · default on · mandatory · returns reasoning_content
xai/grok-4-5grok-4.5v1-responsesgaeffort · default on · mandatory · returns hidden · round-trips encrypted_content
xai/grok-4-6grok-4.6v1-chat-completionsgaeffort · default on · mandatory · returns reasoning_content
xai/grok-4-6grok-4.6v1-responsesgaeffort · default on · mandatory · returns reasoning_content · round-trips encrypted_content