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

# Send Message

> Sends a user message and receives an AI-generated response.

## Streaming

When `stream: true`, the response is a `text/event-stream` with three event
types:

| Event              | Description                                                          |
| ------------------ | -------------------------------------------------------------------- |
| `message.delta`    | Incremental content fragment: `{"content": "..."}`                   |
| `message.complete` | Full message and token usage after streaming finishes                |
| `error`            | Error during streaming: `{"code": "stream_error", "message": "..."}` |

The conversation history (last 50 messages) and thread memory are
automatically included in the AI context.

<RequestExample>
  ```bash cURL (non-streaming) theme={null}
  curl -X POST "https://api.chatgrid.ai/v1/boards/a1b2c3d4-e5f6-7890-abcd-ef1234567890/chats/b2c3d4e5-f6a7-8901-bcde-f12345678901/messages" \
    -H "Authorization: Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
    -H "Content-Type: application/json" \
    -d '{"content": "What are the top SaaS marketing channels?", "stream": false}'
  ```

  ```bash cURL (streaming) theme={null}
  curl -N -X POST "https://api.chatgrid.ai/v1/boards/a1b2c3d4-e5f6-7890-abcd-ef1234567890/chats/b2c3d4e5-f6a7-8901-bcde-f12345678901/messages" \
    -H "Authorization: Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6" \
    -H "Content-Type: application/json" \
    -d '{"content": "What are the top SaaS marketing channels?", "stream": true}'
  ```

  ```typescript Node.js (streaming) theme={null}
  const response = await fetch(
    "https://api.chatgrid.ai/v1/boards/{boardId}/chats/{chatId}/messages",
    {
      method: "POST",
      headers: {
        Authorization: "Bearer cgk_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6",
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        content: "What are the top SaaS marketing channels?",
        stream: true,
      }),
    }
  );

  const reader = response.body.getReader();
  const decoder = new TextDecoder();

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    const text = decoder.decode(value, { stream: true });
    process.stdout.write(text);
  }
  ```
</RequestExample>

<ResponseExample>
  ```json 200 (non-streaming) theme={null}
  {
    "object": "message",
    "data": {
      "id": "e5f6a7b8-c9d0-1234-efab-345678901234",
      "role": "assistant",
      "content": "Here are the top 3 SaaS marketing channels:\n\n1. **Content Marketing & SEO** ...",
      "model": "anthropic/claude-sonnet-4",
      "created_at": "2026-03-15T12:50:05.000Z",
      "metadata": {
        "usage": {
          "prompt_tokens": 245,
          "completion_tokens": 312,
          "total_tokens": 557
        },
        "finish_reason": "stop"
      }
    }
  }
  ```

  ```text SSE stream (streaming) theme={null}
  event: message.delta
  data: {"content":"Here are"}

  event: message.delta
  data: {"content":" the top 3"}

  event: message.delta
  data: {"content":" SaaS marketing channels..."}

  event: message.complete
  data: {"message":{"id":"e5f6a7b8-c9d0-1234-efab-345678901234","role":"assistant","content":"Here are the top 3 SaaS marketing channels...","model":"anthropic/claude-sonnet-4","created_at":"2026-03-15T12:50:05.000Z"},"usage":{"prompt_tokens":245,"completion_tokens":312,"total_tokens":557}}
  ```
</ResponseExample>
