Chat API
Conversations, messages, streaming sends, async tasks, Chat configuration, and WeChat QR code login.
Apart from the two public image endpoints (understanding and image serving), Chat endpoints are user_only: use a grape_ API key or a web JWT; tk_ returns 403.
Endpoints
Conversations and messages
| Method | Path | Purpose |
|---|---|---|
GET |
/api/chat/conversations |
List conversations |
POST |
/api/chat/conversations |
Create conversation |
DELETE |
/api/chat/conversations/{conv_id} |
Delete conversation |
POST |
/api/chat/conversations/ensure-issue |
Ensure an Issue conversation |
GET |
/api/chat/messages/{conv_id} |
Conversation messages |
POST |
/api/chat/messages/{msg_id}/recall |
Recall a message |
GET |
/api/chat/analyze-image |
Image understanding: download the image and return a text description (for Agents) |
GET |
/api/chat/image/{conv_id}/{filename} |
Serve a conversation image (no auth; timestamped filenames are unguessable) |
Sending
| Method | Path | Purpose |
|---|---|---|
POST |
/api/chat/send |
Regular send |
POST |
/api/chat/send/stream |
SSE streaming send |
POST |
/api/chat/send/async |
Async send |
GET |
/api/chat/task/{task_id}/status |
Async task status |
GET |
/api/chat/task/{task_id}/stream |
Async task stream |
POST |
/api/chat/submit |
Task Scene submission |
Configuration and channels
| Method | Path | Purpose |
|---|---|---|
POST |
/api/chat/feedback |
Submit Chat feedback |
GET |
/api/chat/config |
Read Chat configuration |
PUT |
/api/chat/config |
Update Chat configuration |
POST |
/api/chat/im/wechat/login/start |
WeChat QR code login: get the QR code |
GET |
/api/chat/im/wechat/login/status |
WeChat QR code login status |
Sending a message
curl -fsS -X POST "$GRAPE_BASE_URL/api/chat/send" \
-H @~/.grape.auth -H 'Content-Type: application/json' \
-d '{"conversation_id":"<conv-id>","content":"<message>"}'
Streaming send:
POST /api/chat/send/stream
Accept: text/event-stream
Event format:
data: {"type":"text","text":"..."}
data: {"type":"done","reply":"...","messages":[...]}
The stream is complete only after a done event appears; error frames are {"type":"error","text":"..."}.
Sending asynchronously
POST /api/chat/send/asyncreturns a task id- Poll with
GET /api/chat/task/{task_id}/status - Use
GET /api/chat/task/{task_id}/streamwhen streaming results are required
WeChat QR code login
POST /api/chat/im/wechat/login/startgets the QR code- Short-poll with
GET /api/chat/im/wechat/login/status - After the status succeeds, channel binding is complete
Both the QR code and the login state expire. Start a new request after expiry; do not reuse an old QR code.
Common errors
| Status | Cause |
|---|---|
| 400 | Missing conversation or message field |
| 401 | Unauthenticated |
| 403 | tk_ used, or the conversation does not belong to the current user |
| 404 | Conversation or message does not exist |
| 429 | Sending too frequently |