Type to search.

Perform streaming chat completion inference on the service

Auth

The chat completion inference API enables real-time responses for chat completion tasks by delivering answers incrementally, reducing response times during computation. It only works with the chat_completion task type.

Note

The chat_completion task type supports both streaming and non-streaming. The Chat completion inference API and the Stream inference API differ in their response structure and capabilities. The Chat completion inference API provides more comprehensive customization options through more fields and function calling support. To determine whether a given inference service supports this task type, please see the page for that service.

Required privileges

Cluster privileges monitor_inference

Path parameters

inference_id string required

The inference Id

Query parameters

timeout union oneOf · default: 120s

Specifies the amount of time to wait for the inference request to complete.

Values: -1 0

Request body

messages object[] required

A list of objects representing the conversation. Requests should generally only add new messages from the user (role user). The other message roles (assistant, system, or tool) should generally only be copied from the response to a previous completion request, such that the messages array is built up throughout a conversation.

content union oneOf

The content of the message.

String example:

Text
{
   "content": "Some string"
}

Text example:

Text
{
  "content": [
      {
       "text": "Some text",
       "type": "text"
      }
   ]
}

Image example:

Text
{
  "content": [
      {
       "image_url": {
         "url": "data:image/jpeg;base64,..."
       },
       "type": "image_url"
      }
   ]
}

File example:

Text
{
  "content": [
      {
       "file": {
         "file_data": "data:application/pdf;base64,...",
         "filename": "somePDF"
       },
       "type": "file"
      }
   ]
}
One of:
role string required

The role of the message author. Valid values are user, assistant, system, and tool.

tool_call_id string

Only for tool role messages. The tool call that this message is responding to.

reasoning string

Only for assistant role messages. The reasoning details generated by the model as plaintext. Currently supported only for elastic provider.

reasoning_details union oneOf[]

Only for assistant role messages. The reasoning details generated by the model as structured data. Currently supported only for elastic provider.

One of:

The reasoning detail with encrypted reasoning data that may be redacted or protected.

type enum required
Values: reasoning.encrypted
format string

The format of the reasoning detail.

id string

The identifier of the reasoning detail.

index number

The index of the reasoning detail, which indicates its position in the sequence of reasoning details generated by the model.

data string required

The encrypted reasoning data generated by the model, which may be redacted or protected based on the model's configuration and the nature of the reasoning information.

model string

The ID of the model to use. By default, the model ID is set to the value included when creating the inference endpoint.

max_completion_tokens number

The upper bound limit for the number of tokens that can be generated for a completion request.

stop string[]

A sequence of strings to control when the model should stop generating additional tokens.

temperature number

The sampling temperature to use.

tool_choice union oneOf

Controls which tool is called by the model. String representation: One of auto, none, or requrired. auto allows the model to choose between calling tools and generating a message. none causes the model to not call any tools. required forces the model to call one or more tools. Example (object representation):

Text
{
  "tool_choice": {
      "type": "function",
      "function": {
          "name": "get_current_weather"
      }
  }
}
One of:
top_p number

Nucleus sampling, an alternative to sampling with temperature.

Response

application/json

Response Type: object