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
}
ParameterTypeRequiredDescription
user_idstringYesUnique identifier for the user
tokenintYesNumber 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:
ParameterTypeRequiredDescription
pageintNoPage number (default 1)
page_sizeintNoNumber of items per page (default 10)
user_idstringNoFilter 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):
ParameterTypeRequiredDescription
user_idstringYesUnique user identifier
modestringYesNew 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:
ParameterTypeRequiredDescription
pageintNoPage number (default 1)
pageSizeintNoItems per page (default 10)
isDeletedintNoFilter by deletion status (0 = not deleted, 1 = deleted, default all)
user_idstringNoUser 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

FieldTypeDescription
idint64User primary key ID
user_idstringUnique user identifier
modestringCurrent mode
tokenintTotal tokens
updatetimeint64Update timestamp
avail_tokenintAvailable tokens

โœ… Record Object Fields

FieldTypeDescription
idintRecord ID
user_idstringAssociated user ID
questionstringUser question content
answerstringSystem response
contentstringUploaded special content (e.g., image, audio)
tokenintTokens consumed
is_deletedintDeletion status (0 = no, 1 = yes)
create_timeint64Creation timestamp
record_typeintRecord 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: Usually application/octet-stream (binary image/video data)
  • Query Parameters:

ParameterTypeRequiredDescription
promptstringYesRequest content, can include commands starting with / or plain text
user_idstringYesUser unique identifier (numeric string)
  • Request Body:

    • Binary data such as image or audio, depending on command.

Supported Commands

CommandDescription
/chatStart a normal chat session
/modeSet the LLM mode
/stateView current session state and settings
/clearClear all conversation history
/retryRetry last question
/photoGenerate image based on prompt or uploaded image
/videoGenerate video based on prompt
/taskLet multiple agents collaborate on a task
/mcpUse multi-agent control panel for complex task planning
/helpShow this help message (list of commands)

/chat

aa92b3c9580da6926a48fc1fc5c37c03

/mode

aa92b3c9580da6926a48fc1fc5c37c03 aa92b3c9580da6926a48fc1fc5c37c03

/state

aa92b3c9580da6926a48fc1fc5c37c03

/clear

aa92b3c9580da6926a48fc1fc5c37c03

/retry

aa92b3c9580da6926a48fc1fc5c37c03

/photo

aa92b3c9580da6926a48fc1fc5c37c03

/video

aa92b3c9580da6926a48fc1fc5c37c03

/task

aa92b3c9580da6926a48fc1fc5c37c03

/mcp

aa92b3c9580da6926a48fc1fc5c37c03

/help

aa92b3c9580da6926a48fc1fc5c37c03

Response

  • Content-Type: text/event-stream

  • Headers:

    • Cache-Control: no-cache
    • Connection: keep-alive
  • Body: Server-sent event stream data pushed in real-time.

  • Error Responses:

Status CodeDescriptionResponse Text
400Missing required prompt paramMissing prompt parameter
500Request body read failure or unsupported streamingError 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"
}
ParameterTypeRequiredDescription
typestringYesConfig type, e.g., "base"
keystringYesStruct field's JSON tag
valueanyYesNew 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.

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.MCPConfig struct)

  • 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 name
      • disable (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
}