---
title: "(Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible with the Anthropic API."
method: POST
path: "/v1/complete"
tags: ["v1"]
---

# (Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible with the Anthropic API.

`POST /v1/complete`

## Request body

- CompleteRequest — (Legacy) Anthropic compatible complete request on `/v1/complete` endpoint.
  - `max_tokens_to_sample` integer — The maximum number of tokens to generate before stopping.
  - `metadata` MessageMetadata
    - `user_id` string, nullable — A unique identifier representing your end-user, which can help xAI to monitor and detect abuse.
  - `model` string — Model to use for completion.
  - `prompt` string — Prompt for the model to perform completion on.
  - `stop_sequences` string[], nullable — (Not supported by reasoning models) Up to 4 sequences where the API will stop generating further tokens.
  - `stream` boolean, nullable — (Unsupported) If set, partial message deltas will be sent. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a `data: [DONE]` message.
  - `temperature` number, float, nullable — What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.
  - `top_k` integer, nullable — (Unsupported) When generating next tokens, randomly selecting the next token from the k most likely options.
  - `top_p` number, float, nullable — An alternative to sampling with `temperature`, called nucleus sampling, where the model considers the results of the tokens with `top_p` probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. It is generally recommended to alter this or `temperature` but not both.

## Response `200`

Success

- CompleteResponse — (Legacy) Anthropic compatible complete response on `/v1/complete` endpoint.
  - `completion` string, required — The completion content up to and excluding stop sequences.
  - `id` string, required — ID of the completion response.
  - `model` string, required — The model that handled the request.
  - `stop_reason` string, nullable — The reason to stop completion. `"stop_sequence"` means the inference has reached a model-defined or user-supplied stop sequence in `stop`. `"length"` means the inference result has reached models' maximum allowed token length or user defined value in `max_tokens`. `"end_turn"` or `null` in streaming mode when the chunk is not the last.
  - `type` string, required — Completion response object type. This is always `"completion"`.

## Other responses

- `400` — Bad request. The request is invalid or an invalid API key is provided.
- `422` — Unprocessable Entity. There are missing fields in the request body.

---

[API](https://skmtc.net/x/apis/xai-s-rest-api.md) · [All operations](https://skmtc.net/x/apis/xai-s-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/x/xai-s-rest-api/versions/8f6014272113/schema)
