Generate a chat completion Technical Preview

POST /api/observability_ai_assistant/chat/complete

Create a new chat completion by using the Observability AI Assistant.

The API returns the model's response based on the current conversation context.

It also handles any tool requests within the conversation, which may trigger multiple calls to the underlying large language model (LLM).

This functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.

application/json

Body

  • actions array[object]
    Hide actions attributes Show actions attributes object
    • description string

      The description of the function.

    • name string

      The name of the function.

    • parameters object

      The parameters of the function.

  • connectorId string Required

    A unique identifier for the connector.

  • conversationId string

    A unique identifier for the conversation if you are continuing an existing conversation.

  • disableFunctions boolean

    Flag indicating whether all function calls should be disabled for the conversation. If true, no calls to functions will be made.

  • instructions array[string | object]

    An array of instruction objects, which can be either simple strings or detailed objects.

    One of:

    A simple instruction represented as a string.

  • messages array[object] Required

    An array of message objects containing the conversation history.

    Hide messages attributes Show messages attributes object
    • @timestamp string Required

      The timestamp when the message was created.

    • message object Required

      The main content of the message.

      Hide message attributes Show message attributes object
      • content string

        The content of the message.

      • data string

        Additional data associated with the message.

      • event string

        The event related to the message.

      • function_call object

        Details of the function call within the message.

        Hide function_call attributes Show function_call attributes object
        • arguments string

          The arguments for the function call.

        • name string Required

          The name of the function.

        • trigger string Required

          The trigger of the function call.

          Values are assistant, user, or elastic.

      • name string

        The name associated with the message.

      • role string Required

        The role of the message sender.

        Values are system, assistant, function, user, or elastic.

  • persist boolean Required

    Indicates whether the conversation should be saved to storage. If true, the conversation will be saved and will be available in Kibana.

  • title string

    A title for the conversation.

Responses

  • 200 application/json

    Successful response

POST /api/observability_ai_assistant/chat/complete
curl --request POST 'localhost:5601/api/observability_ai_assistant/chat/complete' -u <username>:<password> -H 'kbn-xsrf: true' -H "Content-Type: application/json" --data '
{
"connectorId": "<connectorId>",
"disableFunctions": false,
  "messages": [
    {
      "@timestamp": "2025-06-25T23:45:00.000Z",
      "message": {
        "role": "user",
        "content": "Is my Elasticsearch cluster healthy right now?"
      }
    }
  ],
"persist": false,
"actions": [
  {
    "name": "get_cluster_health",
    "description": "Fetch the current Elasticsearch cluster-health status and key metrics.",
    "parameters": {
      "type": "object",
      "properties": {
        "includeShardStats": {
          "type": "boolean",
          "default": false
        }
      }
    }
  }
],
"instructions": ["When the user asks about Elasticsearch cluster health, use the get_cluster_health tool to retrieve cluster health, then summarize the response in plain English."]
}'
Request example
{
  "connectorId": "<connectorId>",
  "disableFunctions": false,
  "messages": [
    {
      "@timestamp": "2025-06-25T23:45:00.000Z",
      "message": {
        "role": "user",
        "content": "Is my Elasticsearch cluster healthy right now?"
      }
    }
  ],
  "persist": false,
  "actions": [
    {
      "name": "get_cluster_health",
      "description": "Fetch the current Elasticsearch cluster-health status and key metrics.",
      "parameters": {
        "type": "object",
        "properties": {
          "includeShardStats": {
            "type": "boolean",
            "default": false
          }
        }
      }
    }
  ],
  "instructions": ["When the user asks about Elasticsearch cluster health, use the get_cluster_health tool to retrieve cluster health, then summarize the response in plain English."]
}
Response examples (200)
data: {"model":"unknown","choices":[{"delta":{"content":"","function_call":{"name":"get_cluster_health","arguments":"{\"includeShardStats\":true}"}},"finish_reason":null,"index":0}],"created":1750936626911,"id":"9c8eff9b-4fd4-4203-a4ab-2e364688deff","object":"chat.completion.chunk"}

data: [DONE]