AI · API Reference

API — AI

Tài liệu các endpoint của module ai. Mỗi endpoint có request format, response format, lỗi có thể xảy ra và ví dụ thực tế.

Tóm tắt endpoint

MethodPathMô tảAuthRate limit
POST/api/v1/ai/moderateModerate content. [CẦN XÁC NHẬN] stub.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
POST/api/v1/ai/captionGenerate caption. [CẦN XÁC NHẬN] stub.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
POST/api/v1/ai/smart-replyGenerate smart reply. [CẦN XÁC NHẬN] stub.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.
GET/api/v1/ai/recommendationsRecommendations. [CẦN XÁC NHẬN] stub.BearerGlobal apiLimiter; một số flow có Redis/domain limit riêng.

POST /api/v1/ai/moderate

POST Auth required apiLimiter

Endpoint này dùng để moderate content. [CẦN XÁC NHẬN] stub. Gọi endpoint này khi client cần thao tác đúng phạm vi module ai.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X POST http://localhost:3302/api/v1/ai/moderate \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "ai",
    "endpoint": "/api/v1/ai/moderate"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

POST /api/v1/ai/caption

POST Auth required apiLimiter

Endpoint này dùng để generate caption. [CẦN XÁC NHẬN] stub. Gọi endpoint này khi client cần thao tác đúng phạm vi module ai.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X POST http://localhost:3302/api/v1/ai/caption \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "ai",
    "endpoint": "/api/v1/ai/caption"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

POST /api/v1/ai/smart-reply

POST Auth required apiLimiter

Endpoint này dùng để generate smart reply. [CẦN XÁC NHẬN] stub. Gọi endpoint này khi client cần thao tác đúng phạm vi module ai.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectTùy endpointTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X POST http://localhost:3302/api/v1/ai/smart-reply \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "ai",
    "endpoint": "/api/v1/ai/smart-reply"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú

GET /api/v1/ai/recommendations

GET Auth required apiLimiter

Endpoint này dùng để recommendations. [CẦN XÁC NHẬN] stub. Gọi endpoint này khi client cần thao tác đúng phạm vi module ai.

Request

HeaderGiá trịBắt buộcMô tả
AuthorizationBearer accessTokenJWT access token nếu route protected
x-refresh-tokenraw refresh tokenKhôngRefresh token header theo middleware
ParameterKiểuMô tảVí dụ
path paramsstringCác phần :publicId, :username, :code nếu path cócm123
query paramsstring/numbertake, after, page, limit hoặc module-specific querytake=20
FieldKiểuBắt buộcValidationMô tảVí dụ giá trị
bodyobjectKhôngTheo DTO Zod nếu route có validate()Payload nghiệp vụ của endpoint{"content":"Hello"}
Ví dụ request
curl -X GET http://localhost:3302/api/v1/ai/recommendations \
  -H "Authorization: Bearer ACCESS_TOKEN" \
  -H "Content-Type: application/json"

Response

200/201 — Thành công

FieldKiểuLuôn có?Mô tả
successbooleantrue khi request thành công
messagestringKhôngMột số controller truyền message
dataobject/arrayTùy endpointDữ liệu trả về từ service
paginationobjectVới listCursor/offset pagination
{
  "success": true,
  "data": {
    "module": "ai",
    "endpoint": "/api/v1/ai/recommendations"
  }
}

Lỗi có thể xảy ra

HTTP StatusError CodeKhi nào xảy raCách xử lý ở client
401UNAUTHORIZEDUnauthorizedLogin lại hoặc refresh token.
400VALIDATION_FAILEDValidation failedClient sửa field sai.
404NOT_FOUNDResource not foundRefresh dữ liệu.
403FORBIDDENForbiddenẨn action trong UI.
500INTERNAL_SERVER_ERRORExternal dependency failOn-call kiểm tra provider/log.
Ví dụ lỗi
{
  "success": false,
  "message": "Validation failed"
}

Ghi chú