Skip to content

API Overview REST API

ChatAI Plugin provides REST API for management and extension, supporting 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/configConfiguration read/updateView
Channels/api/channelsChannel CRUD, testing, model list-
Conversations/api/conversationsConversation history management-
Presets/api/presetsPreset CRUD-
Tools/api/toolsTool management and logsView
MCP/api/mcpMCP server managementView
Skills/api/skillsSkills agent interface-
Group Admin/api/group-adminGroup-specific configuration-
System/api/systemSystem status and statistics-

Authentication

How to Get

Send #ai管理面板 to bot for temporary login link, or #ai管理面板 永久 for 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 limit returns 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/login, GET /auth/verify
ConfigurationConfig managementGET /config, PUT /config
ToolsTool managementGET /tools, POST /tools/call
MCPMCP serversGET /mcp/servers, POST /mcp/connect
ChatChat functionalityPOST /chat, GET /conversations

Released under the MIT License