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

# AI Message

> Send a message to your AI and receive a response

## Overview

API endpoint for interacting with your AI through messages. This endpoint allows you to have conversations with your AI and receive responses based on your AI's training.

## Authorization

<ParamField header="x-api-key" type="string" required>
  Your Personal AI API key
</ParamField>

## Headers

<ParamField header="Content-Type" type="string" required>
  Must be set to application/json
</ParamField>

## Body

<ParamField body="Text" type="string" required>
  Message to send to your AI for a response

  ```json Example theme={null}
  "What is an SLM?"
  ```
</ParamField>

<ParamField body="Context" type="string" optional>
  Message to add additional context to the AI for a response (Similar to Reply function)

  ```json Example theme={null}
  "Context": "Reply in one sentence."
  ```
</ParamField>

<ParamField body="DomainName" type="string" required>
  The hyphenated text below the AI's name when clicked into a Persona.

  <img alt="DomainName" classname="block dark:hidden" src="https://mintcdn.com/personalai/kGsTZefXJjPC-_P1/images/domainname.png?fit=max&auto=format&n=kGsTZefXJjPC-_P1&q=85&s=36b7c320c44dba9f962cdb342de41f3a" width="1140" height="416" data-path="images/domainname.png" />

  ```json Example theme={null}
  "DomainName": "product-demo-jebzrhw"
  ```
</ParamField>

<ParamField body="UserName" type="string" optional>
  Name of the user sending the request

  ```json Example theme={null}
  "UserName": "Leila"
  ```
</ParamField>

<ParamField body="SessionId" type="string" optional>
  Use the same sessionId to continue conversation on that session

  ```json Example theme={null}
  "SessionId": "d5e9f208-937c-4a9c-92bf-5fb90ce68ff6"
  ```
</ParamField>

<ParamField body="Events" type="string" optional>
  Name of the document you want to refer to in your AI's Upload Library. This functions in the same way as the colon function does in the Personal AI platform.

  ```json Example theme={null}
  "Event": "How to train your AI"
  ```
</ParamField>

<ParamField body="SourceName" type="string" optional>
  Name of the source app of the inbound message, required if using with triggers

  ```json Example theme={null}
  "SourceName": "slack"
  ```
</ParamField>

<ParamField body="is_stack" type="boolean" optional>
  Flag to also add the user message (Text) to memory. Defaults to false if nothing is entered.

  ```json Example theme={null}
  "is_stack": true
  ```
</ParamField>

<ParamField body="is_draft" type="boolean" optional>
  Flag to create a copilot message for the AI. Defaults to false if nothing is entered.

  ```json Example theme={null}
  "is_draft": true
  ```
</ParamField>

```json Example theme={null}
{
    "Text": "What is an SLM?",
    "Context": "Reply in one sentence.",
    "DomainName": "product-demo-jebzrhw",
    "UserName": "Leila",
    "SessionId": "d5e9f208-937c-4a9c-92bf-5fb90ce68ff6",
    "Events": "How to train your AI",
    "SourceName": "slack",
    "is_draft": true,
    "is_stack": true,
    "Metadata": {
        "key": "value"
    }
}
```

***

## Example Responses

<ResponseField name="ai_message" type="string">
  The AI's response message
</ResponseField>

<ResponseField name="ai_score" type="number">
  Confidence score of the AI's response
</ResponseField>

<ResponseField name="SessionId" type="string">
  Session identifier for the conversation
</ResponseField>

```json Example Success Response theme={null}
{
    "ai_message": "SLMs or PLMS PLMs are artificial intelligence (AI) models capable of understanding and generating information within the domain of an individual user. ",
    "ai_score": 47.18898852308854,
    "ai_name": "AI Name",
    "ai_picture": "https://example.com/picture.jpg",
    "SessionId": "d5e9f208-937c-4a9c-92bf-5fb90ce68ff6",
    "source_app": "api"
}
```

```json Example Error Response theme={null}
{
    "detail": "AI message api unauthorized."
}
```

***

## Examlpe cURL

```bash cURL theme={null}
curl --location 'https://api.personal.ai/v1/message' \
--header 'Content-Type: application/json' \
--header 'x-api-key: <your-api-key>' \
--data '{
    "Text": "What is an SLM?",
    "DomainName": "product-demo-jebzrhw",
    "UserName": "Leila",
    "SourceName": "slack",
    "is_draft": true,
    "SessionId": "d5e9f208-937c-4a9c-92bf-5fb90ce68ff6",
    "Events": "How to train your AI"
}'
```

***

## Error Codes

| Code | Description                                                      |
| ---- | ---------------------------------------------------------------- |
| 403  | Forbidden - Check that API key is invalid                        |
| 503  | Threshold Failure - Generated AI message is below user threshold |
