Skip to content

Chat API Chat ​

API endpoints for chat and conversation management.

Send Message ​

POST /api/chat ​

Send a message and get AI response.

Request:

json
{
  "message": "Hello, how are you?",
  "userId": "123456789",
  "groupId": "987654321",
  "preset": "default"
}

Response:

json
{
  "success": true,
  "data": {
    "response": "I'm doing great, thank you for asking!",
    "conversationId": "conv_abc123",
    "usage": {
      "promptTokens": 50,
      "completionTokens": 20,
      "totalTokens": 70
    }
  }
}

Stream Message ​

POST /api/chat/stream ​

Send message with streaming response.

Request: Same as /api/chat

Response (SSE):

data: {"type": "start", "conversationId": "conv_abc123"}
data: {"type": "content", "text": "I'm "}
data: {"type": "content", "text": "doing "}
data: {"type": "content", "text": "great!"}
data: {"type": "end", "usage": {...}}

List Conversations ​

GET /api/conversations ​

Get conversation history.

Query Parameters:

ParamTypeDescription
userIdstringFilter by user
groupIdstringFilter by group
limitnumberMax results
offsetnumberPagination

Response:

json
{
  "success": true,
  "data": {
    "conversations": [
      {
        "id": "conv_abc123",
        "userId": "123456789",
        "groupId": "987654321",
        "messageCount": 10,
        "lastMessage": "Thanks for the help!",
        "updatedAt": 1702622400000
      }
    ],
    "total": 50
  }
}

Get Conversation ​

GET /api/conversations/:id ​

Get specific conversation with messages.

Response:

json
{
  "success": true,
  "data": {
    "id": "conv_abc123",
    "messages": [
      {
        "role": "user",
        "content": "Hello",
        "timestamp": 1702622300000
      },
      {
        "role": "assistant",
        "content": "Hi there!",
        "timestamp": 1702622310000
      }
    ]
  }
}

Delete Conversation ​

DELETE /api/conversations/:id ​

Delete a conversation.

Response:

json
{
  "success": true
}

Clear Context ​

POST /api/conversations/:id/clear ​

Clear conversation context.

Response:

json
{
  "success": true,
  "message": "Context cleared"
}

Error Codes ​

CodeDescription
CONVERSATION_NOT_FOUNDConversation doesn't exist
CHANNEL_UNAVAILABLENo available channels
RATE_LIMITEDToo many requests
MODEL_ERRORModel returned error

Next Steps ​

Released under the MIT License