AI
AI assistants: chat, reply suggestions, usage statistics. · 9 endpoints
- GET/ai/assistants
- GET/ai/assistants/{id}
- GET/ai/assistants/options
- GET/ai/default
- POST/ai/chat
- POST/ai/suggest
- GET/ai/usage/stats
- GET/ai/usage/logs
- GET/accounts/{accountId}/ai-assistant
AI assistants (API keys are not returned)
GET
/api/v1/ai/assistantsScope: ai:manageExample request
bash
curl "http://127.0.0.1:9900/api/v1/ai/assistants" \
-H "Authorization: Bearer dpk_xxx"Get an assistant
GET
/api/v1/ai/assistants/{id}Scope: ai:manageParameters
idpath · required | string max 200 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/ai/assistants/{id}" \
-H "Authorization: Bearer dpk_xxx"Assistants to choose from when calling /ai/chat (name, platform and model only: no prompt, no key)
GET
/api/v1/ai/assistants/optionsScope: ai:useExample request
bash
curl "http://127.0.0.1:9900/api/v1/ai/assistants/options" \
-H "Authorization: Bearer dpk_xxx"Default assistant
GET
/api/v1/ai/defaultScope: ai:useExample request
bash
curl "http://127.0.0.1:9900/api/v1/ai/default" \
-H "Authorization: Bearer dpk_xxx"Ask an AI assistant (uses the assistant's configuration, knowledge and quota)
POST
/api/v1/ai/chatScope: ai:useRequest body (JSON)
assistant_idoptional | string max 200 | Empty = the default assistant |
messagesrequired | object[] max 100 items | |
└rolerequired | "user" | "assistant" | "system" | |
└contentrequired | string | |
max_tokensoptional | integer ≥ 1 · ≤ 8000 | |
temperatureoptional | number ≥ 0 · ≤ 2 | |
raw_systemoptional | boolean | true = send exactly the given messages (including system) to the model, without adding the assistant's system prompt / knowledge: for apps that handle their own prompts |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/ai/chat" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Tóm tắt chính sách đổi trả"}]}'Suggest a reply for a conversation (like the suggestion button in chat)
POST
/api/v1/ai/suggestScope: ai:useRequest body (JSON)
account_idrequired | string max 200 | |
thread_idrequired | string max 200 | |
assistant_idoptional | string max 200 | Empty = the assistant assigned to the account (suggestion role) or the default one |
history_limitoptional | integer ≥ 1 · ≤ 100 · default 30 |
Example request
bash
curl -X POST "http://127.0.0.1:9900/api/v1/ai/suggest" \
-H "Authorization: Bearer dpk_xxx" \
-H "Content-Type: application/json" \
-d '{"account_id":"string","thread_id":"string","assistant_id":"string"}'Token usage per day
GET
/api/v1/ai/usage/statsScope: ai:manageParameters
assistant_idquery · optional | string max 200 | |
daysquery · optional | integer ≥ 1 · ≤ 365 · default 30 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/ai/usage/stats" \
-H "Authorization: Bearer dpk_xxx"AI call log
GET
/api/v1/ai/usage/logsScope: ai:manageParameters
assistant_idquery · optional | string max 200 | |
fromquery · optional | integer ≥ 0 | |
toquery · optional | integer ≥ 0 | |
limitquery · optional | integer ≥ 1 · ≤ 1000 · default 100 |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/ai/usage/logs" \
-H "Authorization: Bearer dpk_xxx"Assistants assigned to the account (suggestions / panel)
GET
/api/v1/accounts/{accountId}/ai-assistantScope: ai:useParameters
accountIdpath · required | string max 200 | Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID. |
rolequery · optional | "suggestion" | "panel" default "suggestion" |
Example request
bash
curl "http://127.0.0.1:9900/api/v1/accounts/{accountId}/ai-assistant" \
-H "Authorization: Bearer dpk_xxx"