Grok
xAI’s chat & Responses API — policed, billed dollar-direct from the response
Fronts xAI’s Grok API, scoped to text inference. Like the OpenAI and Anthropic routes, this is policed rather than transparent: requests are checked against a model allowlist and a request-field policy before they reach xAI.
This route ships behind a kill switch that defaults to off, plus a per-account pilot allowlist — the same current-availability caveat as the other model-inference routes. A request can 404 here even with a funded, valid key until this route is enabled for your deployment.
Endpoints
xAI’s Management API (management-api.x.ai) is a separate host and credential this route never addresses — Collections and account-management features that live there are out of scope entirely, not merely unrouted.
Request policy
- One client credential channel —
Authorization: Bearer— is overwritten unconditionally, simpler than Anthropic’s dual-channel case. - Always overwritten:
user, xAI’s documented end-user attribution field, is replaced with a per-tenant identifier, so abuse enforcement lands on your account rather than the shared key. - Checked by its explicit type field: each
tools[]entry withtype: "function"is validated structurally; any other type must beweb_searchorx_search— xAI’s Remote MCP tool andcode_interpreterare never reachable, for the same credential-relay and unattributable-billing reasons Anthropic’s equivalents are excluded.
Stateful resources
Files and batches you create are tracked per account; a foreign or unknown id answers the same 404. GET v1/files and GET v1/batches (the bare list forms) are answered locally from this ownership record. Batches settle on a recurring poll, since xAI documents no batch-completion webhook either.
Billing
The defining difference from the other model-inference routes: most Grok responses report their own real dollar cost in the response body, and billing reads that figure directly rather than computing it from a maintained price table. The gateway’s price table only backs up the rare response that omits the field. An account can register its own xAI key; while that’s active, calls bill to that key directly instead of metering through the gateway balance.
Examples
Chat Completions
Tokenize
List your models
Responses arrive as xAI’s JSON, untouched once a request clears the checks above. Field-level request and response detail lives in xAI’s documentation.