> ## Documentation Index
> Fetch the complete documentation index at: https://docs.quickblox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Answer Assist

<Warning>
  Before call make sure that AI Answer Assist feature enabled on admin
  dashboard, otherwise you will get 405 error.
</Warning>

#### Body Parameters

<ParamField body="smart_chat_assistant_id" type="string" required>
  Smart Chat Assistant id.
</ParamField>

<ParamField body="message" type="string" required>
  Message you want to get answer for. The maximum length for the message is 2000
  symbols.
</ParamField>

<ParamField body="history" type="array">
  Conversation history. Used to add context.

  <Expandable title="Object">
    <ParamField body="role" type="string" required>
      May be user or assistant.
    </ParamField>

    <ParamField body="message" type="string" required>
      Text message.
    </ParamField>
  </Expandable>
</ParamField>

#### Headers

<ParamField header="QB-Token" type="string" required>
  A user or application session token. See [Authentication](/reference/authentication)
  page to learn more about session tokens.
</ParamField>

#### Responses

<AccordionGroup>
  <Accordion title="200">
    A successful response

    <ResponseField name="answer" type="string" />
  </Accordion>

  <Accordion title="400">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>

  <Accordion title="404">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>

  <Accordion title="405">
    An error response

    <ResponseField name="errors" type="array of strings" />
  </Accordion>
</AccordionGroup>

<RequestExample>
  ```bash cURL theme={null}
  curl -X POST \
  -H "Content-Type: application/json" \
  -H "QB-Token: eddf864695d72d33b959eec2ae6c640d817dfada" \
  -d '{
    "smart_chat_assistant_id": "65d5f3473d5d68095462165d",
    "message": "Who are you?",
    "history": [
      {
        "role": "assistant",
        "message": "History message"
      },
      {
        "role": "user",
        "message": "Hi"
      },
      {
        "role": "assistant",
        "message": "Hello! How can I assist you today?"
      }
    ]
  }' \
  https://api.quickblox.com/ai/ai_extensions/ai_answer_assist
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "answer": "Hello! How can I assist you today?"
  }
  ```

  ```json 400 theme={null}
  {
    "errors": [
      "Validation Error: history: Invalid history data, must be an array of objects with keys: role(must be user or assistant) and message(string). For example:\n{\"history\":[{\"role\":\"user\", \"message\":\"Some message\"}]}"
    ]
  }
  ```

  ```json 404 theme={null}
  {
    "errors": [
      "The resource wasn't found"
    ]
  }
  ```

  ```json 405 theme={null}
  {
    "errors": [
      "AI Answer Assistant is disabled"
    ]
  }
  ```
</ResponseExample>
