---
type: api
title: Create a model response
description: **Spaces method and path for this operation:**
url: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-chatcomplete
resource: https://www.elastic.co/elastic/docs-builder/docs/4371/api/doc/kibana/v8/operation/operation-chatcomplete
products:
  - Kibana
---

# Create a model response

- Server: `https://{kibana_url}`

## Paths

- `POST` `/api/security_ai_assistant/chat/complete`
- `POST` `/s/{space_id}/api/security_ai_assistant/chat/complete`

- [Api key auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v8/authentication#apikeyauth)
- [Basic auth](/elastic/docs-builder/docs/4371/api/doc/kibana/v8/authentication#basicauth)

## Description

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

Create a model response for the given chat conversation.

## Query String Parameters

- `content_references_disabled` (boolean · default: false)
  If true, the response will not include content references.

## Request Body

`application/json`

- `connectorId` (string) — required
  Required connector identifier to route the request.
- `conversationId` (string · min: 1) — optional
  A string that does not contain only whitespace characters.
- `isStream` (boolean) — optional
  If true, the response will be streamed in chunks.
- `langSmithApiKey` (string) — optional
  API key for LangSmith integration.
- `langSmithProject` (string) — optional
  LangSmith project name for tracing.
- `messages` ([] object) — required
  List of chat messages exchanged so far.
  - `content` (string) — optional
    The textual content of the message.
  - `data` (object) — optional
    ECS-style metadata attached to the message.
  - `fields_to_anonymize` ([] string) — optional
    List of field names within the data object that should be anonymized.
  - `role` (enum) — required
    The role associated with the message in the chat.
    Values: `system`, `user`, `assistant`
- `model` (string) — optional
  Model ID or name to use for the response.
- `persist` (boolean) — required
  Whether to persist the chat and response to storage.
- `promptId` (string) — optional
  Prompt template identifier.
- `responseLanguage` (string) — optional
  ISO language code for the assistant's response.

## Responses

#### `200`

Indicates a successful model response call.

`application/octet-stream`

Type: `string`

#### `400`

Generic Error

`application/json`

- `error` (string)
  Error type.
- `message` (string)
  Human-readable error message.
- `statusCode` (number)
  HTTP status code.
## Code Examples

#### Console

```console
POST /api/security_ai_assistant/chat/complete
```

#### curl

```curl
curl -X POST "https://{kibana_url}/api/security_ai_assistant/chat/complete"
```

