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}'
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}'
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);
}
{
"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"
}
}
}
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}}
Messages
Send Message
Sends a user message and receives an AI-generated response.
POST
/
v1
/
boards
/
{boardId}
/
chats
/
{chatId}
/
messages
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}'
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}'
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);
}
{
"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"
}
}
}
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}}
Streaming
Whenstream: 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": "..."} |
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}'
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}'
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);
}
{
"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"
}
}
}
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}}
⌘I