# place.hud.sendChatMessage

> Add the person's message to a chat (a new one where none is named), and start the model's answer: it reads with HUD's read tools as the person and draws its answer as tiles. Answers at once; the answer comes on getChatEvents, and is in getChat once done. Requires auth: the workspace's web session (its cookie, with X-HUD: 1 and the server's own Origin on a procedure) or a HUD access token as Bearer.

- Kind: procedure
- Authority: hud.place
- Lexicon: 1
- Published by [lexicons.hud.place](https://lexicon.garden/identity/did:plc:3tzbz4pml36u4mkresb6pdhv), the NSID's authority

## Links

- [Documentation](https://lexicon.garden/lexicon/did:plc:3tzbz4pml36u4mkresb6pdhv/place.hud.sendChatMessage)
- [Schema JSON](https://lexicon.garden/lexicon/did:plc:3tzbz4pml36u4mkresb6pdhv/place.hud.sendChatMessage/schema.json)
- [Analytics](https://lexicon.garden/lexicon/did:plc:3tzbz4pml36u4mkresb6pdhv/place.hud.sendChatMessage/analytics)

## Procedure (`place.hud.sendChatMessage`)

Type: procedure · POST

### Input (application/json)

- `chat` (string): The chat's id; none starts a new chat.
  - Constraints: minLength: 12, maxLength: 12
- `text` (string, required): The person's message.
  - Constraints: minLength: 1, maxLength: 8000

### Output (application/json)

- `chat` (string, required): The chat's id, new or as given.
  - Constraints: minLength: 12, maxLength: 12
- `turn` (integer, required): The turn the message and its answer share.
  - Constraints: minimum: 1

### Errors

- `NotFound`: No chat of this id is the person's.
- `Busy`: The model is still answering this chat's last message.
- `ChatUnavailable`: No longer answered: a server with no model to chat with serves no sendChatMessage (MethodNotImplemented).
- `InvalidRequest`: The input is not what the method takes.
- `AuthRequired`: No live web session or HUD access token: sign in.

## Schema

```json
{
  "$type": "com.atproto.lexicon.schema",
  "defs": {
    "main": {
      "description": "Add the person's message to a chat (a new one where none is named), and start the model's answer: it reads with HUD's read tools as the person and draws its answer as tiles. Answers at once; the answer comes on getChatEvents, and is in getChat once done. Requires auth: the workspace's web session (its cookie, with X-HUD: 1 and the server's own Origin on a procedure) or a HUD access token as Bearer.",
      "errors": [
        {
          "description": "No chat of this id is the person's.",
          "name": "NotFound"
        },
        {
          "description": "The model is still answering this chat's last message.",
          "name": "Busy"
        },
        {
          "description": "No longer answered: a server with no model to chat with serves no sendChatMessage (MethodNotImplemented).",
          "name": "ChatUnavailable"
        },
        {
          "description": "The input is not what the method takes.",
          "name": "InvalidRequest"
        },
        {
          "description": "No live web session or HUD access token: sign in.",
          "name": "AuthRequired"
        }
      ],
      "input": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "chat": {
              "description": "The chat's id; none starts a new chat.",
              "maxLength": 12,
              "minLength": 12,
              "type": "string"
            },
            "text": {
              "description": "The person's message.",
              "maxLength": 8000,
              "minLength": 1,
              "type": "string"
            }
          },
          "required": [
            "text"
          ],
          "type": "object"
        }
      },
      "output": {
        "encoding": "application/json",
        "schema": {
          "properties": {
            "chat": {
              "description": "The chat's id, new or as given.",
              "maxLength": 12,
              "minLength": 12,
              "type": "string"
            },
            "turn": {
              "description": "The turn the message and its answer share.",
              "minimum": 1,
              "type": "integer"
            }
          },
          "required": [
            "chat",
            "turn"
          ],
          "type": "object"
        }
      },
      "type": "procedure"
    }
  },
  "description": "Write to a chat, and have the model answer.",
  "id": "place.hud.sendChatMessage",
  "lexicon": 1
}
```
