Notes
November 4, 2025 ยท View on GitHub
๐ 1. Add User Token
- Endpoint:
POST /user/token/add - Description: Add available tokens for a user.
- Request Body (JSON):
{
"user_id": "string",
"token": 100
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | string | Yes | Unique identifier for the user |
| token | int | Yes | Number of tokens to add |
- Response Example:
{
"code": 0,
"msg": "success",
"data": null
}
๐ 2. Get User List
- Endpoint:
GET /user/list - Description: Get a paginated list of users, optionally filtered by
user_id. - Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | int | No | Page number (default 1) |
| page_size | int | No | Number of items per page (default 10) |
| user_id | string | No | Filter by user ID |
- Response Example:
{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"id": 1,
"user_id": "user123",
"mode": "default",
"token": 100,
"updatetime": 1623456789,
"avail_token": 50
}
],
"total": 1
}
}
๐ 3. Update User Mode
- Endpoint:
POST /user/update/mode - Description: Update the mode (model) for a user.
- Request Parameters (Form):
| Parameter | Type | Required | Description |
|---|---|---|---|
| user_id | string | Yes | Unique user identifier |
| mode | string | Yes | New mode to set |
- Response Example:
{
"code": 0,
"msg": "success",
"data": null
}
๐ 4. Get User Records
- Endpoint:
GET /record/list - Description: Retrieve paginated user conversation records, with optional filters for deletion status and user ID.
- Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| page | int | No | Page number (default 1) |
| pageSize | int | No | Items per page (default 10) |
| isDeleted | int | No | Filter by deletion status (0 = not deleted, 1 = deleted, default all) |
| user_id | string | No | User ID filter |
- Response Example:
{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"id": 1,
"user_id": "user123",
"question": "What's AI?",
"answer": "Artificial Intelligence...",
"content": "conversation content",
"token": 50,
"is_deleted": 0,
"create_time": 1623456789,
"record_type": 1
}
],
"total": 1
}
}
๐ Data Structure Definitions
โ User Object Fields
| Field | Type | Description |
|---|---|---|
| id | int64 | User primary key ID |
| user_id | string | Unique user identifier |
| mode | string | Current mode |
| token | int | Total tokens |
| updatetime | int64 | Update timestamp |
| avail_token | int | Available tokens |
โ Record Object Fields
| Field | Type | Description |
|---|---|---|
| id | int | Record ID |
| user_id | string | Associated user ID |
| question | string | User question content |
| answer | string | System response |
| content | string | Uploaded special content (e.g., image, audio) |
| token | int | Tokens consumed |
| is_deleted | int | Deletion status (0 = no, 1 = yes) |
| create_time | int64 | Creation timestamp |
| record_type | int | Record type (e.g., WEB or other) |
5. Real-time Communication API โ Communicate
-
Endpoint:
POST /communicate -
Description: Real-time client request handling via Server-Sent Events (SSE), supporting text chat, image/video generation, multi-agent tasks, and various commands.
-
Request Method:
POST -
Request Headers:
Content-Type: Usuallyapplication/octet-stream(binary image/video data)
-
Query Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
| prompt | string | Yes | Request content, can include commands starting with / or plain text |
| user_id | string | Yes | User unique identifier (numeric string) |
-
Request Body:
- Binary data such as image or audio, depending on command.
Supported Commands
| Command | Description |
|---|---|
/chat | Start a normal chat session |
/mode | Set the LLM mode |
/state | View current session state and settings |
/clear | Clear all conversation history |
/retry | Retry last question |
/photo | Generate image based on prompt or uploaded image |
/video | Generate video based on prompt |
/task | Let multiple agents collaborate on a task |
/mcp | Use multi-agent control panel for complex task planning |
/help | Show this help message (list of commands) |
/chat
/mode
/state
/clear
/retry
/photo
/video
/task
/mcp
/help
Response
-
Content-Type:
text/event-stream -
Headers:
Cache-Control: no-cacheConnection: keep-alive
-
Body: Server-sent event stream data pushed in real-time.
-
Error Responses:
| Status Code | Description | Response Text |
|---|---|---|
| 400 | Missing required prompt param | Missing prompt parameter |
| 500 | Request body read failure or unsupported streaming | Error reading request body or Streaming unsupported! |
Example Request
POST /api/communicate?prompt=/photo sunset&user_id=12345 HTTP/1.1
Content-Type: application/octet-stream
<binary image data>
6. Get Current Startup Command Line Arguments
- Endpoint:
GET /command/get - Description: Return the current command-line parameters that differ from the config struct defaults, formatted as CLI flags.
- Request Parameters: None
- Response Example:
{
"code": 0,
"msg": "success",
"data": "-mcp_conf_path=/path/to/mcp_conf.json -some_flag=value "
}
7. Get Full Current Configuration
- Endpoint:
GET /conf/get - Description: Return the full current configuration from all modules (base, audio, llm, photo, rag, video).
- Request Parameters: None
- Response Example:
{
"code": 0,
"msg": "success",
"data": {
"base": {
...
},
"audio": {
...
},
"llm": {
...
},
"photo": {
...
},
"rag": {
...
},
"video": {
...
}
}
}
8. Update Configuration Field
- Endpoint:
POST /conf/update - Description: Dynamically update a specified field in a specific config struct.
- Request Body (JSON):
{
"type": "base|audio|llm|photo|rag|video",
"key": "json_tag_field",
"value": "new_value"
}
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Config type, e.g., "base" |
| key | string | Yes | Struct field's JSON tag |
| value | any | Yes | New value for the field |
- Response Example:
{
"code": 0,
"msg": "success",
"data": ""
}
-
Note:
- Special fields (e.g.,
allowed_user_ids,admin_user_ids) are processed specially. - Unsupported types return parameter error.
- Special fields (e.g.,
9. Get MCP Configuration
- Endpoint:
GET /mcp/get - Description: Read and return the MCP configuration file content.
- Request Parameters: None
- Response Example:
{
"code": 0,
"msg": "success",
"data": {
"McpServers": {
"server1": {
...
},
"server2": {
...
}
},
...
}
}
10. Update MCP Configuration
-
Endpoint:
POST /mcp/update?name={name} -
Description: Update MCP config for a given server name.
-
Request Parameters:
-
Query:
name(string, required): MCP server name
-
JSON Body: MCP configuration object (
mcpParam.MCPConfigstruct)
-
-
Response Example:
{
"code": 0,
"msg": "success",
"data": ""
}
11. Delete MCP Configuration
-
Endpoint:
DELETE /mcp/delete?name={name} -
Description: Delete MCP config by server name, close the client and remove from task tools.
-
Request Parameters:
-
Query:
name(string, required): MCP server name
-
-
Response Example:
{
"code": 0,
"msg": "success",
"data": ""
}
12. Enable or Disable MCP Configuration
-
Endpoint:
POST /mcp/disable?name={name}&disable={0|1} -
Description: Enable or disable MCP config for the specified server.
-
Request Parameters:
-
Query:
name(string, required): MCP server namedisable(string, required):"1"to disable,"0"to enable
-
-
Response Example:
{
"code": 0,
"msg": "success",
"data": ""
}
13. Synchronize MCP Configuration
- Endpoint:
POST /mcp/sync - Description: Clear all MCP clients and task tools, then reinitialize.
- Request Parameters: None
- Response Example:
{
"code": 0,
"msg": "success",
"data": ""
}
Notes
- Successful responses all follow the format:
{
"code": 0,
"msg": "success",
"data": <response
data
or
empty
string>
}
- Failure responses include a non-zero code and an error message:
{
"code": <error
code>,
"msg": <error
message>,
"data": null
}