xAI legacy text completions — POST /v1/completions (OpenAI) and POST /v1/complete (Anthropic)
Status: DOCUMENTED · LEGACY · RETIRED in practice — 2026-09-19 both endpoints returned 400 {"code":"invalid-argument","error":"Raw sampling is not supported for reasoning models"} for grok-4.3 and for grok-4.20-0309-non-reasoning (the only non-reasoning text model exposed). No live model accepts raw completions. /v1/complete is additionally flagged "Anthropic SDK compatibility is fully deprecated".
Sources: https://docs.x.ai/developers/rest-api-reference/inference/legacy · OpenAPI SampleRequest/SampleResponse, CompleteRequest/CompleteResponse · machine-readable: generated/fragments/parameters/xai-legacy-completions-embeddings.json
Last verified: 2026-09-19
POST /v1/completions (OpenAI shape)
Body: model, prompt (string | string[]), max_tokens, n, temperature, top_p, seed, stop (≤4; not on reasoning models), stream, stream_options.include_usage, echo, logprobs (ignored ≥ grok-4.20), user; unsupported: best_of, suffix, logit_bias, frequency_penalty; presence_penalty not on grok-3/reasoning. Response {id, object:"text_completion", created, model, choices[{index, text, finish_reason}], usage (chat-style), system_fingerprint}.
POST /v1/complete (Anthropic shape)
Body: model, prompt (\n\nHuman: … \n\nAssistant:), max_tokens_to_sample, stop_sequences, temperature, top_p, metadata.user_id; unsupported stream, top_k. Response {type:"completion", id, completion, stop_reason (stop_sequence | max_tokens | length | end_turn), model}.
Live
| Endpoint | Model | Result |
|---|---|---|
/v1/completions |
grok-4.3 | 400 Raw sampling is not supported for reasoning models |
/v1/completions |
grok-4.20-0309-non-reasoning | 400 (same message) |
/v1/complete |
grok-4.3 | 400 (same) |
/v1/complete |
grok-4.20-0309-non-reasoning | 400 (same) |
Migration: use /v1/chat/completions or preferably /v1/responses. Anthropic-shaped chat lives on (deprecated) at /v1/messages.