Skip to main content

Agent Config Endpoints

AI agent configuration, character management, and chat history. Base path: /toy/agent.

An agent is a named AI persona (e.g. "Cheeko", "Dino") with its own system prompt, model configuration, and language settings. Each device is linked to one agent; the MQTT gateway and LiveKit server read agent config at session start.

Endpoint Summary

Agent CRUD

MethodPathAuthDescription
GET/toy/agent/listUserList agents (own agents; admin sees all)
GET/toy/agent/allAdminAll agents, paginated
POST/toy/agentUserCreate agent
GET/toy/agent/:idUserGet agent by ID
PUT/toy/agent/:idUserUpdate agent
DELETE/toy/agent/:idUserDelete agent and unlink devices

Agent Templates

MethodPathAuthDescription
GET/toy/agent/templateUserList visible templates
POST/toy/agent/templateUserCreate template
GET/toy/agent/template/:idUserGet template by ID
PUT/toy/agent/template/:idUserUpdate template
DELETE/toy/agent/template/:idUserDelete template
POST/toy/agent/template/:id/apply-to-agentsUserPush template changes to all matching agents

Device-facing config (no auth required)

MethodPathAuthDescription
GET/toy/agent/config/:macNoneKey endpoint — full agent config by device MAC
GET/toy/agent/prompt/:macNoneAlias for /config/:mac
GET/toy/agent/agent-id/:macNoneGet agent ID for device
GET/toy/agent/device/:mac/agent-idNoneGateway alias for agent ID
GET/toy/agent/current-character/:macNoneCurrent character name
GET/toy/agent/device/:mac/current-characterNoneGateway alias for current character
POST/toy/agent/device/:mac/set-characterNoneSwitch character by name
POST/toy/agent/device/:mac/cycle-characterNoneCycle to next character

Chat history

MethodPathAuthDescription
POST/toy/agent/chat-messageNoneSave single chat message (LiveKit agent)
POST/toy/agent/chat-history/reportNoneReport single message in real-time
POST/toy/agent/chat-history/sessionNoneBatch upload all messages for a session
GET/toy/agent/:id/sessionsUserList sessions for an agent
GET/toy/agent/:id/history/:sessionIdUserGet messages for a session

GET /toy/agent/config/:mac

The most important endpoint in the system. Called by the MQTT gateway and LiveKit server at the start of every voice session to get the full agent configuration for the connected device.

Path Parameters

ParamDescription
macDevice MAC address (any format; normalized internally)

Response

{
"code": 0,
"msg": "success",
"data": {
"agentId": "550e8400-e29b-41d4-a716-446655440000",
"agentName": "Cheeko",
"systemPrompt": "You are Cheeko, a friendly AI companion for children...",
"asrModelId": "deepgram",
"vadModelId": "silero",
"llmModelId": "llama-3.3-70b-versatile",
"ttsModelId": "elevenlabs",
"ttsVoiceId": "cheeko_voice_id",
"memModelId": "mem0",
"langCode": "en",
"language": "English",
"chatHistoryConf": 10
}
}
FieldTypeDescription
agentIdstring (UUID)Agent identifier
agentNamestringDisplay name / character name
systemPromptstringFull system prompt for the LLM
asrModelIdstringSpeech-to-text model identifier
vadModelIdstringVoice activity detection model
llmModelIdstringLanguage model identifier
ttsModelIdstringText-to-speech model identifier
ttsVoiceIdstringTTS voice ID (e.g. ElevenLabs voice)
memModelIdstringMemory/personalization model
langCodestringISO language code (e.g. "en")
languagestringFull language name (e.g. "English")
chatHistoryConfintegerNumber of recent messages to include in LLM context

Returns 404 if the device or its linked agent is not found.


GET /toy/agent/device/:mac/agent-id

Used by the LiveKit server to resolve the agent ID for a device MAC before starting a session.

Response

{
"code": 0,
"msg": "success",
"data": "550e8400-e29b-41d4-a716-446655440000"
}

data is the agent ID string directly.


GET /toy/agent/device/:mac/current-character

Returns the character name currently assigned to the device. Used by the MQTT gateway for display purposes.

Response

{
"code": 0,
"msg": "success",
"data": { "characterName": "Cheeko" }
}

POST /toy/agent/device/:mac/set-character

Switches the device's active character/agent by name. The server finds the agent with matching agent_name under the device owner's account.

Request

{ "characterName": "Dino" }

Response

{
"code": 0,
"msg": "success",
"data": { "success": true, "newModeName": "Dino" }
}

POST /toy/agent/device/:mac/cycle-character

Advances the device to the next character in the owner's agent list (ordered by sort field). Wraps around at the end.

Response

{
"code": 0,
"msg": "success",
"data": { "success": true, "newModeName": "Robo" }
}

Agent CRUD Endpoints

