Inference API
Legacy & Deprecated
Completions (legacy)
/v1/completions
(Legacy - Not supported by reasoning models) Create a text completion response for a given prompt. Replaced by /v1/chat/completions.
Request Body
Response Body
choicesarray<object>A list of response choices from the model. The length corresponds to the `n` in request body (default to 1).
createdintegerThe chat completion creation time in Unix timestamp.
idstringID of the request.
modelstringModel to be used.
objectstringObject type of the response. This is always `"text_completion"`.
{
"prompt": "1, 2, 3, 4, ",
"model": "grok-3",
"max_tokens": 3
}{
"id": "873492b3-6144-4279-ac2e-2c45242c5ce6",
"object": "text_completion",
"created": 1743771779,
"model": "grok-3",
"choices": [
{
"index": 0,
"text": "5, ",
"finish_reason": "length"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 3,
"total_tokens": 15,
"prompt_tokens_details": {
"text_tokens": 12,
"audio_tokens": 0,
"image_tokens": 0,
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 0,
"audio_tokens": 0,
"accepted_prediction_tokens": 0,
"rejected_prediction_tokens": 0
}
},
"system_fingerprint": "fp_156d35dcaa"
}Messages (Anthropic compatible - deprecated)
/v1/messages
Create a messages response. This endpoint is compatible with the Anthropic API.
Request Body
Response Body
contentarray<object | object | object | object>Response message content.
idstringUnique object identifier.
modelstringModel name that handled the request.
rolestringRole of the generated message. Always `"assistant"`
typestringObject type. This is always `"message"` for message types.
usageobject{
"model": "latest",
"max_tokens": 32,
"messages": [
{
"role": "user",
"content": "Hello, world"
}
]
}{
"id": "4f224bfb-9d53-4c82-b40a-b7cd80831ec2",
"type": "message",
"role": "assistant",
"content": [
{
"type": "text",
"text": "Hello there! \"Hello, world\" is a classic, isn't it? Whether you're just saying hi or channeling your inner coder, I'm happy to greet you back"
}
],
"model": "latest",
"stop_reason": "max_tokens",
"stop_sequence": null,
"usage": {
"input_tokens": 9,
"cache_creation_input_tokens": 0,
"cache_read_input_tokens": 0,
"output_tokens": 32
}
}Completions (Anthropic compatible - deprecated)
/v1/complete
(Legacy - Not supported by reasoning models) Create a text completion response. This endpoint is compatible with the Anthropic API.
Request Body
Response Body
completionstringThe completion content up to and excluding stop sequences.
idstringID of the completion response.
modelstringThe model that handled the request.
typestringCompletion response object type. This is always `"completion"`.
{
"model": "grok-3",
"max_tokens_to_sample": 8,
"temperature": 0.1,
"prompt": "\n\nHuman: Hello, how are you?\n\nAssistant:"
}{
"type": "completion",
"id": "982044c5-760c-4c8d-8936-f906b5cedc26",
"completion": " Hey there! I'm doing great, thanks",
"stop_reason": "max_tokens",
"model": "grok-3"
}Last updated:September 2, 2026