Skip to content

API Overview REST API

ChatAI Plugin provides REST API for management and extension, supporting the Web panel and third-party integration.

Basic Information

ItemValueDescription
Base URLhttp://localhost:3000/apiPort configurable
AuthenticationJWT TokenSupports Cookie or Bearer Token
Response FormatJSONUnified JSON response structure
Rate Limit60 req/minDefault rate limit

Architecture Overview

API Modules

Module Description

Each module provides a set of related API endpoints that can be used independently.

ModulePathDescriptionDocs
Auth/api/authLogin, verification, Token managementView
Config/api/configConfig read/update, channel management, group configView
Conversations/api/conversationsConversation history view and cleanupView
Presets/api/presetsPreset CRUD, preset file managementView
Tools/api/toolsTool management, execution, logs, dangerous tool configView
MCP/api/mcpMCP server connection, management, SSE status pushView
Skills/api/skillsSkills Agent endpoints, tool categories, global switch, SSEView
Group Admin/api/group-adminPer-group configuration, group admin loginView
System/api/systemHealth checks, version info, statisticsView
Memory/api/memoryStructured user memory management, categories, statisticsView
Knowledge Base/api/knowledgeKnowledge base document CRUD, searchView
Knowledge Graph/api/graphEntity/relationship/property CRUD, visualization dataView
Image/api/imageDrawing preset management, remote preset cachingView
Game/api/gameGalgame character preset managementView
Logs/api/logsLog file listing, error log viewingView
Proxy/api/proxyNetwork proxy configuration managementView
Scope/api/scopeUser/group level independent config managementView

Authentication

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

CodeDescriptionCommon Causes
200Success-
400Bad RequestMissing required params, invalid format
401UnauthorizedToken missing or expired
403ForbiddenNo permission to access resource
404Not FoundRequested resource not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side exception

Rate Limiting

Rate Limit Rules

  • Window: 60 seconds
  • Max Requests: 60 requests
  • Exceeding the limit returns a 429 status 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

DocumentDescriptionMain Endpoints
AuthenticationLogin & verificationPOST /auth/verify, POST /auth/logout
ConfigurationConfig & channel managementGET /config, PUT /config, POST /config/channels
ChatConversations & memoryPOST /chat, GET /chat/history
ToolsTool managementGET /tools, POST /tools/:name/execute
SkillsSkills AgentGET /skills/categories, POST /skills/toggle-category
MCPMCP serversGET /mcp/servers, POST /mcp/servers/:name/connect
MemoryUser memoriesGET /memories/users, POST /memories/user/:userId
Knowledge BaseKnowledge documentsGET /knowledge, GET /knowledge/search
Knowledge GraphEntities & relationshipsGET /graph/entities, POST /graph/relationships
ImageDrawing presetsGET /image/presets, PUT /image/config
GameGalgameGET /game/presets, POST /game/presets
LogsLog viewingGET /logs, GET /logs/recent
ProxyNetwork proxyGET /proxy, PUT /proxy/scopes/:scope
ScopeGranular configGET /scope/users, PUT /scope/group/:groupId

Released under the MIT License