Grok
xAI’s chat & Responses API — policed, billed from the cost each response reports
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.
Only need stateless chat completion, and want the same request body to also work against OpenAI, Anthropic, or Hugging Face models? /inference is a narrower, OpenAI-shaped surface over all four. Use this route directly for the Responses API, tokenization, or the files/batches surface.
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, then adds the gateway’s 5.5% fee. 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, and carry no fee.
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.