POST /toy/agent — Create agent

Request

{
"agentCode": "CHEEKO",
"agentName": "Cheeko",
"asrModelId": "deepgram",
"vadModelId": "silero",
"llmModelId": "llama-3.3-70b-versatile",
"vllmModelId": null,
"ttsModelId": "elevenlabs",
"ttsVoiceId": "cheeko_voice_id",
"memModelId": "mem0",
"intentModelId": null,
"chatHistoryConf": 10,
"systemPrompt": "You are Cheeko...",
"summaryMemory": "",
"langCode": "en",
"language": "English",
"sort": 0
}
FieldTypeDescription
agentCodestringOptional code linking agent to a template
agentNamestringRequired. Display name
asrModelIdstringASR model identifier
vadModelIdstringVAD model identifier
llmModelIdstringLLM model identifier
ttsModelIdstringTTS model identifier
ttsVoiceIdstringVoice ID within TTS provider
memModelIdstringMemory model identifier
chatHistoryConfintegerContext window message count
systemPromptstringLLM system prompt
summaryMemorystringPersistent memory summary
langCodestringLanguage code (en, hi, etc.)
languagestringLanguage display name
sortintegerSort order in character list

GET /toy/agent/list

Returns agents owned by the authenticated user. Super admins see all agents with ownerUsername included.

Query Parameters

ParamDefaultDescription
page1Page number
limit20Items per page

Response

{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"id": "uuid",
"agentName": "Cheeko",
"memModelId": "mem0",
"systemPrompt": "...",
"summaryMemory": "",
"lastConnectedAt": "2024-03-01T10:00:00.000Z",
"deviceCount": 2,
"deviceMacAddresses": "AA:BB:CC:DD:EE:FF,11:22:33:44:55:66",
"ownerUsername": "admin@example.com",
"createDate": "2024-01-01T00:00:00.000Z"
}
],
"total": 5
}
}

DELETE /toy/agent/:id

Deletes the agent and performs cascading cleanup:

  1. Sets agent_id and kid_id to null on all linked devices (devices are not deleted)
  2. Deletes all ai_agent_chat_history records for the agent
  3. Deletes plugin mappings from ai_agent_plugin_mapping
  4. Deletes the agent record

Agent Template Endpoints

Templates are reusable agent configurations. When a template is updated and applied, all agents with a matching agent_code are updated.

POST /toy/agent/template — Create template

Same fields as agent creation, plus:

FieldTypeDescription
isVisibleinteger1 = visible to users, 0 = hidden
sortintegerDisplay order

POST /toy/agent/template/:id/apply-to-agents

Finds all agents where agent_code matches the template's agentCode and updates them with the template's current settings.

{
"code": 0,
"msg": "Template applied to 3 agent(s)",
"data": {
"updatedCount": 3,
"agentCode": "CHEEKO"
}
}

Chat History Endpoints

POST /toy/agent/chat-message

Used by the LiveKit agent to persist individual messages during a conversation.

Request

{
"macAddress": "AA:BB:CC:DD:EE:FF",
"agentId": "agent-uuid",
"sessionId": "session-uuid",
"chatType": 1,
"content": "Can you tell me a story?",
"audioId": "audio-file-id"
}
FieldTypeDescription
macAddressstringRequired. Device MAC
agentIdstringRequired. Agent UUID
sessionIdstringRequired. Session UUID
chatTypeintegerRequired. 1 = user message, 2 = agent message
contentstringRequired. Message text
audioIdstringOptional. Audio file reference

POST /toy/agent/chat-history/session

Batch upload all messages for a session at once (used by LiveKit workers at session end).

Request

{
"macAddress": "AA:BB:CC:DD:EE:FF",
"agentId": "agent-uuid",
"sessionId": "session-uuid",
"messages": [
{
"chatType": 1,
"content": "Hello!",
"audioId": null,
"timestamp": "2024-03-01T10:00:00.000Z"
},
{
"chatType": 2,
"content": "Hi there! How can I help?",
"audioId": "audio-123",
"timestamp": "2024-03-01T10:00:01.000Z"
}
]
}

GET /toy/agent/:id/sessions

Returns paginated list of unique session IDs for an agent.

Response

{
"code": 0,
"msg": "success",
"data": {
"list": [
{
"sessionId": "session-uuid",
"createdAt": "2024-03-01T10:00:00.000Z",
"chatCount": 24
}
],
"total": 10
}
}

GET /toy/agent/:id/history/:sessionId

Returns all messages in a session, ordered by created_at ascending.

Response

{
"code": 0,
"msg": "success",
"data": [
{
"createdAt": "2024-03-01T10:00:00.000Z",
"chatType": 1,
"content": "Hello!",
"audioId": null,
"macAddress": "AA:BB:CC:DD:EE:FF"
}
]
}