---
title: "Generate a chat completion"
method: POST
path: "/api/observability_ai_assistant/chat/complete"
tags: ["observability_ai_assistant"]
---

# Generate a chat completion

`POST /api/observability_ai_assistant/chat/complete`

**Spaces method and path for this operation:**

<div><span class="operation-verb post">post</span>&nbsp;<span class="operation-path">/s/{space_id}/api/observability_ai_assistant/chat/complete</span></div>

Refer to [Spaces](https://www.elastic.co/docs/deploy-manage/manage-spaces) for more information.

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.

## Request body

- object
  - `actions` ObservabilityAIAssistantAPIFunction[]
    - `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` ObservabilityAIAssistantAPIInstruction[] — An array of instruction objects, which can be either simple strings or detailed objects.
    - union
      - string — A simple instruction represented as a string.
      - object — A detailed instruction with an ID and text.
        - `id` string, required — A unique identifier for the instruction.
        - `text` string, required — The text of the instruction.
  - `messages` ObservabilityAIAssistantAPIMessage[], required — An array of message objects containing the conversation history.
    - `@timestamp` string, required — The timestamp when the message was created.
    - `message` object, required — The main content of the message.
      - `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` ObservabilityAIAssistantAPIFunctionCall — Details of the function call within the message.
        - `arguments` string — The arguments for the function call.
        - `name` string, required — The name of the function.
        - `trigger` 'assistant' | 'user' | 'elastic', required — The trigger of the function call.
      - `name` string — The name associated with the message.
      - `role` 'system' | 'assistant' | 'function' | 'user' | 'elastic', required — The role of the message sender.
  - `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.

## Response `200`

Successful response

- object

---

[API](https://skmtc.net/elastic/apis/kibana-apis.md) · [All operations](https://skmtc.net/elastic/apis/kibana-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/elastic/kibana-apis/versions/531c9e2a7d23/schema)
