Inference API

Legacy & Deprecated

View as Markdown

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).

createdinteger

The chat completion creation time in Unix timestamp.

idstring

ID of the request.

modelstring

Model to be used.

objectstring

Object type of the response. This is always `"text_completion"`.

Exampletext

text

{
  "prompt": "1, 2, 3, 4, ",
  "model": "grok-3",
  "max_tokens": 3
}
Exampletext

text

{
  "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.

idstring

Unique object identifier.

modelstring

Model name that handled the request.

rolestring

Role of the generated message. Always `"assistant"`

typestring

Object type. This is always `"message"` for message types.

usageobject

Exampletext

text

{
  "model": "latest",
  "max_tokens": 32,
  "messages": [
    {
      "role": "user",
      "content": "Hello, world"
    }
  ]
}
Exampletext

text

{
  "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

completionstring

The completion content up to and excluding stop sequences.

idstring

ID of the completion response.

modelstring

The model that handled the request.

typestring

Completion response object type. This is always `"completion"`.

Exampletext

text

{
  "model": "grok-3",
  "max_tokens_to_sample": 8,
  "temperature": 0.1,
  "prompt": "\n\nHuman: Hello, how are you?\n\nAssistant:"
}
Exampletext

text

{
  "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