Run inference, tokenize, or create a file/batch

View as Markdown
Covers `v1/chat/completions`, `v1/responses`, and `v1/tokenize-text`, plus creating a file or batch (registered to your account on success — a batch's own per-item bodies face the identical field policy a live call would). The request `model` must be on the gateway's catalog, `user` is always overwritten with a per-tenant identifier, and `tools[]` is checked by its explicit `type` — see the Grok tag description above.

Authentication

AuthorizationBearer

Your per-client bearer token — the API key the gateway issued to you. Present it in Authorization: Bearer <token> form. A token that is missing, unknown, or revoked draws a 401. Before the call is sent upstream the token is removed (stripped, or swapped for the upstream’s own credential); it never makes it past the gateway.

Path parameters

pathstringRequired
The path to call on xAI's Grok API, any further `/` segments included — all of it after `/grok/` is passed to `https://api.x.ai/` when the gateway's model catalog and endpoint/field policy admit the request (see the Grok tag description above). Examples: `v1/chat/completions`, `v1/responses`, `v1/tokenize-text`, `v1/models`, `v1/models/{model}`, `v1/files`, `v1/files/{id}`, `v1/batches`, `v1/batches/{id}`.

Request

This endpoint expects a map from strings to any.

Response

Whatever the upstream answered, relayed as-is (status, headers, body). Rendered here as JSON; the true shape is the upstream provider’s to define.

Errors

400
Bad Request Error
401
Unauthorized Error
404
Not Found Error