Skip to content

AI

AI assistants: chat, reply suggestions, usage statistics. · 9 endpoints

AI assistants (API keys are not returned)

GET/api/v1/ai/assistantsScope: ai:manage

Example 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:manage

Parameters

id
path · 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:use

Example 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:use

Example 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:use

Request body (JSON)

assistant_id
optional
string
max 200
Empty = the default assistant
messages
required
object[]
max 100 items
└role
required
"user" | "assistant" | "system"
└content
required
string
max_tokens
optional
integer
≥ 1 · ≤ 8000
temperature
optional
number
≥ 0 · ≤ 2
raw_system
optional
booleantrue = 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:use

Request body (JSON)

account_id
required
string
max 200
thread_id
required
string
max 200
assistant_id
optional
string
max 200
Empty = the assistant assigned to the account (suggestion role) or the default one
history_limit
optional
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:manage

Parameters

assistant_id
query · optional
string
max 200
days
query · 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:manage

Parameters

assistant_id
query · optional
string
max 200
from
query · optional
integer
≥ 0
to
query · optional
integer
≥ 0
limit
query · 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:use

Parameters

accountId
path · required
string
max 200
Account ID (accounts.zalo_id). Facebook uses the Facebook ID, Telegram uses the Telegram account ID.
role
query · 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"