API Overview REST API
ChatAI Plugin provides REST API for management and extension, supporting the Web panel and third-party integration.
Basic Information
| Item | Value | Description |
|---|---|---|
| Base URL | http://localhost:3000/api | Port configurable |
| Authentication | JWT Token | Supports Cookie or Bearer Token |
| Response Format | JSON | Unified JSON response structure |
| Rate Limit | 60 req/min | Default rate limit |
Architecture Overview
API Modules
Module Description
Each module provides a set of related API endpoints that can be used independently.
| Module | Path | Description | Docs |
|---|---|---|---|
| Auth | /api/auth | Login, verification, Token management | View |
| Config | /api/config | Config read/update, channel management, group config | View |
| Conversations | /api/conversations | Conversation history view and cleanup | View |
| Presets | /api/presets | Preset CRUD, preset file management | View |
| Tools | /api/tools | Tool management, execution, logs, dangerous tool config | View |
| MCP | /api/mcp | MCP server connection, management, SSE status push | View |
| Skills | /api/skills | Skills Agent endpoints, tool categories, global switch, SSE | View |
| Group Admin | /api/group-admin | Per-group configuration, group admin login | View |
| System | /api/system | Health checks, version info, statistics | View |
| Memory | /api/memory | Structured user memory management, categories, statistics | View |
| Knowledge Base | /api/knowledge | Knowledge base document CRUD, search | View |
| Knowledge Graph | /api/graph | Entity/relationship/property CRUD, visualization data | View |
| Image | /api/image | Drawing preset management, remote preset caching | View |
| Game | /api/game | Galgame character preset management | View |
| Logs | /api/logs | Log file listing, error log viewing | View |
| Proxy | /api/proxy | Network proxy configuration management | View |
| Scope | /api/scope | User/group level independent config management | View |
Authentication
Get Login Link
How to Get
Send #ai管理面板 to the bot for a temporary login link, or #ai管理面板 永久 for a permanent link.
Login Flow
API Authentication
bash
# Browser automatically carries Cookie
curl http://localhost:3000/api/config \
-H "Cookie: auth_token=xxx"bash
# For third-party calls
curl http://localhost:3000/api/config \
-H "Authorization: Bearer xxx"Response Format
json
{
"success": true,
"data": { ... }
}json
{
"success": false,
"error": "Error message",
"code": "ERROR_CODE"
}Error Codes
| Code | Description | Common Causes |
|---|---|---|
200 | Success | - |
400 | Bad Request | Missing required params, invalid format |
401 | Unauthorized | Token missing or expired |
403 | Forbidden | No permission to access resource |
404 | Not Found | Requested resource not found |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server-side exception |
Rate Limiting
Rate Limit Rules
- Window: 60 seconds
- Max Requests: 60 requests
- Exceeding the limit returns a
429status code
SSE Endpoints
Some endpoints support Server-Sent Events for real-time push:
javascript
const eventSource = new EventSource('/api/skills/sse')
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data)
console.log('Status update:', data)
}
eventSource.onerror = (error) => {
console.error('SSE Error:', error)
}Detailed API Documentation
| Document | Description | Main Endpoints |
|---|---|---|
| Authentication | Login & verification | POST /auth/verify, POST /auth/logout |
| Configuration | Config & channel management | GET /config, PUT /config, POST /config/channels |
| Chat | Conversations & memory | POST /chat, GET /chat/history |
| Tools | Tool management | GET /tools, POST /tools/:name/execute |
| Skills | Skills Agent | GET /skills/categories, POST /skills/toggle-category |
| MCP | MCP servers | GET /mcp/servers, POST /mcp/servers/:name/connect |
| Memory | User memories | GET /memories/users, POST /memories/user/:userId |
| Knowledge Base | Knowledge documents | GET /knowledge, GET /knowledge/search |
| Knowledge Graph | Entities & relationships | GET /graph/entities, POST /graph/relationships |
| Image | Drawing presets | GET /image/presets, PUT /image/config |
| Game | Galgame | GET /game/presets, POST /game/presets |
| Logs | Log viewing | GET /logs, GET /logs/recent |
| Proxy | Network proxy | GET /proxy, PUT /proxy/scopes/:scope |
| Scope | Granular config | GET /scope/users, PUT /scope/group/:groupId |